compareToSameClassWithComparator method
Returns whether this Geometry
is greater than, equal to,
or less than another Geometry
of the same class.
using the given {@link CoordinateSequenceComparator}.
@param o a Geometry
having the same class as this Geometry
@param comp a CoordinateSequenceComparator
@return a positive number, 0, or a negative number, depending on whether
this object is greater than, equal to, or less than o
, as
defined in "Normal Form For Geometry" in the JTS Technical
Specifications
Implementation
int compareToSameClassWithComparator(
Object o, Comparator<CoordinateSequence> comp) {
Polygon poly = o as Polygon;
LinearRing thisShell = shell!;
LinearRing otherShell = poly.shell!;
int shellComp =
thisShell.compareToSameClassWithComparator(otherShell, comp);
if (shellComp != 0) return shellComp;
int nHole1 = getNumInteriorRing();
int nHole2 = poly.getNumInteriorRing();
int i = 0;
while (i < nHole1 && i < nHole2) {
LinearRing thisHole = getInteriorRingN(i);
LinearRing otherHole = poly.getInteriorRingN(i);
int holeComp = thisHole.compareToSameClassWithComparator(otherHole, comp);
if (holeComp != 0) return holeComp;
i++;
}
if (i < nHole1) return 1;
if (i < nHole2) return -1;
return 0;
}