equalsExactWithTol method
Returns true if the two Geometry
s are exactly equal,
up to a specified distance tolerance.
Two Geometries are exactly equal within a distance tolerance
if and only if:
- they have the same structure
- they have the same values for their vertices, within the given tolerance distance, in exactly the same order.
GeometryFactory
, the SRID
,
or the userData
fields.
To properly test equality between different geometries, it is usually necessary to {@link #normalize()} them first.
@param other the Geometry
with which to compare this Geometry
@param tolerance distance at or below which two Coordinate
s
are considered equal
@return true
if this and the other Geometry
have identical structure and point values, up to the distance tolerance.
@see #equalsExact(Geometry) @see #normalize() @see #norm()
Implementation
bool equalsExactWithTol(Geometry other, double tolerance) {
if (!isEquivalentClass(other)) {
return false;
}
Polygon otherPolygon = other as Polygon;
Geometry thisShell = shell!;
Geometry otherPolygonShell = otherPolygon.shell!;
if (!thisShell.equalsExactWithTol(otherPolygonShell, tolerance)) {
return false;
}
if (holes!.length != otherPolygon.holes!.length) {
return false;
}
for (int i = 0; i < holes!.length; i++) {
if (!holes![i].equalsExactWithTol(otherPolygon.holes![i], tolerance)) {
return false;
}
}
return true;
}