/** * Compares this object with the specified object for order. Uses the standard lexicographic * ordering for the points in the LineSegment. * * @param o the <code>LineSegment</code> with which this <code>LineSegment</code> is being * compared * @return a negative integer, zero, or a positive integer as this <code>LineSegment</code> is * less than, equal to, or greater than the specified <code>LineSegment</code> */ public int compareTo(Object o) { LineSegment other = (LineSegment) o; int comp0 = p0.compareTo(other.p0); if (comp0 != 0) return comp0; return p1.compareTo(other.p1); }
/** * Puts the line segment into a normalized form. This is useful for using line segments in maps * and indexes when topological equality rather than exact equality is desired. A segment in * normalized form has the first point smaller than the second (according to the standard ordering * on {@link Coordinate}). */ public void normalize() { if (p1.compareTo(p0) < 0) reverse(); }