/** * Enlarges this <code>Envelope</code> so that it contains the given {@link Coordinate}. Has no * effect if the point is already on or within the envelope. * * @param p the Coordinate to expand to include */ public void expandToInclude(Coordinate p) { expandToInclude(p.x, p.y, p.z); }
/** Include the provided coordinates, expanding as necessary. */ public void include(double x, double y, double z) { expandToInclude(x, y, z); }
/** * Enlarges this <code>Envelope</code> so that it contains the given point. Has no effect if the * point is already on or within the envelope. * * @param x the value to lower the minimum x to or to raise the maximum x to * @param y the value to lower the minimum y to or to raise the maximum y to * @param z the value to lower the minimum z to or to raise the maximum z to */ public void expandToInclude(double x, double y, double z) { if (isNull()) { expandToInclude(x, y); minz = z; maxz = z; } else { expandToInclude(x, y); if (z < minz) { minz = z; } if (z > maxz) { maxz = z; } } }
/** Include the provided bounding box, expanding as necessary. */ public void include(final BoundingBox3D bbox) { if (crs == null) { this.crs = bbox.getCoordinateReferenceSystem(); } expandToInclude(getJTSEnvelope(bbox)); }
public ReferencedEnvelope3D get3DEnvelope(Geometry geom) { Coordinate[] coordinates = geom.getCoordinates(); ReferencedEnvelope3D env = new ReferencedEnvelope3D(); for (Coordinate coordinate : coordinates) { env.expandToInclude(coordinate); } return env; }
@Override public void expandToInclude(DirectPosition pt) { double x = pt.getOrdinate(0); double y = pt.getOrdinate(1); double z = pt.getDimension() >= 3 ? pt.getOrdinate(2) : Double.NaN; expandToInclude(x, y, z); } /**
targetEnvelope.expandToInclude(pt); targetEnvelope.expandToInclude(pt); targetEnvelope.expandToInclude(pt); targetEnvelope.expandToInclude(pt);
JTS.transform(this, target, transform, numPointsForTransformation); target.expandToInclude(0, 0, this.minz); target.expandToInclude(0, 0, this.maxz);
@Test public void include() throws Exception { ReferencedEnvelope3D australia = new ReferencedEnvelope3D(DefaultGeographicCRS.WGS84_3D); australia.include(40, 110, 0); australia.include(10, 150, 10); ReferencedEnvelope3D newZealand = new ReferencedEnvelope3D(DefaultEngineeringCRS.CARTESIAN_3D); newZealand.include(50, 165, 0); newZealand.include(33, 180, 5); try { australia.expandToInclude(newZealand); fail("Expected a mismatch of CoordinateReferenceSystem"); } catch (MismatchedReferenceSystemException t) { // expected } try { australia.include(newZealand); fail("Expected a mismatch of CoordinateReferenceSystem"); } catch (MismatchedReferenceSystemException t) { // expected } }