public void setID(String id) { ((FeatureIdImpl) fid).setID(id); }
/** * Sets the FID, used by datastores only. * * <p>I would love to protect this for safety reason, i.e. so client classes can't use it by * casting to it. * * @param id The fid to set. */ public void setID(String fid) { ((FeatureIdImpl) id).setID(fid); } }
/** Used to update any FeatureId during a commit. */ public void replaceFid(String tempFid, String actualFid) { for (Identifier id : fids) { if (tempFid.equals(id.getID())) { // we have a match! if (id instanceof FeatureIdImpl) { FeatureIdImpl featureId = (FeatureIdImpl) id; // update internal structure! featureId.setID(actualFid); } } } }
cur.getUserData().get(ContentFeatureStore.ORIGINAL_FEATURE_KEY); if (orig != null) { ((FeatureIdImpl) orig.getIdentifier()).setID(fid); orig.getUserData().putAll(cur.getUserData()); orig.getUserData().remove(ContentFeatureStore.ORIGINAL_FEATURE_KEY);
Boolean.TRUE.equals(feature.getUserData().get(Hints.USE_PROVIDED_FID)); if (getQueryCapabilities().isUseProvidedFIDSupported() && useExisting) { ((FeatureIdImpl) toWrite.getIdentifier()).setID(feature.getID());
/** * Sets the FID, used by datastores only. * * I would love to protect this for safety reason, i.e. so client classes can't use it by * casting to it. * * @param id * The fid to set. */ public void setID(String fid) { ((FeatureIdImpl) id).setID(fid); } }
public void setID( String id ) { ((FeatureIdImpl)fid).setID(id); }
public void setID( String id ) { ((FeatureIdImpl)fid).setID(id); }
/** * Used to update any FeatureId during a commit. */ public void replaceFid(String tempFid, String actualFid) { for (Identifier id : fids) { if (tempFid.equals(id.getID())) { // we have a match! if (id instanceof FeatureIdImpl) { FeatureIdImpl featureId = (FeatureIdImpl) id; // update internal structure! featureId.setID(actualFid); } } } }
public void execute(Tuple tuple) { final String[] attributes = tuple.getValue(0).toString().split(","); // Only ingest attributes that have a latitude and longitude if (attributes.length == 2 && attributes[LATITUDE_COL_IDX] != null && attributes[LONGITUDE_COL_IDX] != null) { featureBuilder.reset(); final SimpleFeature simpleFeature = featureBuilder.buildFeature(String.valueOf(UUID.randomUUID().getMostSignificantBits())); simpleFeature.setDefaultGeometry(getGeometry(attributes)); try { final SimpleFeature next = featureWriter.next(); for (int i = 0; i < simpleFeature.getAttributeCount(); i++) { next.setAttribute(i, simpleFeature.getAttribute(i)); } ((FeatureIdImpl)next.getIdentifier()).setID(simpleFeature.getID()); featureWriter.write(); } catch (IOException e) { log.error("Exception writing feature", e); } } }
public void writeFeatures(DataStore datastore, SimpleFeatureType sft, List<SimpleFeature> features) throws IOException { if (features.size() > 0) { System.out.println("Writing test data"); // use try-with-resources to ensure the writer is closed try (FeatureWriter<SimpleFeatureType, SimpleFeature> writer = datastore.getFeatureWriterAppend(sft.getTypeName(), Transaction.AUTO_COMMIT)) { for (SimpleFeature feature : features) { // using a geotools writer, you have to get a feature, modify it, then commit it // appending writers will always return 'false' for haveNext, so we don't need to bother checking SimpleFeature toWrite = writer.next(); // copy attributes toWrite.setAttributes(feature.getAttributes()); // if you want to set the feature ID, you have to cast to an implementation class // and add the USE_PROVIDED_FID hint to the user data ((FeatureIdImpl) toWrite.getIdentifier()).setID(feature.getID()); toWrite.getUserData().put(Hints.USE_PROVIDED_FID, Boolean.TRUE); // alternatively, you can use the PROVIDED_FID hint directly // toWrite.getUserData().put(Hints.PROVIDED_FID, feature.getID()); // if no feature ID is set, a UUID will be generated for you // make sure to copy the user data, if there is any toWrite.getUserData().putAll(feature.getUserData()); // write the feature writer.write(); } } System.out.println("Wrote " + features.size() + " features"); System.out.println(); } }
public void write() throws IOException { if (live == null) throw new IOException("No current feature to write"); // this will return true only in update mode, otherwise original is null boolean changed = !live.equals(original); if (!changed && original != null) { // nothing to do, just skip } else if (original != null) { // not equals, we're updating an existing one Object ogrFeature = mapper.convertGTFeature(layerDefinition, live); ogr.CheckError(ogr.LayerSetFeature(layer, ogrFeature)); } else { Object ogrFeature = mapper.convertGTFeature(layerDefinition, live); ogr.CheckError(ogr.LayerCreateFeature(layer, ogrFeature)); String geotoolsId = mapper.convertOGRFID(featureType, ogrFeature); ((FeatureIdImpl) live.getIdentifier()).setID(geotoolsId); ogr.FeatureDestroy(ogrFeature); } // reset state live = null; original = null; } }
((FeatureIdImpl) toWrite.getIdentifier()).setID(feature.getID()); ids.add(feature.getID());
((FeatureIdImpl) newFeature.getIdentifier()).setID(feature.getID());
((FeatureIdImpl) toWrite.getIdentifier()).setID(feature.getID());
FeatureId identifier = r.get(i); if( identifier instanceof FeatureIdImpl){ ((FeatureIdImpl)identifier).setID( fid );
((FeatureIdImpl) newFeature.getIdentifier()).setID(feature.getID());