/** * Receives an OGC feature and adds it into the collection * * @param feature the OGC feature */ public void feature(SimpleFeature feature) { featureCollection.add(feature); } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { SimpleFeatureCollection featureCollection = (SimpleFeatureCollection) node.getChildValue(FeatureCollection.class); if (featureCollection == null) { featureCollection = DefaultFeatureCollections.newCollection(); } //<element maxOccurs="unbounded" minOccurs="0" ref="gml:featureMember"/> featureCollection.addAll(node.getChildValues(SimpleFeature.class)); //<element minOccurs="0" ref="gml:featureMembers"/> SimpleFeature[] featureMembers = (SimpleFeature[]) node.getChildValue(SimpleFeature[].class); if (featureMembers != null) { for (int i = 0; i < featureMembers.length; i++) { featureCollection.add(featureMembers[i]); } } return featureCollection; }
public boolean add(SimpleFeature o) { return collection.add(o); }
public boolean add(SimpleFeature o) { return delegate.add(o); }
public boolean add(SimpleFeature o) { long size = delegate.size(); if ( size < max ) { return delegate.add( o ); } return false; }
public boolean add(SimpleFeature o) { if ( !filter.evaluate( o ) ) { return false; } return delegate.add( o ); }
/** * Copies the provided features into a FeatureCollection. * <p> * Often used when gathering a SimpleFeatureCollection into memory. * * @param list * features to add to a new FeatureCollection * @return FeatureCollection */ public static SimpleFeatureCollection collection(List<SimpleFeature> list) { SimpleFeatureCollection collection = FeatureCollections.newCollection(); for (SimpleFeature feature : list) { collection.add(feature); } return collection; }
/** * Copies the provided features into a FeatureCollection. * <p> * Often used when gathering features for FeatureStore: * * <pre> * <code> * featureStore.addFeatures( DataUtilities.collection(feature)); * </code> * </pre> * * @param feature * a feature to add to a new collection * @return FeatureCollection */ public static SimpleFeatureCollection collection(SimpleFeature feature) { SimpleFeatureCollection collection = FeatureCollections.newCollection(); collection.add(feature); return collection; }
/** * @see org.geotools.data.FeatureResults#collection() */ public SimpleFeatureCollection collection() throws IOException { SimpleFeatureCollection fc = FeatureCollections.newCollection(); List<SimpleFeature> results = index.query(bounds); for (Iterator<SimpleFeature> it = results.iterator(); it.hasNext();) { fc.add(it.next()); } return fc; }
/** * Copies the provided features into a FeatureCollection. * <p> * Often used when gathering features for FeatureStore: * * <pre> * <code> * featureStore.addFeatures( DataUtilities.collection(array)); * </code> * </pre> * * @param features * Array of features * @return FeatureCollection */ public static SimpleFeatureCollection collection(SimpleFeature[] features) { SimpleFeatureCollection collection = FeatureCollections.newCollection(); final int length = features.length; for (int i = 0; i < length; i++) { collection.add(features[i]); } return collection; }
/** * Appends element. * <p> * This implementation calls <tt>add(size(), o)</tt>. * <p> * Note that this implementation throws an * <tt>UnsupportedOperationException</tt> unless <tt>add(int, Object)</tt> * is overridden. * * @param item * the Object element to be appended to this list. * @return <tt>true</tt> (as per the general contract of * <tt>Collection.add</tt>). * @throws UnsupportedOperationException * if the <tt>add</tt> method is not supported by this Set. * @throws ClassCastException * if the class of the specified element prevents it from being * added to this set. * @throws IllegalArgumentException * some aspect of this element prevents it from being added to * this collection. */ public boolean add(SimpleFeature feature) { boolean added = collection.add( feature ); if(added){ index.add( feature.getIdentifier() ); } return true; }
while (reader.hasNext()) { try { collection.add(reader.next()); } catch (NoSuchElementException e) { throw (IOException) new IOException("EOF").initCause(e);
/** * Copies the provided reader into a FeatureCollection, reader will be closed. * <p> * Often used when gathering features for FeatureStore: * * <pre> * <code> * featureStore.addFeatures( DataUtilities.collection(reader)); * </code> * </pre> * * @return FeatureCollection */ public static SimpleFeatureCollection collection(SimpleFeatureIterator reader) throws IOException { SimpleFeatureCollection collection = FeatureCollections.newCollection(); try { while (reader.hasNext()) { try { collection.add(reader.next()); } catch (NoSuchElementException e) { throw (IOException) new IOException("EOF").initCause(e); } } } finally { reader.close(); } return collection; } //
public void testBounds() throws Exception { PrecisionModel pm = new PrecisionModel(); Geometry[] g = new Geometry[4]; GeometryFactory gf = new GeometryFactory(pm); g[0] = gf.createPoint(new Coordinate(0, 0)); g[1] = gf.createPoint(new Coordinate(0, 10)); g[2] = gf.createPoint(new Coordinate(10, 0)); g[3] = gf.createPoint(new Coordinate(10, 10)); GeometryCollection gc = gf.createGeometryCollection(g); SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName("bounds"); tb.setCRS(null); tb.add("p1", Point.class); SimpleFeatureType t = tb.buildFeatureType(); SimpleFeatureCollection fc = FeatureCollections.newCollection(); SimpleFeatureBuilder b = new SimpleFeatureBuilder(t); for (int i = 0; i < g.length; i++) { b.add(g[i]); fc.add(b.buildFeature(null)); } assertEquals(gc.getEnvelopeInternal(), fc.getBounds()); }
protected void setUp() throws Exception { SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName("Dummy"); SimpleFeatureType schema = tb.buildFeatureType(); features = newCollection(schema); SimpleFeatureBuilder b = new SimpleFeatureBuilder(schema); for (int i = 0; i < 100; i++) { features.add(b.buildFeature(null)); } }
public SimpleFeatureCollection collection() throws IOException { try { SimpleFeatureCollection collection = FeatureCollections.newCollection(); //Feature feature; FeatureReader<SimpleFeatureType, SimpleFeature> reader = reader(); //SimpleFeatureType type = reader.getFeatureType(); try { while (reader.hasNext()) { collection.add(reader.next()); } } finally { reader.close(); } return collection; } catch (IllegalAttributeException e) { throw new DataSourceException("Could not read feature ", e); } }
found.add((SimpleFeature) feature);
/** * Wraps a grid coverage into a Feature. Code lifted from ArcGridDataSource * (temporary). * * @param coverage the grid coverage. * @return a feature with the grid coverage envelope as the geometry and the * grid coverage itself in the "grid" attribute. */ public static SimpleFeatureCollection wrapGridCoverage(final GridCoverage2D coverage) throws TransformException, SchemaException { final Polygon bounds = getPolygon(coverage.getEnvelope2D()); final CoordinateReferenceSystem sourceCRS = coverage.getCoordinateReferenceSystem2D(); SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder(getTypeFactory()); ftb.setName("GridCoverage"); ftb.add("geom", Polygon.class, sourceCRS); ftb.add("grid", GridCoverage.class); SimpleFeatureType schema = ftb.buildFeatureType(); // create the feature SimpleFeatureBuilder fb = new SimpleFeatureBuilder(schema, getFeatureFactory()); fb.add(bounds); fb.add(coverage); SimpleFeature feature = fb.buildFeature(null); final SimpleFeatureCollection collection = FeatureCollections.newCollection(); collection.add(feature); return collection; }
fb.add(generator.getBuffer(distances[i])); fb.add(distances[i]); result.add(fb.buildFeature("buffers." + (i + 1)));