compareTo method

int compareTo(
  1. dynamic o
)
override

Returns whether this Geometry is greater than, equal to, or less than another Geometry.

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 @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 compareTo(dynamic o) {
  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 compareToSameClass(o);
}