public class CoordinateArrays extends Object
Modifier and Type | Class and Description |
---|---|
static class |
CoordinateArrays.BidirectionalComparator
A
Comparator for Coordinate arrays
modulo their directionality. |
static class |
CoordinateArrays.ForwardComparator
A
Comparator for Coordinate arrays
in the forward direction of their coordinates,
using lexicographic ordering. |
Modifier and Type | Method and Description |
---|---|
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 int |
compare(Coordinate[] pts1,
Coordinate[] pts2)
Compares two
Coordinate arrays
in the forward direction of their coordinates,
using lexicographic ordering. |
static Coordinate[] |
copyDeep(Coordinate[] coordinates)
Creates a deep copy of the argument
Coordinate array. |
static void |
copyDeep(Coordinate[] src,
int srcStart,
Coordinate[] dest,
int destStart,
int length)
Creates a deep copy of a given section of a source
Coordinate array
into a destination Coordinate array. |
static int |
dimension(Coordinate[] pts)
Determine dimension based on subclass of
Coordinate . |
static void |
enforceConsistency(Coordinate[] array)
Utility method ensuring array contents are of consistent dimension and measures.
|
static Coordinate[] |
enforceConsistency(Coordinate[] array,
int dimension,
int measures)
Utility method ensuring array contents are of the specified dimension and measures.
|
static Envelope |
envelope(Coordinate[] coordinates)
Computes the envelope of the coordinates.
|
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 |
equals(Coordinate[] coord1,
Coordinate[] coord2,
Comparator coordinateComparator)
Returns true if the two arrays are identical, both null, or pointwise
equal, using a user-defined
Comparator for Coordinate s |
static Coordinate[] |
extract(Coordinate[] pts,
int start,
int end)
|
static boolean |
hasRepeatedOrInvalidPoints(Coordinate[] coord)
Tests whether an array has any repeated or invalid coordinates.
|
static boolean |
hasRepeatedPoints(Coordinate[] coord)
Tests whether
Coordinate.equals(Object) returns true for any two consecutive Coordinates
in the given array. |
static int |
increasingDirection(Coordinate[] pts)
Determines which orientation of the
Coordinate array
is (overall) increasing. |
static int |
indexOf(Coordinate coordinate,
Coordinate[] coordinates)
Returns the index of
coordinate in coordinates . |
static Coordinate[] |
intersection(Coordinate[] coordinates,
Envelope env)
Extracts the coordinates which intersect an
Envelope . |
static boolean |
isRing(Coordinate[] pts)
Tests whether an array of
Coordinate s forms a ring,
by checking length and closure. |
static int |
measures(Coordinate[] pts)
Determine number of measures based on subclass of
Coordinate . |
static Coordinate |
minCoordinate(Coordinate[] coordinates)
Returns the minimum coordinate, using the usual lexicographic comparison.
|
static Coordinate |
ptNotInList(Coordinate[] testPts,
Coordinate[] pts)
Finds a point in a list of points which is not contained in another list of points
|
static Coordinate[] |
removeNull(Coordinate[] coord)
Collapses a coordinate array to remove all null elements.
|
static Coordinate[] |
removeRepeatedOrInvalidPoints(Coordinate[] coord)
If the coordinate array argument has repeated or invalid points,
constructs a new array containing no repeated points.
|
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 void |
scroll(Coordinate[] coordinates,
int indexOfFirstCoordinate)
Shifts the positions of the coordinates until the coordinate
at
firstCoordinate is first. |
static void |
scroll(Coordinate[] coordinates,
int indexOfFirstCoordinate,
boolean ensureRing)
Shifts the positions of the coordinates until the coordinate
at
indexOfFirstCoordinate is first. |
static Coordinate[] |
toCoordinateArray(Collection coordList)
Converts the given Collection of Coordinates into a Coordinate array.
|
public static int dimension(Coordinate[] pts)
Coordinate
.pts
- supplied coordinatespublic static int measures(Coordinate[] pts)
Coordinate
.pts
- supplied coordinatespublic static void enforceConsistency(Coordinate[] array)
Array is modified in place if required, coordinates are replaced in the array as required to ensure all coordinates have the same dimension and measures. The final dimension and measures used are the maximum found when checking the array.
array
- Modified in place to coordinates of consistent dimension and measures.public static Coordinate[] enforceConsistency(Coordinate[] array, int dimension, int measures)
Array is returned unmodified if consistent, or a copy of the array is made with each inconsistent coordinate duplicated into an instance of the correct dimension and measures.
>array
- coordinate arraydimension
- measures
- public static boolean isRing(Coordinate[] pts)
Coordinate
s forms a ring,
by checking length and closure.
Self-intersection is not checked.pts
- an array of Coordinatespublic static Coordinate ptNotInList(Coordinate[] testPts, Coordinate[] pts)
testPts
- the Coordinate
s to testpts
- an array of Coordinate
s to test the input points againstCoordinate
from testPts
which is not in pts
, '
or null
public static int compare(Coordinate[] pts1, Coordinate[] pts2)
Coordinate
arrays
in the forward direction of their coordinates,
using lexicographic ordering.pts1
- pts2
- public static int increasingDirection(Coordinate[] pts)
Coordinate
array
is (overall) increasing.
In other words, determines which end of the array is "smaller"
(using the standard ordering on Coordinate
).
Returns an integer indicating the increasing direction.
If the sequence is a palindrome, it is defined to be
oriented in a positive direction.pts
- the array of Coordinates to test1
if the array is smaller at the start
or is a palindrome,
-1
if smaller at the endpublic static Coordinate[] copyDeep(Coordinate[] coordinates)
Coordinate
array.coordinates
- an array of Coordinatespublic static void copyDeep(Coordinate[] src, int srcStart, Coordinate[] dest, int destStart, int length)
Coordinate
array
into a destination Coordinate array.
The destination array must be an appropriate size to receive
the copied coordinates.src
- an array of CoordinatessrcStart
- the index to start copying fromdest
- thedestStart
- the destination index to start copying tolength
- the number of items to copypublic static Coordinate[] toCoordinateArray(Collection coordList)
public static boolean hasRepeatedPoints(Coordinate[] coord)
Coordinate.equals(Object)
returns true for any two consecutive Coordinates
in the given array.coord
- an array of coordinatespublic static Coordinate[] atLeastNCoordinatesOrNothing(int n, Coordinate[] c)
public static Coordinate[] removeRepeatedPoints(Coordinate[] coord)
coord
- an array of coordinateshasRepeatedPoints(Coordinate[])
public static boolean hasRepeatedOrInvalidPoints(Coordinate[] coord)
coord
- an array of coordinatesCoordinate.isValid()
public static Coordinate[] removeRepeatedOrInvalidPoints(Coordinate[] coord)
coord
- an array of coordinateshasRepeatedOrInvalidPoints(Coordinate[])
,
Coordinate.isValid()
public static Coordinate[] removeNull(Coordinate[] coord)
coord
- the coordinate array to collapsepublic static void reverse(Coordinate[] coord)
public static boolean equals(Coordinate[] coord1, Coordinate[] coord2)
Coordinate.equals(Object)
public static boolean equals(Coordinate[] coord1, Coordinate[] coord2, Comparator coordinateComparator)
Comparator
for Coordinate
scoord1
- an array of Coordinatescoord2
- an array of CoordinatescoordinateComparator
- a Comparator for Coordinatespublic static Coordinate minCoordinate(Coordinate[] coordinates)
coordinates
- the array to searchcompareTo
Coordinate.compareTo(Coordinate)
public static void scroll(Coordinate[] coordinates, Coordinate firstCoordinate)
firstCoordinate
is first.coordinates
- the array to rearrangefirstCoordinate
- the coordinate to make firstpublic static void scroll(Coordinate[] coordinates, int indexOfFirstCoordinate)
firstCoordinate
is first.coordinates
- the array to rearrangeindexOfFirstCoordinate
- the index of the coordinate to make firstpublic static void scroll(Coordinate[] coordinates, int indexOfFirstCoordinate, boolean ensureRing)
indexOfFirstCoordinate
is first.
If ensureRing
is true
, first and last
coordinate of the returned array are equal.coordinates
- the array to rearrangeindexOfFirstCoordinate
- the index of the coordinate to make firstensureRing
- flag indicating if returned array should form a ring.public static int indexOf(Coordinate coordinate, Coordinate[] coordinates)
coordinate
in coordinates
.
The first position is 0; the second, 1; etc.coordinate
- the Coordinate
to search forcoordinates
- the array to searchcoordinate
, or -1 if it is
not foundpublic static Coordinate[] extract(Coordinate[] pts, int start, int end)
Coordinate
array
from indices start
to
end
(inclusive).
The input indices are clamped to the array size;
If the end index is less than the start index,
the extracted array will be empty.pts
- the input arraystart
- the index of the start of the subsequence to extractend
- the index of the end of the subsequence to extractpublic static Envelope envelope(Coordinate[] coordinates)
coordinates
- the coordinates to scanpublic static Coordinate[] intersection(Coordinate[] coordinates, Envelope env)
Envelope
.coordinates
- the coordinates to scanenv
- the envelope to intersect withCopyright © 2024. All rights reserved.