compareLocationValues method

int compareLocationValues(
  1. int componentIndex1,
  2. int segmentIndex1,
  3. double segmentFraction1
)

Compares this object with the specified index values for order.

@param componentIndex1 a component index @param segmentIndex1 a segment index @param segmentFraction1 a segment fraction @return a negative integer, zero, or a positive integer as this LineStringLocation is less than, equal to, or greater than the specified locationValues

Implementation

int compareLocationValues(
    int componentIndex1, int segmentIndex1, double segmentFraction1) {
  // compare component indices
  if (componentIndex < componentIndex1) return -1;
  if (componentIndex > componentIndex1) return 1;
  // compare segments
  if (segmentIndex < segmentIndex1) return -1;
  if (segmentIndex > segmentIndex1) return 1;
  // same segment, so compare segment fraction
  if (segmentFraction < segmentFraction1) return -1;
  if (segmentFraction > segmentFraction1) return 1;
  // same location
  return 0;
}