compareToSameClassWithComparator method

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

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) {
  GeometryCollection gc = o as GeometryCollection;

  int n1 = getNumGeometries();
  int n2 = gc.getNumGeometries();
  int i = 0;
  while (i < n1 && i < n2) {
    Geometry thisGeom = getGeometryN(i);
    Geometry otherGeom = gc.getGeometryN(i);
    int holeComp = thisGeom.compareToSameClassWithComparator(otherGeom, comp);
    if (holeComp != 0) return holeComp;
    i++;
  }
  if (i < n1) return 1;
  if (i < n2) return -1;
  return 0;
}