use of org.geotools.data.simple.SimpleFeatureIterator in project GeoGig by boundlessgeo.
the class ExportOpTest method testExportFromHEAD.
@Test
public void testExportFromHEAD() throws Exception {
Feature[] points = new Feature[] { points1, points2, points3 };
for (Feature feature : points) {
insert(feature);
}
geogig.command(AddOp.class).call();
geogig.command(CommitOp.class).setAll(true).call();
MemoryDataStore dataStore = new MemoryDataStore(pointsType);
final String typeName = dataStore.getTypeNames()[0];
SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName);
SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
geogig.command(ExportOp.class).setFeatureStore(featureStore).setPath("HEAD:" + pointsName).call();
featureSource = dataStore.getFeatureSource(typeName);
featureStore = (SimpleFeatureStore) featureSource;
SimpleFeatureCollection featureCollection = featureStore.getFeatures();
assertEquals(featureCollection.size(), points.length);
SimpleFeatureIterator features = featureCollection.features();
assertTrue(collectionsAreEqual(features, points));
}
use of org.geotools.data.simple.SimpleFeatureIterator in project GeoGig by boundlessgeo.
the class ExportOpTest method testExportWithAlterUsingDefaultFeatureType.
@Test
public void testExportWithAlterUsingDefaultFeatureType() throws Exception {
Feature[] points = new Feature[] { points2, points1B, points3 };
for (Feature feature : points) {
insert(feature);
}
MemoryDataStore dataStore = new MemoryDataStore(pointsType);
final String typeName = dataStore.getTypeNames()[0];
SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName);
SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
geogig.command(ExportOp.class).setFeatureStore(featureStore).setPath(pointsName).setAlter(true).call();
featureSource = dataStore.getFeatureSource(typeName);
featureStore = (SimpleFeatureStore) featureSource;
SimpleFeatureCollection featureCollection = featureStore.getFeatures();
assertEquals(featureCollection.size(), points.length);
SimpleFeatureIterator features = featureCollection.features();
assertTrue(collectionsAreEqual(features, points));
}
use of org.geotools.data.simple.SimpleFeatureIterator in project GeoGig by boundlessgeo.
the class ExportOpTest method testExportFromTreeWithSeveralFeatureTypesUsingDefaultFeatureType.
@Test
public void testExportFromTreeWithSeveralFeatureTypesUsingDefaultFeatureType() throws Exception {
Feature[] points = new Feature[] { points2, points1B, points3 };
for (Feature feature : points) {
insert(feature);
}
Feature[] expectedPoints = new Feature[] { points2, points3 };
MemoryDataStore dataStore = new MemoryDataStore(pointsType);
final String typeName = dataStore.getTypeNames()[0];
SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName);
SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
geogig.command(ExportOp.class).setFeatureStore(featureStore).setPath(pointsName).exportDefaultFeatureType().call();
featureSource = dataStore.getFeatureSource(typeName);
featureStore = (SimpleFeatureStore) featureSource;
SimpleFeatureCollection featureCollection = featureStore.getFeatures();
assertEquals(featureCollection.size(), expectedPoints.length);
SimpleFeatureIterator features = featureCollection.features();
assertTrue(collectionsAreEqual(features, expectedPoints));
}
Aggregations