Class CoordinateArrays
- Namespace
- NetTopologySuite.Geometries
- Assembly
- NetTopologySuite.dll
Useful utility functions for handling Coordinate arrays.
public static class CoordinateArrays
- Inheritance
-
CoordinateArrays
- Inherited Members
Methods
AtLeastNCoordinatesOrNothing(int, Coordinate[])
Returns either the given coordinate array if its length is greater than the given amount, or an empty coordinate array.
public static Coordinate[] AtLeastNCoordinatesOrNothing(int n, Coordinate[] c)
Parameters
nintLength amount.
cCoordinate[]Array of Coordinates.
Returns
- Coordinate[]
New Coordinate array.
Compare(Coordinate[], Coordinate[])
Compares two Coordinate arrays in the forward direction of their coordinates, using lexicographic ordering.
public static int Compare(Coordinate[] pts1, Coordinate[] pts2)
Parameters
pts1Coordinate[]pts2Coordinate[]
Returns
CopyDeep(Coordinate[])
Creates a deep copy of the argument Coordinate array.
public static Coordinate[] CopyDeep(Coordinate[] coordinates)
Parameters
coordinatesCoordinate[]Array of Coordinates.
Returns
- Coordinate[]
Deep copy of the input.
CopyDeep(Coordinate[], int, Coordinate[], int, int)
Creates a deep copy of a given section of a source Coordinate array into a destination Coordinate array. The destination array must be an appropriate size to receive the copied coordinates.
public static void CopyDeep(Coordinate[] src, int srcStart, Coordinate[] dest, int destStart, int length)
Parameters
srcCoordinate[]An array of Coordinates
srcStartintThe index to start copying from
destCoordinate[]The array to receive the deep-copied coordinates
destStartintThe destination index to start copying to
lengthintThe number of items to copy
Dimension(Coordinate[])
Determine dimension based on subclass of Coordinate.
public static int Dimension(Coordinate[] pts)
Parameters
ptsCoordinate[]pts supplied coordinates
Returns
- int
number of ordinates recorded
EnforceConsistency(Coordinate[])
Utility method ensuring array contents are of consistent dimension and measures.
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.public static void EnforceConsistency(Coordinate[] array)
Parameters
arrayCoordinate[]Modified in place to coordinates of consistent dimension and measures.
EnforceConsistency(Coordinate[], int, int)
Utility method ensuring array contents are of the specified dimension and 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.public static Coordinate[] EnforceConsistency(Coordinate[] array, int dimension, int measures)
Parameters
arrayCoordinate[]A coordinate array
dimensionintmeasuresint
Returns
- Coordinate[]
Input array or copy created if required to enforce consistency.
Envelope(Coordinate[])
Computes the Envelope(Coordinate[]) of the coordinates.
public static Envelope Envelope(Coordinate[] coordinates)
Parameters
coordinatesCoordinate[]the Coordinate array to scan.
Returns
- Envelope
the Envelope(Coordinate[]) of the
coordinates.
Equals(Coordinate[], Coordinate[])
Returns true if the two arrays are identical, both null, or pointwise
equal (as compared using Coordinate.Equals).
public static bool Equals(Coordinate[] coord1, Coordinate[] coord2)
Parameters
coord1Coordinate[]First array of Coordinates.
coord2Coordinate[]Second array of Coordinates.
Returns
- bool
trueif two Coordinates array are equals; false otherwise
Equals(Coordinate[], Coordinate[], IComparer<Coordinate[]>)
Returns true if the two arrays are identical, both null, or pointwise
equal, using a user-defined IComparer
for Coordinates.
public static bool Equals(Coordinate[] coord1, Coordinate[] coord2, IComparer<Coordinate[]> coordinateComparer)
Parameters
coord1Coordinate[]An array of Coordinates.
coord2Coordinate[]Another array of Coordinates.
coordinateComparerIComparer<Coordinate[]>A IComparer for Coordinates.
Returns
Extract(Coordinate[], int, int)
Extracts a subsequence of the input 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.
public static Coordinate[] Extract(Coordinate[] pts, int start, int end)
Parameters
ptsCoordinate[]The input array.
startintThe index of the start of the subsequence to extract.
endintThe index of the end of the subsequence to extract.
Returns
- Coordinate[]
A subsequence of the input array.
HasRepeatedOrInvalidPoints(Coordinate[])
Tests whether an array has any repeated or invalid coordinates.
public static bool HasRepeatedOrInvalidPoints(Coordinate[] coord)
Parameters
coordCoordinate[]An array of coordinates
Returns
- bool
trueif the array contains repeated or invalid coordinates
HasRepeatedPoints(Coordinate[])
Returns whether Equals(object) returns true for any two consecutive coordinates in the given array.
public static bool HasRepeatedPoints(Coordinate[] coord)
Parameters
coordCoordinate[]An array of
Coordinates.
Returns
- bool
true if coord has repeated points; false otherwise.
IncreasingDirection(Coordinate[])
Determines which orientation of the 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.
public static int IncreasingDirection(Coordinate[] pts)
Parameters
ptsCoordinate[]The array of Coordinates to test.
Returns
- int
1if the array is smaller at the start or is a palindrome,-1if smaller at the end.
IndexOf(Coordinate, Coordinate[])
Returns the index of coordinate in coordinates.
The first position is 0; the second is 1; etc.
public static int IndexOf(Coordinate coordinate, Coordinate[] coordinates)
Parameters
coordinateCoordinateA Coordinate to search for.
coordinatesCoordinate[]A Coordinate array to search.
Returns
- int
The position of
coordinate, or -1 if it is not found.
Intersection(Coordinate[], Envelope)
Extracts the coordinates which intersect an Envelope(Coordinate[]).
public static Coordinate[] Intersection(Coordinate[] coordinates, Envelope env)
Parameters
coordinatesCoordinate[]The coordinates to scan
envEnvelopeThe envelope to intersect with
Returns
- Coordinate[]
An array of coordinates which intersect with the envelope
IsRing(Coordinate[])
Tests whether an array of Coordinates forms a ring, by checking length and closure. Self-intersection is not checked.
public static bool IsRing(Coordinate[] pts)
Parameters
ptsCoordinate[]An array of Coordinates
Returns
- bool
true if the coordinate form a ring.
Measures(Coordinate[])
Determine number of measures based on subclass of Coordinate.
public static int Measures(Coordinate[] pts)
Parameters
ptsCoordinate[]supplied coordinates
Returns
- int
number of measures recorded
MinCoordinate(Coordinate[])
Returns the minimum coordinate, using the usual lexicographic comparison.
public static Coordinate MinCoordinate(Coordinate[] coordinates)
Parameters
coordinatesCoordinate[]Array to search.
Returns
- Coordinate
The minimum coordinate in the array, found using
CompareTo.
PointNotInList(Coordinate[], Coordinate[])
Finds a Coordinate in a list of Coordinates which is not contained in another list of Coordinates.
public static Coordinate PointNotInList(Coordinate[] testPts, Coordinate[] pts)
Parameters
testPtsCoordinate[]The Coordinates to test.
ptsCoordinate[]An array of Coordinates to test the input points against.
Returns
- Coordinate
A Coordinate from
testPtswhich is not inpts, ornull.
RemoveNull(Coordinate[])
Collapses a coordinate array to remove all null elements.
public static Coordinate[] RemoveNull(Coordinate[] coord)
Parameters
coordCoordinate[]The coordinate array to collapse
Returns
- Coordinate[]
An Array containing only non-null elements
RemoveRepeatedOrInvalidPoints(Coordinate[])
If the coordinate array argument has repeated or invalid points, constructs a new array containing no repeated points. Otherwise, returns the argument.
public static Coordinate[] RemoveRepeatedOrInvalidPoints(Coordinate[] coord)
Parameters
coordCoordinate[]An array of coordinates
Returns
- Coordinate[]
The array with repeated or invalid coordinates removed.
RemoveRepeatedPoints(Coordinate[])
If the coordinate array argument has repeated points, constructs a new array containing no repeated points. Otherwise, returns the argument.
public static Coordinate[] RemoveRepeatedPoints(Coordinate[] coord)
Parameters
coordCoordinate[]An array of
Coordinates
Returns
- Coordinate[]
The array with repeated coordinates removed
Reverse(Coordinate[])
Reverses the coordinates in an array in-place.
public static void Reverse(Coordinate[] coord)
Parameters
coordCoordinate[]Array of Coordinates.
Scroll(Coordinate[], Coordinate)
Shifts the positions of the coordinates until firstCoordinate is first.
public static void Scroll(Coordinate[] coordinates, Coordinate firstCoordinate)
Parameters
coordinatesCoordinate[]Array to rearrange.
firstCoordinateCoordinateCoordinate to make first.
Scroll(Coordinate[], int)
Shifts the positions of the coordinates until the coordinate
at indexOfFirstCoordinate is first.
public static void Scroll(Coordinate[] coordinates, int indexOfFirstCoordinate)
Parameters
coordinatesCoordinate[]The array of coordinates to arrange
indexOfFirstCoordinateintThe index of the coordinate to make first
Scroll(Coordinate[], int, bool)
Shifts the positions of the coordinates until the coordinate
at indexOfFirstCoordinate is first.
public static void Scroll(Coordinate[] coordinates, int indexOfFirstCoordinate, bool ensureRing)
Parameters
coordinatesCoordinate[]The array of coordinates to arrange
indexOfFirstCoordinateintThe index of the coordinate to make first
ensureRingboolA flag indicating if returned array should form a ring.
Remarks
If ensureRing is true, first and last
coordinate of the returned array are equal.
ToCoordinateArray(IEnumerable<Coordinate>)
Converts the given IEnumerable<T> of Coordinates into a Coordinate array.
public static Coordinate[] ToCoordinateArray(IEnumerable<Coordinate> coordList)
Parameters
coordListIEnumerable<Coordinate>IEnumerable<T> of coordinates.