return storeDelegate.addFeatures(collection); } else { return storeDelegate.addFeatures(collection); } else { if (collection.getSchema() instanceof SimpleFeatureType + "the attributes one cannot write off complex features. " + "However at this time there is no writable complex feature!"); return storeDelegate.addFeatures(collection);
public List<FeatureId> addFeatures( FeatureCollection<SimpleFeatureType, SimpleFeature> collection) throws IOException { return delegate().addFeatures(collection); }
public Set addFeatures(FeatureCollection collection) throws IOException { return wrappedStore.addFeatures(collection); }
public List<FeatureId> addFeatures( FeatureCollection<SimpleFeatureType, SimpleFeature> collection) throws IOException { return fstore.addFeatures(collection); }
public List<FeatureId> addFeatures( FeatureCollection<SimpleFeatureType, SimpleFeature> collection) throws IOException { return delegate().addFeatures(collection); }
public void testWrite() throws Exception { FeatureStore<SimpleFeatureType, SimpleFeature> fs = (FeatureStore<SimpleFeatureType, SimpleFeature>) dataStore.getFeatureSource(tname(TESTLOB)); SimpleFeature sf = SimpleFeatureBuilder.build( lobSchema, new Object[] {new byte[] {6, 7, 8}, "newclob", new byte[] {11, 12, 13}}, null); List<FeatureId> fids = fs.addFeatures(DataUtilities.collection(sf)); Filter filter = ff.id(new HashSet<Identifier>(fids)); try (FeatureIterator<SimpleFeature> fi = fs.getFeatures(filter).features()) { assertTrue(fi.hasNext()); SimpleFeature f = fi.next(); assertTrue( Arrays.equals( new byte[] {6, 7, 8}, (byte[]) f.getAttribute(aname(BLOB_FIELD)))); assertTrue( Arrays.equals( new byte[] {11, 12, 13}, (byte[]) f.getAttribute(aname(RAW_FIELD)))); assertEquals("newclob", f.getAttribute(aname(CLOB_FIELD))); } }
@PutMapping( path = "{product:.+}/granules", produces = {MediaType.APPLICATION_JSON_VALUE} ) public void putProductGranules( @PathVariable(name = "collection", required = true) String collection, @PathVariable(name = "product", required = true) String product, @RequestBody SimpleFeatureCollection granules) throws IOException { SimpleFeatureStore store = (SimpleFeatureStore) getOpenSearchAccess().getGranules(collection, product); runTransactionOnStore( store, s -> { s.removeFeatures(Filter.INCLUDE); s.addFeatures(granules); }); }
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<String> postProductJson( @PathVariable(name = "collection", required = true) String collection, HttpServletRequest request, @RequestBody(required = true) SimpleFeature feature) throws IOException, URISyntaxException { String productId = (String) feature.getAttribute("eop:identifier"); Feature productFeature = simpleToComplex(feature, getProductSchema(), PRODUCT_HREFS); // insert the new feature runTransactionOnProductStore(fs -> fs.addFeatures(singleton(productFeature))); return returnCreatedProductReference(collection, request, productId); }
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<String> postCollectionJson( HttpServletRequest request, @RequestBody(required = true) SimpleFeature feature) throws IOException, URISyntaxException { String eoId = checkCollectionIdentifier(feature); Feature collectionFeature = simpleToComplex(feature, getCollectionSchema(), COLLECTION_HREFS); // insert the new feature runTransactionOnCollectionStore(fs -> fs.addFeatures(singleton(collectionFeature))); // if got here, all is fine return returnCreatedCollectionReference(request, eoId); }
static void write(List<SimpleFeature> features, File file) throws IOException { String basename = file.getName(); if (basename.endsWith(FILE_EXTENSION_SHAPEFILE)) { basename = basename.substring(0, basename.length() - 4); } File shapefile = new File(file.getParentFile(), basename + FILE_EXTENSION_SHAPEFILE); ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory(); Map map = Collections.singletonMap("url", shapefile.toURI().toURL()); DataStore dataStore = factory.createNewDataStore(map); SimpleFeature simpleFeature = features.get(0); SimpleFeatureType simpleFeatureType = simpleFeature.getType(); final String typeName = simpleFeatureType.getName().getLocalPart(); dataStore.createSchema(simpleFeatureType); FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) dataStore.getFeatureSource(typeName); DefaultTransaction transaction = new DefaultTransaction("X"); featureStore.setTransaction(transaction); final FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection = DataUtilities.collection(features); featureStore.addFeatures(featureCollection); try { transaction.commit(); } catch (Exception e) { transaction.rollback(); throw new IOException("Cannot write shapefile. Error:\n" + e.getMessage(), e); } finally { dataStore.dispose(); transaction.close(); } } }
final FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection = DataUtilities.collection( features); featureStore.addFeatures(featureCollection); try { transaction.commit();
public void testGetFeatureStoreAddFeatures() throws IOException { FeatureReader reader = DataUtilities.reader(new Feature[] { newRoad, }); FeatureStore road = (FeatureStore) data.getFeatureSource("ROAD"); road.addFeatures( DataUtilities.collection(reader)); assertEquals(roadFeatures.length + 1, road.getFeatures().size()); }
protected void addFeature( int id, Date time, Double elevation, Date referenceTime, Double scanningAngle) throws IOException { FeatureTypeInfo timeElevationCustom = getCatalog().getFeatureTypeByName(TIME_ELEVATION_CUSTOM.getLocalPart()); FeatureStore fs = (FeatureStore) timeElevationCustom.getFeatureSource(null, null); SimpleFeatureType type = (SimpleFeatureType) timeElevationCustom.getFeatureType(); MemoryFeatureCollection coll = new MemoryFeatureCollection(type); StringBuffer content = new StringBuffer(); content.append(id); content.append('|'); content.append(time.toString()); content.append('|'); content.append(elevation); content.append('|'); content.append(referenceTime.toString()); content.append('|'); content.append(scanningAngle); SimpleFeature f = DataUtilities.createFeature(type, content.toString()); coll.add(f); org.geotools.data.Transaction tx = fs.getTransaction(); fs.addFeatures(coll); tx.commit(); }
protected void addFeature(int id, Date time, Double elevation) throws IOException { FeatureTypeInfo timeWithStartEnd = getCatalog().getFeatureTypeByName(TIME_WITH_START_END.getLocalPart()); FeatureStore fs = (FeatureStore) timeWithStartEnd.getFeatureSource(null, null); SimpleFeatureType type = (SimpleFeatureType) timeWithStartEnd.getFeatureType(); MemoryFeatureCollection coll = new MemoryFeatureCollection(type); StringBuffer content = new StringBuffer(); content.append(id); content.append('|'); content.append(time.toString()); content.append("||"); content.append(elevation); content.append('|'); SimpleFeature f = DataUtilities.createFeature(type, content.toString()); coll.add(f); org.geotools.data.Transaction tx = fs.getTransaction(); fs.addFeatures(coll); tx.commit(); }
protected void addFeature(int id, Date time, Double elevation) throws IOException { FeatureTypeInfo timeWithStartEnd = getCatalog().getFeatureTypeByName(ELEVATION_WITH_START_END.getLocalPart()); FeatureStore fs = (FeatureStore) timeWithStartEnd.getFeatureSource(null, null); SimpleFeatureType type = (SimpleFeatureType) timeWithStartEnd.getFeatureType(); MemoryFeatureCollection coll = new MemoryFeatureCollection(type); StringBuffer content = new StringBuffer(); content.append(id); content.append('|'); content.append(time.toString()); content.append("||"); content.append(elevation); content.append('|'); SimpleFeature f = DataUtilities.createFeature(type, content.toString()); coll.add(f); org.geotools.data.Transaction tx = fs.getTransaction(); fs.addFeatures(coll); tx.commit(); }
roads.addFeatures(DataUtilities.collection(roadFeatures)); rivers.addFeatures(DataUtilities.collection(riverFeatures));
void addFeature(FeatureStore store, String wkt, Object... atts) throws Exception { SimpleFeatureBuilder b = new SimpleFeatureBuilder((SimpleFeatureType) store.getSchema()); b.add(new WKTReader().read(wkt)); for (Object att : atts) { b.add(att); } DefaultFeatureCollection features = new DefaultFeatureCollection(null, null); features.add(b.buildFeature(null)); store.addFeatures(features); }
void addFeature(FeatureStore store, String wkt, Object... atts) throws Exception { SimpleFeatureBuilder b = new SimpleFeatureBuilder((SimpleFeatureType) store.getSchema()); b.add(new WKTReader().read(wkt)); for (Object att : atts) { b.add(att); } DefaultFeatureCollection features = new DefaultFeatureCollection(null, null); features.add(b.buildFeature(null)); store.addFeatures(features); }
fs.addFeatures(fs1.getFeatures()); FeatureTypeInfo ft = cb.buildFeatureType(fs); cat.add(ft); fs.addFeatures(fs2.getFeatures()); ft = cb.buildFeatureType(fs); cat.add(ft);
void addFeatures(FeatureStore fs, FeatureCollection features) throws Exception { SimpleFeatureBuilder b = new SimpleFeatureBuilder((SimpleFeatureType) fs.getSchema()); DefaultFeatureCollection toAdd = new DefaultFeatureCollection(null, null); FeatureIterator it = features.features(); try { SimpleFeature f = null; int i = 0; while (it.hasNext()) { f = (SimpleFeature) it.next(); b.init(f); b.add(f.getAttribute("pointProperty")); b.add(i++); toAdd.add(b.buildFeature(null)); } } finally { it.close(); } fs.addFeatures(toAdd); }