com.vividsolutions.jts.geom

Class CoordinateArrays


public class CoordinateArrays
extends java.lang.Object

Useful utility functions for handling Coordinate arrays
Version:
1.6

Method Summary

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.
static Coordinate[]
copyDeep(Coordinate[] coordinates)
Creates a deep copy of the argument
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)
static boolean
hasRepeatedPoints(Coordinate[] coord)
Returns whether #equals returns true for any two consecutive Coordinates in the given array.
static int
indexOf(Coordinate coordinate, Coordinate[] coordinates)
Returns the index of coordinate in coordinates.
static Coordinate
minCoordinate(Coordinate[] coordinates)
Returns the minimum coordinate, using the usual lexicographic comparison.
static Coordinate[]
removeRepeatedPoints(Coordinate[] coord)
If the coordinate array argument has repeated points, constructs a new array containing no repeated points.
static void
reverse(Coordinate[] coord)
Reverses the coordinates in an array in-place.
static void
scroll(Coordinate[] coordinates, Coordinate firstCoordinate)
Shifts the positions of the coordinates until firstCoordinate is first.
static Coordinate[]
toCoordinateArray(List coordList)
Converts the given List of Coordinates into a Coordinate array.

Method Details

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.
Parameters:
coordinate - the Coordinate to search for
coordinates - the array to search
Returns:
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.
Parameters:
coordinates - the array to search
Returns:
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.
Parameters:
coordinates - the array to rearrange
firstCoordinate - the coordinate to make first

toCoordinateArray

public static Coordinate[] toCoordinateArray(List coordList)
Converts the given List of Coordinates into a Coordinate array.