compareToSameClass method
Returns whether this Geometry
is greater than, equal to,
or less than another Geometry
having the same class.
@param o a Geometry
having the same class as this Geometry
@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 compareToSameClass(Object o) {
LineString line = o as LineString;
// MD - optimized implementation
int i = 0;
int j = 0;
while (i < points.size() && j < line.points.size()) {
int comparison =
points.getCoordinate(i).compareTo(line.points.getCoordinate(j));
if (comparison != 0) {
return comparison;
}
i++;
j++;
}
if (i < points.size()) {
return 1;
}
if (j < line.points.size()) {
return -1;
}
return 0;
}