/** * Returns true if the two <code>Geometry</code>s are exactly equal. * Two Geometries are exactly equal iff: * <ul> * <li>they have the same structure * <li>they have the same values for their vertices, * in exactly the same order. * </ul> * This provides a stricter test of equality than * {@link #equalsTopo(Geometry)}, which is more useful * in certain situations * (such as using geometries as keys in collections). * <p> * This method does <i>not</i> * test the values of the <code>GeometryFactory</code>, the <code>SRID</code>, * or the <code>userData</code> fields. * <p> * To properly test equality between different geometries, * it is usually necessary to {@link #normalize()} them first. * *@param other the <code>Geometry</code> with which to compare this <code>Geometry</code> *@return <code>true</code> if this and the other <code>Geometry</code> * have identical structure and point values. * * @see #equalsExact(Geometry, double) * @see #normalize() * @see #norm() */ public boolean equalsExact(Geometry other) { return equalsExact(other, 0); }
return equalsExact(g);
public boolean equalsExact(Geometry other, double tolerance) { if (!isEquivalentClass(other)) { return false; } Polygon otherPolygon = (Polygon) other; Geometry thisShell = shell; Geometry otherPolygonShell = otherPolygon.shell; if (!thisShell.equalsExact(otherPolygonShell, tolerance)) { return false; } if (holes.length != otherPolygon.holes.length) { return false; } for (int i = 0; i < holes.length; i++) { if (!((Geometry) holes[i]).equalsExact(otherPolygon.holes[i], tolerance)) { return false; } } return true; }
public boolean equalsExact(Geometry other, double tolerance) { if (!isEquivalentClass(other)) { return false; } GeometryCollection otherCollection = (GeometryCollection) other; if (geometries.length != otherCollection.geometries.length) { return false; } for (int i = 0; i < geometries.length; i++) { if (!((Geometry) geometries[i]).equalsExact(otherCollection.geometries[i], tolerance)) { return false; } } return true; }
/** * Tests whether two geometries are exactly equal * in their normalized forms. * This is a convenience method which creates normalized * versions of both geometries before computing * {@link #equalsExact(Geometry)}. * <p> * This method is relatively expensive to compute. * For maximum performance, the client * should instead perform normalization on the individual geometries * at an appropriate point during processing. * * @param g a Geometry * @return true if the input geometries are exactly equal in their normalized form */ public boolean equalsNorm(Geometry g) { if (g == null) return false; return norm().equalsExact(g.norm()); }
static public boolean equalsExactTolerance(Geometry arg0,Geometry arg1, Double arg2) { if (arg0 == null || arg1 == null || arg2 == null) return false; Geometry _this = arg0; return _this.equalsExact(arg1,arg2); }
static public boolean equalsExact(Geometry arg0,Geometry arg1) { Geometry _this = arg0; return _this.equalsExact(arg1); }
static public boolean equalsExactTolerance(Geometry arg0,Geometry arg1,double arg2) { Geometry _this = arg0; return _this.equalsExact(arg1,arg2); }
static public boolean equalsExact(Geometry arg0,Geometry arg1) { if (arg0 == null || arg1 == null) return false; Geometry _this = arg0; return _this.equalsExact(arg1); }
public boolean equals(Object x, Object y) throws HibernateException { if (x == y) return true; if (x == null || y == null) return false; return ((Geometry) x).equalsExact((Geometry) y); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; JtsGeometry that = (JtsGeometry) o; return geom.equalsExact(that.geom);//fast equality for normalized geometries }
private static boolean geomEquals(@Nullable Geometry g1, @Nullable Geometry g2) { if (g1 == null || g2 == null) { return g1 == null && g2 == null; } return g1.equalsExact(g2); }
private boolean geomEquals(@Nullable Geometry g1, @Nullable Geometry g2) { if (g1 == null || g2 == null) { return g1 == null && g2 == null; } return g1.equalsExact(g2); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; JtsGeometry that = (JtsGeometry) o; return geom.equalsExact(that.geom);//fast equality for normalized geometries }
/** * Compares two geometries for equality. */ protected void assertEquals(Geometry expected, Geometry actual) { if (expected == actual) { return; } assertNotNull(expected); assertNotNull(actual); assertTrue(expected.equalsExact(actual)); }
@Override public boolean evaluateInternal(Geometry left, Geometry right) { Envelope envLeft = left.getEnvelopeInternal(); Envelope envRight = right.getEnvelopeInternal(); if (envRight.equals(envLeft)) return left.equalsExact(right); else return false; }
/** * Compares two geometries for equality. */ protected void assertEquals(String message, Geometry expected, Geometry actual) { if (expected == actual) { return; } assertNotNull(message, expected); assertNotNull(message, actual); assertTrue(message, expected.equalsExact(actual)); }
private void testFormatting(Geometry expectedGeometry) throws ParseException { final WKTReader wktReader = new WKTReader(); final String geometryWkt = converter.format(expectedGeometry); final Geometry geometry = wktReader.read(geometryWkt); assertTrue(expectedGeometry.equalsExact(geometry)); }
private void testParsing(Geometry expectedGeometry) throws ConversionException { final WKTWriter wktWriter = new WKTWriter(); final String geometryWkt = wktWriter.write(expectedGeometry); final Geometry geometry = converter.parse(geometryWkt); assertTrue(expectedGeometry.equalsExact(geometry)); assertEquals(null, converter.parse("")); } }
@Test public void testNoConflictIfSameDiff2() throws Exception { String wkt = "MULTIPOLYGON (((-75.0740073 38.6938098, -75.0739683 38.6935296, " + "-75.0745695 38.6934786, -75.0745824 38.6935715, -75.0741091 38.6936117, " + "-75.0741352 38.6937989, -75.0740073 38.6938098)))"; Geometry oldGeom = new WKTReader().read(wkt); Geometry newGeom = new WKTReader().read(wkt); assertTrue(oldGeom.equalsExact(newGeom)); GeometryAttributeDiff diff = new GeometryAttributeDiff(oldGeom, newGeom); GeometryAttributeDiff diff2 = new GeometryAttributeDiff(oldGeom, newGeom); assertFalse(diff.conflicts(diff2)); } }