use of org.opengis.feature.simple.SimpleFeature in project GeoGig by boundlessgeo.
the class ImportOpTest method testImportAllWithDifferentFeatureTypesAndDestPathAndAdd.
@Test
public void testImportAllWithDifferentFeatureTypesAndDestPathAndAdd() throws Exception {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setCRS(CRS.decode("EPSG:4326"));
builder.add("geom", Point.class);
builder.add("label", String.class);
builder.setName("dest");
SimpleFeatureType type = builder.buildFeatureType();
GeometryFactory gf = new GeometryFactory();
SimpleFeature feature = SimpleFeatureBuilder.build(type, new Object[] { gf.createPoint(new Coordinate(0, 0)), "feature0" }, "feature");
geogig.getRepository().workingTree().insert("dest", feature);
ImportOp importOp = geogig.command(ImportOp.class);
importOp.setDataStore(TestHelper.createTestFactory().createDataStore(null));
importOp.setAll(true);
importOp.setOverwrite(false);
importOp.setDestinationPath("dest");
importOp.setAdaptToDefaultFeatureType(false);
importOp.call();
Iterator<NodeRef> features = geogig.command(LsTreeOp.class).setStrategy(Strategy.DEPTHFIRST_ONLY_FEATURES).call();
ArrayList<NodeRef> list = Lists.newArrayList(features);
assertEquals(5, list.size());
TreeSet<ObjectId> set = Sets.newTreeSet();
ArrayList<RevFeatureType> ftlist = new ArrayList<RevFeatureType>();
for (NodeRef node : list) {
Optional<RevFeatureType> ft = geogig.command(RevObjectParse.class).setObjectId(node.getMetadataId()).call(RevFeatureType.class);
assertTrue(ft.isPresent());
ftlist.add(ft.get());
set.add(node.getMetadataId());
}
assertEquals(4, set.size());
}
use of org.opengis.feature.simple.SimpleFeature in project GeoGig by boundlessgeo.
the class WorkingTreeTest method testInsertPagingFeatureSource.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testInsertPagingFeatureSource() throws Exception {
assertEquals(2, super.getGeogig().getPlatform().availableProcessors());
final List<SimpleFeature> features = ImmutableList.of((SimpleFeature) points1, (SimpleFeature) points2, (SimpleFeature) points3);
MemoryDataStore store = new MemoryDataStore();
store.addFeatures(features);
final QueryCapabilities caps = mock(QueryCapabilities.class);
when(caps.isOffsetSupported()).thenReturn(true);
FeatureSource source = new ForwardingFeatureSource(store.getFeatureSource(pointsName)) {
@Override
public QueryCapabilities getQueryCapabilities() {
return caps;
}
@Override
public FeatureCollection getFeatures(Query query) throws IOException {
Integer startIndex = query.getStartIndex();
if (startIndex == null) {
return super.getFeatures();
}
int toIndex = (int) Math.min((long) startIndex + query.getMaxFeatures(), features.size());
List<SimpleFeature> result = features.subList(startIndex, toIndex);
return DataUtilities.collection(result);
}
};
assertTrue(source.getQueryCapabilities().isOffsetSupported());
String treePath = "target_typename";
workTree.insert(treePath, source, Query.ALL, LISTENER);
assertEquals(3, workTree.countUnstaged(treePath).featureCount());
}
use of org.opengis.feature.simple.SimpleFeature in project ddf by codice.
the class CopyFilterDelegateTest method testFilterModification.
@Test
public void testFilterModification() {
Filter filterIn = FF.equals(TEST_PROPERTY, FOO_LITERAL);
FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
FilterDelegate<Filter> delegate = new FilterModifierDelegate(filterBuilder);
FilterAdapter fa = new GeotoolsFilterAdapterImpl();
Filter modifiedFilter = null;
try {
modifiedFilter = fa.adapt(filterIn, delegate);
} catch (UnsupportedQueryException e) {
fail(e.getMessage());
}
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName("testFeatureType");
b.add(TEST_PROPERTY_VALUE, String.class);
b.add("classification", String.class);
SimpleFeatureType featureType = b.buildFeatureType();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
builder.add(FOO_LITERAL_VALUE);
builder.add("UNCLASS");
SimpleFeature feature = builder.buildFeature("test");
assertTrue(modifiedFilter.evaluate(feature));
}
use of org.opengis.feature.simple.SimpleFeature in project ddf by codice.
the class TestPubSubOgcFilter method testContextualFeatureEvaluate.
@Test
@Ignore
public void testContextualFeatureEvaluate() throws TransformerException {
SimpleFeature feature = generateSampleFeature();
FilterFactory filterFactory = new FilterFactoryImpl();
PropertyIsEqualTo filter = filterFactory.equal(filterFactory.property("name"), filterFactory.literal("FirstFeature"), true);
printFilter(filter);
assertTrue(filter.evaluate(feature));
}
use of org.opengis.feature.simple.SimpleFeature in project ddf by codice.
the class TestPubSubOgcFilter method testGeospatialFeatureEvaluate.
@Test
@Ignore
public void testGeospatialFeatureEvaluate() throws TransformerException {
SimpleFeature feature = generateSampleFeature();
FilterFactoryImpl filterFactory = new FilterFactoryImpl();
BBOX bboxFilter = filterFactory.bbox("geo", -114, 10, -110, 30, DefaultGeographicCRS.WGS84.toString());
assertTrue(bboxFilter.evaluate(feature));
BBOX bboxFilter1 = filterFactory.bbox("geo", -110, 10, 0, 30, DefaultGeographicCRS.WGS84.toString());
assertFalse(bboxFilter1.evaluate(feature));
}
Aggregations