removeRepeatedOrInvalidPoints static method
If the coordinate array argument has repeated or invalid points, constructs a new array containing no repeated points. Otherwise, returns the argument.
@param coord an array of coordinates @return the array with repeated and invalid coordinates removed @see #hasRepeatedOrInvalidPoints(Coordinate[]) @see Coordinate#isValid()
Implementation
static List<Coordinate> removeRepeatedOrInvalidPoints(
List<Coordinate> coord) {
if (!hasRepeatedOrInvalidPoints(coord)) return coord;
CoordinateList coordList = new CoordinateList();
for (int i = 0; i < coord.length; i++) {
if (!coord[i].isValid()) continue;
coordList.addCoord(coord[i], false);
}
return coordList.toCoordinateArray();
}