/** Check if this bounding box intersects the provided bounds. */ public boolean intersects(final BoundingBox3D bbox) { ensureCompatibleReferenceSystem(bbox); return intersects(getJTSEnvelope(bbox)); }
/** * Initialize the bounding box with another bounding box. * * @since 2.4 */ public void setBounds(final BoundingBox3D bbox) { ensureCompatibleReferenceSystem(bbox); init(getJTSEnvelope(bbox)); }
/** Returns {@code true} if the provided bounds are contained by this bounding box. */ public boolean contains(final BoundingBox3D bbox) { ensureCompatibleReferenceSystem(bbox); return covers(getJTSEnvelope(bbox)); }
/** Returns {@code true} if the provided location is contained by this bounding box. */ public boolean contains(DirectPosition pos) { ensureCompatibleReferenceSystem(pos); return contains(pos.getOrdinate(0), pos.getOrdinate(1), pos.getOrdinate(2)); }
/** * Enlarges this <code>Envelope</code> so that it contains the <code>other</code> Envelope. Has * no effect if <code>other</code> is wholly on or within the envelope. * * @param other the <code>Envelope</code> to expand to include */ public void expandToInclude(ReferencedEnvelope3D other) { ensureCompatibleReferenceSystem(other); if (other.isNull()) { return; } if (isNull()) { super.expandToInclude(other); minz = other.getMinZ(); maxz = other.getMaxZ(); } else { super.expandToInclude(other); if (other.minz < minz) { minz = other.minz; } if (other.maxz > maxz) { maxz = other.maxz; } } }
/** * 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()); }