compareToWithComparator method

int compareToWithComparator(
  1. Object o,
  2. Comparator<CoordinateSequence> comp
)

Returns whether this Geometry is greater than, equal to, or less than another Geometry, using the given {@link CoordinateSequenceComparator}.

If their classes are different, they are compared using the following ordering:

  • Point (lowest)
  • MultiPoint
  • LineString
  • LinearRing
  • MultiLineString
  • Polygon
  • MultiPolygon
  • GeometryCollection (highest)
If the two Geometrys have the same class, their first elements are compared. If those are the same, the second elements are compared, etc.

@param o a Geometry with which to compare 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 compareToWithComparator(Object o, Comparator<CoordinateSequence> comp) {
  Geometry other = o as Geometry;
  if (getSortIndex() != other.getSortIndex()) {
    return getSortIndex() - other.getSortIndex();
  }
  if (isEmpty() && other.isEmpty()) {
    return 0;
  }
  if (isEmpty()) {
    return -1;
  }
  if (other.isEmpty()) {
    return 1;
  }
  return compareToSameClassWithComparator(o, comp);
}