normalize method
void
normalize()
override
Normalizes a LineString. A normalized linestring has the first point which is not equal to it's reflected point less than the reflected point.
Implementation
void normalize() {
for (int i = 0; i < points.size() / 2; i++) {
int j = points.size() - 1 - i;
// skip equal points on both ends
if (!points.getCoordinate(i).equals(points.getCoordinate(j))) {
if (points.getCoordinate(i).compareTo(points.getCoordinate(j)) > 0) {
CoordinateSequence copy = points.copy();
CoordinateSequences.reverse(copy);
points = copy;
}
return;
}
}
}