com.vividsolutions.jts.geom
Class CoordinateArrays

java.lang.Object
  extended bycom.vividsolutions.jts.geom.CoordinateArrays

public class CoordinateArrays
extends java.lang.Object

Useful utility functions for handling Coordinate arrays

Version:
1.4.0

Constructor Summary
CoordinateArrays()
           
 
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 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.
protected static int indexOf(Coordinate coordinate, Coordinate[] coordinates)
          Returns the index of coordinate in coordinates.
protected 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.
protected static void scroll(Coordinate[] coordinates, Coordinate firstCoordinate)
          Shifts the positions of the coordinates until firstCoordinate is first.
static Coordinate[] toCoordinateArray(java.util.List coordList)
          Converts the given List of Coordinates into a Coordinate array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoordinateArrays

public CoordinateArrays()
Method Detail

toCoordinateArray

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


hasRepeatedPoints

public static boolean hasRepeatedPoints(Coordinate[] coord)
Returns whether #equals returns true for any two consecutive Coordinates in the given array.


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.


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.

See Also:
hasRepeatedPoints(Coordinate[])

reverse

public static void reverse(Coordinate[] coord)
Reverses the coordinates in an array in-place.


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)

See Also:
Coordinate.equals(Object)

minCoordinate

protected 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
See Also:
Coordinate.compareTo(Object)

scroll

protected 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

indexOf

protected 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