/** * see interface for details. * * @param fc * @throws IOException */ public List<FeatureId> addFeatures(FeatureCollection<SimpleFeatureType, SimpleFeature> fc) throws IOException { FeatureStore<SimpleFeatureType, SimpleFeature> store = store(); // check if the feature collection needs to be retyped if (!store.getSchema().equals(fc.getSchema())) { fc = new RetypingFeatureCollection(DataUtilities.simple(fc), store.getSchema()); } return store().addFeatures(fc); }
} else { if (limitedAttributeSize > 0 && fc.getSchema().getDescriptors().size() > limitedAttributeSize) { if (fc instanceof SimpleFeatureCollection) {
FeatureSource fs = getFeatureSource(null, null); FeatureCollection fc = fs.getFeatures(query); return fc.getSchema();
public TransformFeatureCollectionWrapper( FeatureCollection<SimpleFeatureType, SimpleFeature> wrapped, Transformer transformer) { super(wrapped.getSchema()); this.wrapped = wrapped; this.transformer = transformer; }
public TemplateModel wrap(Object object) throws TemplateModelException { // check for feature collection if (object instanceof FeatureCollection) { // create a model with just one variable called 'features' SimpleHash map = new SimpleHash(); map.put( "features", templateFeatureCollectionFactory.createTemplateFeatureCollection( (FeatureCollection) object, this)); map.put("type", wrap(((FeatureCollection) object).getSchema())); return map; } else if (object instanceof ComplexType) { return buildType((ComplexType) object); } else if (object instanceof Feature) { return buildComplex((Feature) object); } return super.wrap(object); }
public SimpleFeatureType getSchema() { return collection.getSchema(); }
public T getSchema() { return delegate.getSchema(); }
return storeDelegate.addFeatures(collection); } else { if (collection.getSchema() instanceof SimpleFeatureType && storeDelegate instanceof SimpleFeatureStore) {
@Test public void testForce() throws Exception { FeatureTypeInfo fti = getCatalog().getFeatureTypeByName(MockData.BASIC_POLYGONS.getLocalPart()); assertEquals("EPSG:4269", fti.getSRS()); assertEquals(ProjectionPolicy.FORCE_DECLARED, fti.getProjectionPolicy()); FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures(); assertEquals(CRS.decode("EPSG:4269"), fc.getSchema().getCoordinateReferenceSystem()); FeatureIterator fi = fc.features(); Feature f = fi.next(); fi.close(); assertEquals(CRS.decode("EPSG:4269"), f.getType().getCoordinateReferenceSystem()); }
@Test public void testLeaveNative() throws Exception { FeatureTypeInfo fti = getCatalog().getFeatureTypeByName(MockData.LINES.getLocalPart()); assertEquals("EPSG:3004", fti.getSRS()); assertEquals(ProjectionPolicy.NONE, fti.getProjectionPolicy()); FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures(); assertEquals(CRS.decode("EPSG:32615"), fc.getSchema().getCoordinateReferenceSystem()); FeatureIterator fi = fc.features(); Feature f = fi.next(); // test that the geometry was left in tact Geometry g = (Geometry) f.getDefaultGeometryProperty().getValue(); assertTrue(g.equalsExact(WKT.read("LINESTRING(500125 500025,500175 500075)"))); fi.close(); assertEquals(CRS.decode("EPSG:32615"), f.getType().getCoordinateReferenceSystem()); }
@Test public void testReproject() throws Exception { FeatureTypeInfo fti = getCatalog().getFeatureTypeByName(MockData.POLYGONS.getLocalPart()); assertEquals("EPSG:4326", fti.getSRS()); assertEquals(ProjectionPolicy.REPROJECT_TO_DECLARED, fti.getProjectionPolicy()); FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures(); assertEquals(CRS.decode("EPSG:4326"), fc.getSchema().getCoordinateReferenceSystem()); FeatureIterator fi = fc.features(); Feature f = fi.next(); // test that geometry was actually reprojected Geometry g = (Geometry) f.getDefaultGeometryProperty().getValue(); assertFalse( g.equalsExact( WKT.read( "POLYGON((500225 500025,500225 500075,500275 500050,500275 500025,500225 500025))"))); fi.close(); assertEquals(CRS.decode("EPSG:4326"), f.getType().getCoordinateReferenceSystem()); }
@Test public void testWithRename() throws Exception { FeatureTypeInfo fti = getCatalog().getFeatureTypeByName("MyPoints"); assertEquals("EPSG:4326", fti.getSRS()); assertEquals(ProjectionPolicy.REPROJECT_TO_DECLARED, fti.getProjectionPolicy()); FeatureCollection fc = fti.getFeatureSource(null, null).getFeatures(); assertEquals(CRS.decode("EPSG:4326"), fc.getSchema().getCoordinateReferenceSystem()); FeatureIterator fi = fc.features(); Feature f = fi.next(); // test that geometry was reprojected Geometry g = (Geometry) f.getDefaultGeometryProperty().getValue(); assertFalse(g.equalsExact(WKT.read("POINT(500050 500050)"))); fi.close(); assertEquals(CRS.decode("EPSG:4326"), f.getType().getCoordinateReferenceSystem()); }
/** * Used to stage content in memory. * * <p>Client code is encouraged to use DataUtilities.collection( collection ) * * @param collection SimpleFeatureCollection to copy into memory */ public DefaultFeatureCollection( FeatureCollection<SimpleFeatureType, SimpleFeature> collection) { this(collection.getID(), collection.getSchema()); addAll(collection); }
public FilteringFeatureCollection(FeatureCollection<T, F> delegate, Filter filter) { super(delegate); this.delegate = delegate; this.filter = (Filter) filter.accept(new BindingFilterVisitor(delegate.getSchema()), null); }
/** * This constructor should not be used by client code. * * @param collection SimpleFeatureCollection to copy into memory */ public TreeSetFeatureCollection( FeatureCollection<SimpleFeatureType, SimpleFeature> collection) { this(collection.getID(), collection.getSchema()); addAll(collection); }
private static SimpleFeatureType origionalType( FeatureCollection<SimpleFeatureType, SimpleFeature> results) { while (true) { if (results instanceof ReprojectFeatureResults) { results = ((ReprojectFeatureResults) results).getOrigin(); } if (results instanceof ForceCoordinateSystemFeatureResults) { results = ((ForceCoordinateSystemFeatureResults) results).getOrigin(); } break; } return results.getSchema(); }
private static SimpleFeatureType origionalType( FeatureCollection<SimpleFeatureType, SimpleFeature> results) { while (true) { if (results instanceof ReprojectFeatureResults) { results = ((ReprojectFeatureResults) results).getOrigin(); } if (results instanceof ForceCoordinateSystemFeatureResults) { results = ((ForceCoordinateSystemFeatureResults) results).getOrigin(); } break; } return results.getSchema(); }
@Test public void testQueryWithPropertyNames() throws Exception { // check the schemas in feature source and feature collection SimpleFeatureSource fs = rts.getFeatureSource(RENAMED); Query q = new Query(RENAMED, Filter.INCLUDE, new String[] {"ADDRESS"}); FeatureCollection<SimpleFeatureType, SimpleFeature> fc = fs.getFeatures(q); assertEquals(1, fc.getSchema().getAttributeCount()); // make sure the feature schema is good as well FeatureIterator<SimpleFeature> it = fc.features(); SimpleFeature sf = it.next(); it.close(); assertEquals(1, sf.getAttributeCount()); assertNull(sf.getAttribute("FID")); assertNotNull(sf.getAttribute("ADDRESS")); } }
public void check(int index, SimpleFeature feature) { assertEquals( tname(features.getSchema().getName().getLocalPart()) + "." + index, feature.getID()); } });
public void check(int index, SimpleFeature feature) { assertEquals( tname(features.getSchema().getName().getLocalPart()) + "." + index, feature.getIdentifier().getID()); } });