public void visit(org.opengis.feature.Feature feature) { bounds.include(feature.getBounds()); }
@Override public Object evaluate(Object object) { if (!(object instanceof Feature)) { return null; } Feature feature = (Feature) object; ReferencedEnvelope env = ReferencedEnvelope.reference(feature.getBounds()); if (env != null) { return JTS.toGeometry(env); } else { return null; } } }
public void fireFeatureRemoved(FeatureSource<?, ?> source, Feature feature) { if (listeners.isEmpty() && tx != Transaction.AUTO_COMMIT) return; Filter filter = idFilter(feature); ReferencedEnvelope bounds = ReferencedEnvelope.reference(feature.getBounds()); FeatureEvent event = new FeatureEvent(source, Type.REMOVED, bounds, filter); fireFeatureEvent(event); }
/** * Used to issue a Type.ADDED FeatureEvent indicating a new feature being created * * @param source * @param feature */ public final void fireFeatureAdded(FeatureSource<?, ?> source, Feature feature) { if (listeners.isEmpty() && tx != Transaction.AUTO_COMMIT) return; Filter filter = idFilter(feature); ReferencedEnvelope bounds = ReferencedEnvelope.reference(feature.getBounds()); FeatureEvent event = new FeatureEvent(source, Type.ADDED, bounds, filter); fireFeatureEvent(event); }
/** * Creates a FeatureEvent indicating that the provided feature has been changed. * * <p>This method is provided to simplify event notification for implementors by constructing a * FeatureEvent internally (and then only if listeners are interested). You may find it easier * to construct your own FeatureEvent using {{@link #hasListener()} to check if you need to fire * events at all. * * @param source FeatureSource responsible for the change * @param feature The updated feature * @param before the bounds of the feature before the change */ public void fireFeatureUpdated( FeatureSource<?, ?> source, Feature feature, ReferencedEnvelope before) { if (feature == null) { return; // nothing changed } if (listeners.isEmpty() && tx != Transaction.AUTO_COMMIT) return; // nobody is listenting Filter filter = idFilter(feature); ReferencedEnvelope bounds = ReferencedEnvelope.reference(feature.getBounds()); if (bounds != null) { bounds.expandToInclude(before); } FeatureEvent event = new FeatureEvent(source, Type.CHANGED, bounds, filter); fireFeatureEvent(event); }
/** * Full collection traversal to obtain bounds of FeatureCollection. Subclasees are strong * encouraged to override this expensive method (even if just to implement caching). */ public ReferencedEnvelope getBounds() { ReferencedEnvelope bounds = null; FeatureIterator<F> it = features(); try { while (it.hasNext()) { Feature feature = it.next(); BoundingBox bbox = feature.getBounds(); if (bbox != null) { if (bounds == null) { bounds = new ReferencedEnvelope(bbox); } else { bounds.include(bbox); } } } } finally { it.close(); } return bounds; } }
/** * Return gml:boundedBy property if wanted. * * @param feature feature for which bounds might be required * @param configuration encoder configuration, used to suppress feature bounds * @return the feature bounds, or null if none or unwanted */ private BoundingBox getBoundedBy(Feature feature, Configuration configuration) { // check for flag not to include bounds if (configuration.hasProperty(GMLConfiguration.NO_FEATURE_BOUNDS)) { return null; } else { BoundingBox bounds = feature.getBounds(); // do a check for the case where the feature has no geometry properties if (bounds.isEmpty() && (feature.getDefaultGeometryProperty() == null || feature.getDefaultGeometryProperty().getValue() == null)) { return null; } else { return bounds; } } }
if (feature == null) continue; BoundingBox geomBounds = feature.getBounds();
@SuppressWarnings("unchecked") private ReferencedEnvelope getBounds(FeatureSource source) { try { ReferencedEnvelope boundingBox = new ReferencedEnvelope(DefaultGeographicCRS.WGS84); FeatureCollection features = source.getFeatures(); FeatureIterator iterator = features.features(); try { while (iterator.hasNext()) { Feature f = iterator.next(); boundingBox.include(f.getBounds()); } } finally { iterator.close(); } return boundingBox; } catch (IOException e) { throw new RuntimeException(e); } }
private void fillCache(Query query) throws IOException { Query cloned = new DefaultQuery(query); cloned.getHints().remove(Hints.GEOMETRY_DISTANCE); FeatureCollection features = wrapped.getFeatures(cloned); FeatureIterator fi = features.features(); index = null; STRtree newIndex = new STRtree(); while (fi.hasNext()) { // consider turning all geometries into packed ones, to save space Feature f = fi.next(); newIndex.insert(ReferencedEnvelope.reference(f.getBounds()), f); } fi.close(); index = newIndex; cachedQuery = query; cachedBounds = getEnvelope(query.getFilter()); dirty = false; }
public void visit(org.opengis.feature.Feature feature) { bounds.include( feature.getBounds() ); }
public void fireFeatureRemoved(FeatureSource<?, ?> source, Feature feature) { if (listeners.isEmpty() && tx != Transaction.AUTO_COMMIT) return; Filter filter = idFilter(feature); ReferencedEnvelope bounds = new ReferencedEnvelope(feature.getBounds()); FeatureEvent event = new FeatureEvent(source, Type.REMOVED, bounds, filter); fireFeatureEvent(event); }
/** Calculate bounds from features */ private ReferencedEnvelope calculateBounds() { ReferencedEnvelope extent = new ReferencedEnvelope(); for (Feature feature : list) { if (feature == null) continue; ReferencedEnvelope bbox = ReferencedEnvelope.reference(feature.getBounds()); if (bbox == null || bbox.isEmpty() || bbox.isNull()) continue; extent.expandToInclude(bbox); } return new ReferencedEnvelope(extent, schema.getCoordinateReferenceSystem()); }
/** Calculate bounds from features */ private ReferencedEnvelope calculateBounds() { ReferencedEnvelope extent = new ReferencedEnvelope(); for (Feature feature : list) { if (feature == null) continue; ReferencedEnvelope bbox = ReferencedEnvelope.reference(feature.getBounds()); if (bbox == null || bbox.isEmpty() || bbox.isNull()) continue; extent.expandToInclude(bbox); } return new ReferencedEnvelope(extent, schema.getCoordinateReferenceSystem()); }
public Node put(final ObjectId revFeatureId, final Feature feature) { final RevTreeBuilder treeBuilder = getTreeBuilder(feature); String fid = feature.getIdentifier().getID(); // System.err.printf("%s -> %s\n", fid, treeBuilder); BoundingBox bounds = feature.getBounds(); FeatureType type = feature.getType(); final Node node = createFeatureNode(revFeatureId, fid, bounds, type); treeBuilder.put(node); return node; }
public Node put(final ObjectId revFeatureId, final Feature feature) { final RevTreeBuilder treeBuilder = getTreeBuilder(feature); String fid = feature.getIdentifier().getID(); // System.err.printf("%s -> %s\n", fid, treeBuilder); BoundingBox bounds = feature.getBounds(); FeatureType type = feature.getType(); final Node node = createFeatureNode(revFeatureId, fid, bounds, type); treeBuilder.put(node); return node; }
private Node feature(ObjectStore db, String idPrefix, int index) { final String id = idPrefix + "." + index; final Feature feature; feature = super.feature(pointsType, id, id, index, point(index)); RevFeature revFeature = RevFeatureBuilder.build(feature); db.put(revFeature); Envelope bounds = (Envelope) feature.getBounds(); return Node.create(id, revFeature.getId(), ObjectId.NULL, TYPE.FEATURE, bounds); }
private Node feature(ObjectStore db, String idPrefix, int index) { final String id = idPrefix + "." + index; final Feature feature; feature = super.feature(pointsType, id, id, index, point(index)); RevFeature revFeature = RevFeature.builder().build(feature); db.put(revFeature); Envelope bounds = (Envelope) feature.getBounds(); return RevObjectFactory.defaultInstance().createNode(id, revFeature.getId(), ObjectId.NULL, TYPE.FEATURE, bounds, null); }