private SimpleFeatureCollection makePointFeatures() throws Exception { Map<Vertex, Double> points = makePoints(); /* Stage the point features in memory */ DefaultFeatureCollection featureCollection = new DefaultFeatureCollection(null, pointSchema); SimpleFeatureBuilder fbuilder = new SimpleFeatureBuilder(pointSchema); GeometryFactory gf = new GeometryFactory(); for (Map.Entry<Vertex, Double> entry : points.entrySet()) { Vertex vertex = entry.getKey(); Double travelTime = entry.getValue(); fbuilder.add(gf.createPoint(vertex.getCoordinate())); fbuilder.add(travelTime); featureCollection.add(fbuilder.buildFeature(null)); } return featureCollection; }
private SimpleFeatureCollection makeContourFeatures() throws Exception { Map<Integer, Geometry> contours = makeContours(); /* Stage the features in memory, in order from bottom to top, biggest to smallest */ DefaultFeatureCollection featureCollection = new DefaultFeatureCollection(null, contourSchema); SimpleFeatureBuilder fbuilder = new SimpleFeatureBuilder(contourSchema); List<Integer> thresholds = new ArrayList<Integer>(contours.keySet()); Collections.sort(thresholds); //Collections.reverse(thresholds); for (Integer threshold : thresholds) { Geometry contour = contours.get(threshold); fbuilder.add(contour); fbuilder.add(threshold); featureCollection.add(fbuilder.buildFeature(null)); } return featureCollection; }
/** * Create a geotools feature collection from a list of isochrones in the OTPA internal format. * Once in a FeatureCollection, they can for example be exported as GeoJSON. */ public static SimpleFeatureCollection makeContourFeatures(List<IsochroneData> isochrones) { DefaultFeatureCollection featureCollection = new DefaultFeatureCollection(null, contourSchema); SimpleFeatureBuilder fbuilder = new SimpleFeatureBuilder(contourSchema); for (IsochroneData isochrone : isochrones) { fbuilder.add(isochrone.geometry); fbuilder.add(isochrone.cutoffSec); featureCollection.add(fbuilder.buildFeature(null)); } return featureCollection; }
/** * Creates a new DefaultFeatureCollection. * * @return A new, empty DefaultFeatureCollection. */ protected SimpleFeatureCollection createCollection() { return new DefaultFeatureCollection(null, null); }
/** * Copies the provided features into a FeatureCollection. * * <p>Often used when gathering a SimpleFeatureCollection into memory. * * @param SimpleFeatureCollection the features to add to a new feature collection. * @return FeatureCollection */ public static DefaultFeatureCollection collection( FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection) { return new DefaultFeatureCollection(featureCollection); }
protected SimpleFeatureCollection createCollection(String id, SimpleFeatureType ft) { return new DefaultFeatureCollection(id, ft); } }
protected SimpleFeatureCollection createCollection(String id) { return new DefaultFeatureCollection(id, null); }
/** * 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) { DefaultFeatureCollection collection = new DefaultFeatureCollection(null, null); for (SimpleFeature feature : list) { collection.add(feature); } return collection; }
/** @see org.geotools.data.FeatureResults#collection() */ public SimpleFeatureCollection collection() throws IOException { DefaultFeatureCollection fc = new DefaultFeatureCollection(); 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(feature)); * </code> * </pre> * * @param feature a feature to add to a new collection * @return FeatureCollection */ public static SimpleFeatureCollection collection(SimpleFeature feature) { DefaultFeatureCollection collection = new DefaultFeatureCollection(null, null); collection.add(feature); return collection; }
f.getUserData().put("foo", "bar"); DefaultFeatureCollection features = new DefaultFeatureCollection(null, b.getFeatureType()); features.add(f);
protected SimpleFeatureCollection newCollection( SimpleFeatureType schema, List<SimpleFeature> list) { DefaultFeatureCollection features = new DefaultFeatureCollection(); features.addAll(list); return features; } }
/** * Go through collection contents and morph contents into SimpleFeatures as required. * * @param collection * @return SimpleFeatureCollection */ private SimpleFeatureCollection simpleFeatureCollection(Collection<?> collection) { DefaultFeatureCollection featureCollection = new DefaultFeatureCollection(); SimpleFeatureType schema = null; for (Object obj : collection) { if (schema == null) { schema = simpleType(obj); } SimpleFeature feature = simpleFeature(obj, schema); featureCollection.add(feature); } return featureCollection; }
public void addGranule( final String typeName, final SimpleFeature granule, final Transaction transaction) throws IOException { Utilities.ensureNonNull("typeName", typeName); Utilities.ensureNonNull("granule", granule); Utilities.ensureNonNull("transaction", transaction); final DefaultFeatureCollection collection = new DefaultFeatureCollection(); collection.add(granule); addGranules(typeName, collection, transaction); }
public SimpleFeatureCollection collection() throws IOException { try { DefaultFeatureCollection collection = new DefaultFeatureCollection(null, null); FeatureReader<SimpleFeatureType, SimpleFeature> reader = reader(); try { while (reader.hasNext()) { collection.add(reader.next()); } } finally { reader.close(); } return collection; } catch (org.opengis.feature.IllegalAttributeException e) { throw new DataSourceException("Could not read feature ", e); } } }
public void testInstance() { Function equInt = ff.function("Quantile", ff.literal(new DefaultFeatureCollection())); assertNotNull(equInt); }
public void testGetName() { Function qInt = ff.function("Quantile", ff.literal(new DefaultFeatureCollection())); assertEquals("Quantile", qInt.getName()); }
public SimpleFeatureCollection createLineCollection() throws Exception { DefaultFeatureCollection fc = new DefaultFeatureCollection(); fc.add(createLine(-177, 0, -177, 10)); fc.add(createLine(-177, 0, -200, 0)); fc.add(createLine(-177, 0, -177, 100)); return fc; }
public SimpleFeatureCollection createLineCollection() throws Exception { DefaultFeatureCollection fc = new DefaultFeatureCollection(); fc.add(createLine(-177, 0, -177, 10)); fc.add(createLine(-177, 0, -200, 0)); fc.add(createLine(-177, 0, -177, 100)); return fc; }
@Override protected void setUp() throws Exception { SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName("foo"); tb.add("geom", Point.class); tb.add("name", String.class); SimpleFeatureType featureType = tb.buildFeatureType(); delegate = new DefaultFeatureCollection(null, featureType); SimpleFeatureBuilder b = new SimpleFeatureBuilder(featureType); for (int i = 0; i < 10; i++) { b.add(new GeometryFactory().createPoint(new Coordinate(i, i))); b.add(String.valueOf(i)); delegate.add(b.buildFeature("fid." + i)); } }