/** * For {@link SpecializableTransform#equals(Object)} implementation. */ @Override public boolean equals(final Object obj) { if (super.equals(obj)) { final SubArea other = (SubArea) obj; return transform.equals(other.transform) && Objects.equals(specialization, other.specialization); } return false; }
crs = envelopeCRS; assert crs.getCoordinateSystem().getDimension() == getDimension() : crs; assert envelope.getClass() != getClass() || equals(envelope) : envelope;
crs = envelopeCRS; assert crs.getCoordinateSystem().getDimension() == getDimension() : crs; assert envelope.getClass() != getClass() || equals(envelope) : envelope;
/** * Tests two distinct sub-envelopes for equality. */ @Test @Override public void testEquals() { final GeneralEnvelope e1 = create(-40, -20, +60, +30); final GeneralEnvelope e2 = create(-40, -20, +60, +30); assertEquals(e1, e2); e2.ordinates[0] = -1; e2.ordinates[1] = -4; e2.ordinates[9] = -9; assertEquals(e1, e2); e2.ordinates[2] = -41; assertFalse(e1.equals(e2)); }
/** * Asserts that adding the given point to the given envelope produces the given result. * First, this method tests using the {@link Envelope2D} implementation. Then, it tests * using the {@link GeneralEnvelope} implementation. */ private static void assertAddEquals(final GeneralEnvelope e, final DirectPosition2D p, final double xmin, final double ymin, final double xmax, final double ymax) { final Envelope2D r = new Envelope2D(e); r.add(p); assertEnvelopeEquals(r, xmin, ymin, xmax, ymax); // Compares with GeneralEnvelope. final GeneralEnvelope ec = new GeneralEnvelope(e); ec.add(p); assertEnvelopeEquals(ec, xmin, ymin, xmax, ymax); assertTrue("Using GeneralEnvelope.", ec.equals(r, STRICT, false)); }
/** * 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)); }
/** * Tests the {@link GeneralEnvelope#clone()} method. */ @Test public void testClone() { final GeneralEnvelope e1 = new GeneralEnvelope(2); e1.setRange(0, -40, +60); e1.setRange(1, -20, +30); final GeneralEnvelope e2 = e1.clone(); validate(e2); assertNotSame("Expected a new instance.", e1, e2); assertEquals ("The two instances should be equal.", e1, e2); e1.setRange(0, -40, +61); assertFalse("Ordinates array should have been cloned.", e1.equals(e2)); e2.setRange(0, -40, +61); assertEquals(e1, e2); }
assertNotSame(e1, e2); assertEquals (e1, e2); assertTrue (e1.equals(e2, EPS, true )); assertTrue (e1.equals(e2, EPS, false)); assertEquals (e1.hashCode(), e2.hashCode()); assertTrue (e1.contains(e2, true )); assertFalse(e1.contains(e2, false)); assertFalse(e1.equals (e2)); assertTrue (e1.equals (e2, EPS, true )); assertTrue (e1.equals (e2, EPS, false)); assertFalse(e1.hashCode() == e2.hashCode()); assertTrue (e1.contains(e2, true )); assertFalse(e1.contains(e2, false)); assertFalse(e1.equals (e2)); assertFalse(e1.equals (e2, EPS, true )); assertFalse(e1.equals (e2, EPS, false)); assertFalse(e1.hashCode() == e2.hashCode());