eventCompare method

int? eventCompare(
  1. bool? p1_isStart,
  2. Coordinate? p1_1,
  3. Coordinate? p1_2,
  4. bool? p2_isStart,
  5. Coordinate? p2_1,
  6. Coordinate? p2_2,
)

Implementation

int eventCompare(bool p1_isStart, JTS.Coordinate p1_1, JTS.Coordinate p1_2,
    bool p2_isStart, JTS.Coordinate p2_1, JTS.Coordinate p2_2) {
  // compare the selected points first
  // compare the selected points first
  var comp = Epsilon().pointsCompare(p1_1, p2_1);
  if (comp != 0) return comp;

  // the selected points are the same

  if (Epsilon().pointsSame(
      p1_2, p2_2)) // if the non-selected points are the same too...
    return 0; // then the segments are equal

  if (p1_isStart != p2_isStart) // if one is a start and the other isn't...
    return p1_isStart ? 1 : -1; // favor the one that isn't the start

  // otherwise, we'll have to calculate which one is below the other manually
  return Epsilon().pointAboveOrOnLine(
          p1_2,
          p2_isStart ? p2_1 : p2_2, // order matters
          p2_isStart ? p2_2 : p2_1)
      ? 1
      : -1;
}