public double getMaxY() { return envelope.getMaxY(); }
/** Returns the maximal ordinate along the specified dimension. */ public double getMaximum(final int dimension) { switch (dimension) { case 0: return getMaxX(); case 1: return getMaxY(); case 2: return getMaxZ(); default: throw new IndexOutOfBoundsException(String.valueOf(dimension)); } }
/** * A coordinate position consisting of all the maximal ordinates for each dimension for all * points within the {@code Envelope}. */ public DirectPosition getUpperCorner() { return new DirectPosition3D(crs, getMaxX(), getMaxY(), getMinZ()); }
/** Returns the center ordinate along the specified dimension. */ public double getMedian(final int dimension) { switch (dimension) { case 0: return 0.5 * (getMinX() + getMaxX()); case 1: return 0.5 * (getMinY() + getMaxY()); case 2: return 0.5 * (getMinZ() + getMaxZ()); default: throw new IndexOutOfBoundsException(String.valueOf(dimension)); } }
/** * Computes the distance between this and another <code>Envelope</code>. The distance between * overlapping Envelopes is 0. Otherwise, the distance is the Euclidean distance between the * closest points. */ public double distance(ReferencedEnvelope3D env) { if (intersects(env)) return 0; double dx = 0.0; if (getMaxX() < env.getMinX()) dx = env.getMinX() - getMaxX(); else if (getMinX() > env.getMaxX()) dx = getMinX() - env.getMaxX(); double dy = 0.0; if (getMaxY() < env.getMinY()) dy = env.getMinY() - getMaxY(); else if (getMinY() > env.getMaxY()) dy = getMinY() - env.getMaxY(); double dz = 0.0; if (maxz < env.minz) dz = env.minz - maxz; else if (minz > env.maxz) dz = minz - env.maxz; // if either is zero, the envelopes overlap either vertically or // horizontally if (dx == 0.0 && dz == 0) return dy; if (dy == 0.0 && dz == 0) return dx; if (dx == 0 && dy == 0) return dz; return Math.sqrt(dx * dx + dy * dy + dz * dz); }
/** * Computes the coordinate of the centre of this envelope (as long as it is non-null * * @return the centre coordinate of this envelope <code>null</code> if the envelope is null */ public Coordinate centre() { if (isNull()) return null; return new Coordinate( (getMinX() + getMaxX()) / 2.0, (getMinY() + getMaxY()) / 2.0, (getMinZ() + getMaxZ()) / 2.0); }
/** * Computes the intersection of two {@link Envelope}s. * * @param env the envelope to intersect with * @return a new Envelope representing the intersection of the envelopes (this will be the null * envelope if either argument is null, or they do not intersect */ public ReferencedEnvelope3D intersection(ReferencedEnvelope3D env) { ensureCompatibleReferenceSystem(env); if (isNull() || env.isNull() || !intersects(env)) return new ReferencedEnvelope3D(); double intMinX = getMinX() > env.getMinX() ? getMinX() : env.getMinX(); double intMinY = getMinY() > env.getMinY() ? getMinY() : env.getMinY(); double intMinZ = minz > env.minz ? minz : env.minz; double intMaxX = getMaxX() < env.getMaxX() ? getMaxX() : env.getMaxX(); double intMaxY = getMaxY() < env.getMaxY() ? getMaxY() : env.getMaxY(); double intMaxZ = maxz < env.maxz ? maxz : env.maxz; return new ReferencedEnvelope3D( intMinX, intMaxX, intMinY, intMaxY, intMinZ, intMaxZ, env.getCoordinateReferenceSystem()); }
public boolean equals(Object obj) { if (obj == EVERYTHING) { return true; } if (obj instanceof ReferencedEnvelope3D) { ReferencedEnvelope3D other = (ReferencedEnvelope3D) obj; if (other.crs != EVERYTHING.crs) return false; if (other.getMinX() != EVERYTHING.getMinX()) return false; if (other.getMinY() != EVERYTHING.getMinY()) return false; if (other.getMinZ() != EVERYTHING.getMinZ()) return false; if (other.getMaxX() != EVERYTHING.getMaxX()) return false; if (other.getMaxY() != EVERYTHING.getMaxY()) return false; if (other.getMaxZ() != EVERYTHING.getMaxZ()) return false; return true; } return super.equals(obj); }
/** * Translates this envelope by given amounts in the X and Y direction. * * @param transX the amount to translate along the X axis * @param transY the amount to translate along the Y axis * @param transZ the amount to translate along the Z axis */ public void translate(double transX, double transY, double transZ) { if (isNull()) { return; } init( getMinX() + transX, getMaxX() + transX, getMinY() + transY, getMaxY() + transY, getMinZ() + transZ, getMaxZ() + transZ); }
public Expression getExpression2() { // in this case, the 3D BBOX falls back to regular 2D bbox behaviour (until there is more // support for 3D geometries) // 3DBBOX must be run as a post-filter in order to support the third coordinate. Coordinate[] coords = new Coordinate[5]; coords[0] = new Coordinate(envelope.getMinX(), envelope.getMinY()); coords[1] = new Coordinate(envelope.getMinX(), envelope.getMaxY()); coords[2] = new Coordinate(envelope.getMaxX(), envelope.getMaxY()); coords[3] = new Coordinate(envelope.getMaxX(), envelope.getMinY()); coords[4] = new Coordinate(envelope.getMinX(), envelope.getMinY()); LinearRing ring = null; GeometryFactory gfac = new GeometryFactory(); try { ring = gfac.createLinearRing(coords); } catch (TopologyException tex) { throw new IllegalFilterException(tex.toString()); } Polygon polygon = gfac.createPolygon(ring, null); if (envelope instanceof ReferencedEnvelope3D) { ReferencedEnvelope3D refEnv = (ReferencedEnvelope3D) envelope; polygon.setUserData(refEnv.getCoordinateReferenceSystem()); } return factory.literal(polygon); }