/** * Computes the canonical orientation for a coordinate array. * * @param pts the array to test * @return <code>true</code> if the points are oriented forwards * or <code>false</code if the points are oriented in reverse */ private static boolean orientation(Coordinate[] pts) { return CoordinateArrays.increasingDirection(pts) == 1; }
public int OLDcompare(Object o1, Object o2) { Coordinate[] pts1 = (Coordinate[]) o1; Coordinate[] pts2 = (Coordinate[]) o2; if (pts1.length < pts2.length) return -1; if (pts1.length > pts2.length) return 1; if (pts1.length == 0) return 0; int dir1 = increasingDirection(pts1); int dir2 = increasingDirection(pts2); int i1 = dir1 > 0 ? 0 : pts1.length - 1; int i2 = dir2 > 0 ? 0 : pts1.length - 1; for (int i = 0; i < pts1.length; i++) { int comparePt = pts1[i1].compareTo(pts2[i2]); if (comparePt != 0) return comparePt; i1 += dir1; i2 += dir2; } return 0; }