com.vividsolutions.jts.geom
Class CoordinateArrays
java.lang.Object
com.vividsolutions.jts.geom.CoordinateArrays
public class CoordinateArrays
extends java.lang.Object
Useful utility functions for handling Coordinate arrays
atLeastNCoordinatesOrNothing
public static Coordinate[] atLeastNCoordinatesOrNothing(int n,
Coordinate[] c)
Returns either the given coordinate array if its length is greater than the
given amount, or an empty coordinate array.
copyDeep
public static Coordinate[] copyDeep(Coordinate[] coordinates)
Creates a deep copy of the argument Coordinate) array.
@param coordinates an array of Coordinates
@return a deep copy of the input
equals
public static boolean equals(Coordinate[] coord1,
Coordinate[] coord2)
Returns true if the two arrays are identical, both null, or pointwise
equal (as compared using Coordinate#equals)
hasRepeatedPoints
public static boolean hasRepeatedPoints(Coordinate[] coord)
Returns whether #equals returns true for any two consecutive Coordinates
in the given array.
indexOf
public static int indexOf(Coordinate coordinate,
Coordinate[] coordinates)
Returns the index of coordinate
in coordinates
.
The first position is 0; the second, 1; etc.
coordinate
- the Coordinate
to search forcoordinates
- the array to search
- the position of
coordinate
, or -1 if it is
not found
minCoordinate
public static Coordinate minCoordinate(Coordinate[] coordinates)
Returns the minimum coordinate, using the usual lexicographic comparison.
coordinates
- the array to search
- the minimum coordinate in the array, found using
compareTo
removeRepeatedPoints
public static Coordinate[] removeRepeatedPoints(Coordinate[] coord)
If the coordinate array argument has repeated points,
constructs a new array containing no repeated points.
Otherwise, returns the argument.
reverse
public static void reverse(Coordinate[] coord)
Reverses the coordinates in an array in-place.
scroll
public static void scroll(Coordinate[] coordinates,
Coordinate firstCoordinate)
Shifts the positions of the coordinates until firstCoordinate
is first.
coordinates
- the array to rearrangefirstCoordinate
- the coordinate to make first
toCoordinateArray
public static Coordinate[] toCoordinateArray(List coordList)
Converts the given List of Coordinates into a Coordinate array.