compareTo method

int compareTo(
  1. SegmentNode obj
)
override

@return -1 this SegmentNode is located before the argument location; 0 this SegmentNode is at the argument location; 1 this SegmentNode is located after the argument location

Implementation

int compareTo(SegmentNode obj) {
  SegmentNode other = obj;

  if (segmentIndex < other.segmentIndex) return -1;
  if (segmentIndex > other.segmentIndex) return 1;

  if (coord.equals2D(other.coord)) return 0;

  // an exterior node is the segment start point, so always sorts first
  // this guards against a robustness problem where the octants are not reliable
  if (!_isInterior) return -1;
  if (!other._isInterior) return 1;

  return SegmentPointComparator.compare(segmentOctant, coord, other.coord);
  //return segment.compareNodePosition(this, other);
}