/** * Get the union. * * @param r the other geometry * @return the union of this geometry envelope and another geometry envelope */ public Value getEnvelopeUnion(ValueGeometry r) { GeometryFactory gf = new GeometryFactory(); Envelope mergedEnvelope = new Envelope(getGeometryNoCopy().getEnvelopeInternal()); mergedEnvelope.expandToInclude(r.getGeometryNoCopy().getEnvelopeInternal()); return get(gf.toGeometry(mergedEnvelope)); }
/** * Include the provided coordinates, expanding as necessary. * * @since 2.4 */ public void include(double x, double y) { super.expandToInclude(x, y); }
public Envelope expandEnvelope(Envelope env) { double minx = coords[0]; double maxx = minx; double miny = coords[1]; double maxy = miny; for (int i = 0; i < coords.length; i += dimension) { double x = coords[i]; if (x < minx) minx = x; else if (x > maxx) maxx = x; double y = coords[i + 1]; if (y < miny) miny = y; else if (y > maxy) maxy = y; } env.expandToInclude(minx, miny); env.expandToInclude(maxx, maxy); return env; }
Envelope envelopeFrom(CircularArc arc, double... otherPoints) { Envelope env = new Envelope(); // add the control points env.expandToInclude(arc.controlPoints[0], arc.controlPoints[1]); env.expandToInclude(arc.controlPoints[2], arc.controlPoints[3]); env.expandToInclude(arc.controlPoints[4], arc.controlPoints[5]); if (otherPoints != null) { // add the other points for (int i = 0; i < otherPoints.length; ) { env.expandToInclude(otherPoints[i++], otherPoints[i++]); } } return env; }
/** * Sets a corner. * * @param c the coordinate of the corner. */ public void addCoordinate(Coordinate c) { LOGGER.entering("SubHandlerBox", "addCoordinate", c); e.expandToInclude(c); LOGGER.exiting("SubHandlerBox", "addCoordinate"); }
@Override protected Envelope computeEnvelopeInternal() { final Envelope result = new Envelope(); for (LineString ls : components) { result.expandToInclude(ls.getEnvelopeInternal()); } return result; }
public GeometryDataset(Geometry... geometries) { this.geometries = Arrays.asList(geometries); this.bounds = new Envelope(); for (Geometry g : geometries) { bounds.expandToInclude(g.getEnvelopeInternal()); } setBuffer(0.1d); }
@Override public Object visit(Or filter, Object data) { Envelope mixed = new Envelope(); for (Filter f : filter.getChildren()) { Envelope env = (Envelope) f.accept(this, data); mixed.expandToInclude(env); } return mixed; }
/** * @todo change GeometryFactory * @param pt * @param weightClusterPosition */ public void add(Coordinate pt, boolean weightClusterPosition) { count++; /** * Only create set if this is the second point seen (and assum the first pt is in * location) */ if (uniquePts == null) { uniquePts = new HashSet<Coordinate>(); } uniquePts.add(pt); if (weightClusterPosition) { pickWeightedLocation(pt); } else { pickNearestLocation(pt); } if (boundingBox == null) { boundingBox = new Envelope(); } else { boundingBox.expandToInclude(pt); } // pickCenterLocation(pt); }
@Override protected Envelope getExtent(ImageLevelInfo li, Connection con) throws SQLException, IOException { String extentSelect = getExtentSelectStatment(li); String statementString = MessageFormat.format(extentSelect, new Object[] {li.getSpatialTableName()}); Envelope extent = null; PreparedStatement s = con.prepareStatement(statementString); ResultSet r = s.executeQuery(); WKBReader reader = new WKBReader(); while (r.next()) { byte[] bytes = r.getBytes(1); Geometry g; try { g = reader.read(bytes); } catch (ParseException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); throw new IOException(e); } if (extent == null) { extent = g.getEnvelopeInternal(); } else { extent.expandToInclude(g.getEnvelopeInternal()); } } r.close(); s.close(); return extent; }
Envelope getEnvelope(Filter filter) { Envelope result = originalBounds; if (filter instanceof And) { Envelope bounds = new Envelope(); for (Iterator iter = ((And) filter).getChildren().iterator(); iter.hasNext(); ) { Filter f = (Filter) iter.next(); Envelope e = getEnvelope(f); if (e == null) return null; else bounds.expandToInclude(e); } result = bounds; } else if (filter instanceof BinarySpatialOperator) { BinarySpatialOperator gf = (BinarySpatialOperator) filter; if (supportedFilterTypes.contains(gf.getClass())) { Expression lg = gf.getExpression1(); Expression rg = gf.getExpression2(); if (lg instanceof Literal) { Geometry g = (Geometry) ((Literal) lg).getValue(); if (rg instanceof PropertyName) result = g.getEnvelopeInternal(); } else if (rg instanceof Literal) { Geometry g = (Geometry) ((Literal) rg).getValue(); if (lg instanceof PropertyName) result = g.getEnvelopeInternal(); } } } return result.intersection(originalBounds); }
return null; } else { bounds.expandToInclude(e);
/** * This method computes reprojected bounds the hard way, but computing them feature by feature. * This method could be faster if computed the reprojected bounds by reprojecting the original * feature bounds a Shape object, thus getting the true shape of the reprojected envelope, and * then computing the minimum and maximum coordinates of that new shape. The result would not a * true representation of the new bounds. * * @see org.geotools.data.FeatureResults#getBounds() */ public ReferencedEnvelope getBounds() { SimpleFeatureIterator r = features(); try { Envelope newBBox = new Envelope(); Envelope internal; SimpleFeature feature; while (r.hasNext()) { feature = r.next(); final Geometry geom = ((Geometry) feature.getDefaultGeometry()); if (geom != null) { internal = geom.getEnvelopeInternal(); newBBox.expandToInclude(internal); } } return new ReferencedEnvelope(newBBox, target); } catch (Exception e) { throw new RuntimeException("Exception occurred while computing reprojected bounds", e); } finally { r.close(); } }
/** Include the provided envelope, expanding as necessary. */ @Override public void expandToInclude(Envelope other) { if (other instanceof BoundingBox) { if (other.isNull()) { return; } BoundingBox bbox = (BoundingBox) other; ensureCompatibleReferenceSystem(bbox); expandToInclude(bbox.getLowerCorner()); expandToInclude(bbox.getUpperCorner()); } else { super.expandToInclude(other); } }
public BoundingBox getBounds() { // TODO: cache this value CoordinateReferenceSystem crs = featureType.getCoordinateReferenceSystem(); Envelope bounds = ReferencedEnvelope.create(crs); for (Object o : values) { if (o instanceof Geometry) { Geometry g = (Geometry) o; // TODO: check userData for crs... and ensure its of the same // crs as the feature type if (bounds.isNull()) { bounds.init(JTS.bounds(g, crs)); } else { bounds.expandToInclude(JTS.bounds(g, crs)); } } } return (BoundingBox) bounds; }
bounds.expandToInclude(env[0], env[1]); bounds.expandToInclude(env[2], env[3]);
if (geometry != null) { internal = geometry.getEnvelopeInternal(); newBBox.expandToInclude(internal);
/** * Stolen from {@link ReprojectFeatureResults}. * * @see org.geotools.feature.FeatureCollection#getBounds() */ public ReferencedEnvelope getBounds() { FeatureIterator<Feature> features = features(); try { Envelope newBBox = new Envelope(); Envelope internal; Feature feature; while (features.hasNext()) { feature = features.next(); final Geometry geometry = feature.getDefaultGeometryProperty() != null ? ((Geometry) feature.getDefaultGeometryProperty().getValue()) : null; if (geometry != null) { internal = geometry.getEnvelopeInternal(); newBBox.expandToInclude(internal); } } return ReferencedEnvelope.reference(newBBox); } catch (Exception e) { throw new RuntimeException("Exception occurred while computing bounds", e); } finally { features.close(); } }
Envelope envelope = curve.getEnvelopeInternal(); if (offsetCurve != null) { envelope.expandToInclude(offsetCurve.getEnvelopeInternal());
public IndexedFeatureResults(SimpleFeatureCollection results) throws IOException, IllegalAttributeException { // copy results attributes super(null, results.getSchema()); // load features into the index SimpleFeatureIterator reader = null; bounds = new Envelope(); count = 0; try { reader = results.features(); SimpleFeature f; Envelope env; while (reader.hasNext()) { f = reader.next(); env = ((Geometry) f.getDefaultGeometry()).getEnvelopeInternal(); bounds.expandToInclude(env); count++; index.insert(env, f); } } finally { if (reader != null) reader.close(); } }