/** * 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); }
protected SimpleFeatureCollection newCollection( SimpleFeatureType schema, List<SimpleFeature> list) { DefaultFeatureCollection features = new DefaultFeatureCollection(); features.addAll(list); return features; } }
public SimpleFeatureCollection collection() throws IOException { DefaultFeatureCollection copy = new DefaultFeatureCollection(null, getSchema()); List<SimpleFeature> list = new ArrayList<SimpleFeature>(contents.size()); SimpleFeatureIterator iterator = features(); try { while (iterator.hasNext()) { SimpleFeature feature = iterator.next(); SimpleFeature duplicate; try { duplicate = SimpleFeatureBuilder.copy(feature); } catch (IllegalAttributeException e) { throw new DataSourceException("Unable to copy " + feature.getID(), e); } list.add(duplicate); } } finally { iterator.close(); } copy.addAll(list); return copy; }
protected void setUp() throws Exception { type = DataUtilities.createType("TestType", "geom:Geometry"); features = new SimpleFeature[] { SimpleFeatureBuilder.build(type, new Object[] {null}, "f1"), SimpleFeatureBuilder.build(type, new Object[] {null}, "f2"), SimpleFeatureBuilder.build(type, new Object[] {null}, "f3"), SimpleFeatureBuilder.build(type, new Object[] {null}, "f4"), SimpleFeatureBuilder.build(type, new Object[] {null}, "f5"), SimpleFeatureBuilder.build(type, new Object[] {null}, "f6") }; DefaultFeatureCollection collection = new DefaultFeatureCollection(); List<SimpleFeature> list = Arrays.asList(features); collection.addAll(list); arrayReader = new CollectionFeatureReader(features); collectionReader = new CollectionFeatureReader(list, type); featureCollectionReader = new CollectionFeatureReader((SimpleFeatureCollection) collection, type); }
/** * This constructor should not be used by client code. * @param collection SimpleFeatureCollection to copy into memory */ public DefaultFeatureCollection( FeatureCollection<SimpleFeatureType,SimpleFeature> collection ) { this( collection.getID(), collection.getSchema() ); addAll(collection); }
@Override public void redo() throws CannotRedoException { super.redo(); vectorDataNode.getFeatureCollection().addAll(simpleFeatures); } });
@Override public void undo() throws CannotUndoException { super.undo(); vectorDataNode.getFeatureCollection().addAll(simpleFeatures); }
public static VectorDataNode parse(String maskName, Path inputFile) { VectorDataNode node = null; try (InputStream inputStream = Files.newInputStream(inputFile)) { SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); Handler handler = new Handler(); parser.parse(inputStream, handler); List<SimpleFeature> polygonFeatures = handler.getResult(); DefaultFeatureCollection featureCollection = new DefaultFeatureCollection("VectorMasks", featureType); featureCollection.addAll(polygonFeatures); /*for (int i = 0; i < polygonFeatures.size(); i++) { SimpleFeature feature = new SimpleFeatureImpl(new Object[]{ polygonFeatures.get(i), String.format("Polygon-%s", i)}, featureType, new FeatureIdImpl(String.format("F-%s", i)), true); featureCollection.add(feature); }*/ node = new VectorDataNode(maskName, featureCollection); } catch (Exception e) { systemLogger.warning(e.getMessage()); } return node; }
public static void writeGeometries(final Collection<SimpleFeature> features, final String filename) { if (features.isEmpty()) { throw new UncheckedIOException("Cannot write empty collection"); } log.info("Writing shapefile to " + filename); try { URL fileURL = (new File(filename)).toURI().toURL(); ShapefileDataStore datastore = new ShapefileDataStore(fileURL); SimpleFeature feature = features.iterator().next(); datastore.createSchema(feature.getFeatureType()); DefaultFeatureCollection coll = new DefaultFeatureCollection(); coll.addAll(features); SimpleFeatureType featureType = features.iterator().next().getFeatureType(); datastore.createSchema(featureType); SimpleFeatureStore featureSource = (SimpleFeatureStore) datastore.getFeatureSource(); featureSource.addFeatures(coll); } catch (IOException e) { throw new RuntimeException(e); } } }
"The geometry is not contained in the product."); } else { vectorDataLayer.getVectorDataNode().getFeatureCollection().addAll(productFeatures);
@Override public void insertFigures(boolean performInsert, Figure... figures) { Debug.trace("VectorDataFigureEditor.insertFigures " + performInsert + ", " + figures.length); if (vectorDataNode != null) { List<SimpleFeature> simpleFeatures = toSimpleFeatureList(figures); vectorDataNode.getFeatureCollection().addAll(simpleFeatures); getUndoContext().postEdit(new FigureInsertEdit(this, performInsert, figures) { @Override public void undo() throws CannotUndoException { super.undo(); vectorDataNode.getFeatureCollection().removeAll(simpleFeatures); } @Override public void redo() throws CannotRedoException { super.redo(); vectorDataNode.getFeatureCollection().addAll(simpleFeatures); } }); } else { // warn super.insertFigures(performInsert, figures); } }
targetVectorDataNode.getFeatureCollection().addAll((FeatureCollection<?, ?>) targetCollection); targetVectorDataNode.setDefaultStyleCss(sourceVectorDataNode.getDefaultStyleCss()); targetVectorDataNode.setDescription(sourceVectorDataNode.getDescription());