Search in sources :

Example 1 with AdaptorFeatureCollection

use of org.geotools.feature.collection.AdaptorFeatureCollection in project polymap4-core by Polymap4.

the class DataSourceProcessor method addFeaturesRequest.

@Override
public void addFeaturesRequest(AddFeaturesRequest request, ProcessorContext context) throws Exception {
    Collection<Feature> features = request.getFeatures();
    log.debug("addFeatures(): Features: " + features.size());
    FeatureCollection fc = new AdaptorFeatureCollection("features", (SimpleFeatureType) fs.getSchema()) {

        @Override
        protected void closeIterator(Iterator it) {
        }

        @Override
        protected Iterator openIterator() {
            return features.iterator();
        }

        @Override
        public int size() {
            return features.size();
        }
    };
    List<FeatureId> result = ((FeatureStore) fs).addFeatures(fc);
    context.sendResponse(new ModifyFeaturesResponse(new FidSet(result)));
    context.sendResponse(ProcessorResponse.EOP);
}
Also used : FeatureId(org.opengis.filter.identity.FeatureId) FeatureCollection(org.geotools.feature.FeatureCollection) AdaptorFeatureCollection(org.geotools.feature.collection.AdaptorFeatureCollection) AdaptorFeatureCollection(org.geotools.feature.collection.AdaptorFeatureCollection) FeatureIterator(org.geotools.feature.FeatureIterator) Iterator(java.util.Iterator) Feature(org.opengis.feature.Feature) FeatureStore(org.geotools.data.FeatureStore)

Aggregations

Iterator (java.util.Iterator)1 FeatureStore (org.geotools.data.FeatureStore)1 FeatureCollection (org.geotools.feature.FeatureCollection)1 FeatureIterator (org.geotools.feature.FeatureIterator)1 AdaptorFeatureCollection (org.geotools.feature.collection.AdaptorFeatureCollection)1 Feature (org.opengis.feature.Feature)1 FeatureId (org.opengis.filter.identity.FeatureId)1