/** * If the given object is a JTS geometry and its envelope is non-empty, returns * that envelope as an Apache SIS implementation. Otherwise returns {@code null}. * * @param geometry the geometry from which to get the envelope, or {@code null}. * @return the envelope of the given object, or {@code null} if the object is not * a recognized geometry or its envelope is empty. */ @Override final GeneralEnvelope tryGetEnvelope(final Object geometry) { if (geometry instanceof Geometry) { final Envelope bounds = ((Geometry) geometry).getEnvelopeInternal(); final GeneralEnvelope env = new GeneralEnvelope(2); env.setRange(0, bounds.getMinX(), bounds.getMaxX()); env.setRange(1, bounds.getMinY(), bounds.getMaxY()); if (!env.isEmpty()) { return env; } } return null; }
if (envelope.isEmpty()) try {
try { final Envelope penv2 = Envelopes.transform(env2, crs1); if (GeneralEnvelope.castOrCopy(penv2).isEmpty()) break cas1; return GeneralEnvelope.castOrCopy(env1).intersects(penv2); } catch(Exception ex) {/*do nothing*/} try { final Envelope penv1 = Envelopes.transform(env1, crs2); if (GeneralEnvelope.castOrCopy(penv1).isEmpty()) break cas2; return GeneralEnvelope.castOrCopy(penv1).intersects(env2); } catch(Exception ex) {/*do nothing*/}
assert isEmpty() || AbstractEnvelope.castOrCopy(envelope).contains(this) : this;
assert isEmpty() || AbstractEnvelope.castOrCopy(envelope).contains(this) : this;
assert contains(position) || isEmpty() || hasNaN(position) : position;
assert contains(position) || isEmpty() || hasNaN(position) : position;
/** * Asserts that the intersection of the two following envelopes is equals to the given rectangle. * First, this method tests using the {@link Envelope2D} implementation. Then, it tests using the * {@link GeneralEnvelope} implementation. */ private static void assertIntersectEquals(final GeneralEnvelope e1, final GeneralEnvelope e2, final double xmin, final double ymin, final double xmax, final double ymax) { final Envelope2D r1 = new Envelope2D(e1); final Envelope2D r2 = new Envelope2D(e2); final Envelope2D ri = r1.createIntersection(r2); assertFalse("isEmpty", r1.isEmpty()); assertEnvelopeEquals(ri, xmin, ymin, xmax, ymax); assertEquals("Interchanged arguments.", ri, r2.createIntersection(r1)); // Compares with GeneralEnvelope. final GeneralEnvelope ei = new GeneralEnvelope(e1); ei.intersect(e2); assertFalse("isEmpty", e1.isEmpty()); assertEnvelopeEquals(ei, xmin, ymin, xmax, ymax); assertTrue("Using GeneralEnvelope.", ei.equals(ri, STRICT, false)); // Interchanges arguments. ei.setEnvelope(e2); ei.intersect(e1); assertFalse("isEmpty", e1.isEmpty()); assertEnvelopeEquals(ei, xmin, ymin, xmax, ymax); assertTrue("Using GeneralEnvelope.", ei.equals(ri, STRICT, false)); }
assert contains(envelope) || isEmpty() || hasNaN(envelope) : this;
assert contains(envelope) || isEmpty() || hasNaN(envelope) : this;
env.setRange(3, Double.NaN, Double.NaN); assertFalse("isAllNaN", env.isAllNaN()); // Opportunist test (not really the topic of this method). assertTrue ("isEmpty", env.isEmpty()); // Opportunist test (not really the topic of this method).