Class CoordinateArrays
Useful utility functions for handling Coordinate arrays.
Inherited Members
Namespace: NetTopologySuite.Geometries
Assembly: NetTopologySuite.dll
Syntax
public static class CoordinateArrays
Methods
| Improve this Doc View SourceAtLeastNCoordinatesOrNothing(Int32, Coordinate[])
Returns either the given coordinate array if its length is greater than the given amount, or an empty coordinate array.
Declaration
public static Coordinate[] AtLeastNCoordinatesOrNothing(int n, Coordinate[] c)
Parameters
Type | Name | Description |
---|---|---|
Int32 | n | Length amount. |
Coordinate[] | c | Array of Coordinates. |
Returns
Type | Description |
---|---|
Coordinate[] | New Coordinate array. |
Compare(Coordinate[], Coordinate[])
Compares two Coordinate arrays in the forward direction of their coordinates, using lexicographic ordering.
Declaration
public static int Compare(Coordinate[] pts1, Coordinate[] pts2)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | pts1 | |
Coordinate[] | pts2 |
Returns
Type | Description |
---|---|
Int32 |
CopyDeep(Coordinate[])
Creates a deep copy of the argument Coordinate
array.
Declaration
public static Coordinate[] CopyDeep(Coordinate[] coordinates)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coordinates | Array of Coordinates. |
Returns
Type | Description |
---|---|
Coordinate[] | Deep copy of the input. |
CopyDeep(Coordinate[], Int32, Coordinate[], Int32, Int32)
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.
Declaration
public static void CopyDeep(Coordinate[] src, int srcStart, Coordinate[] dest, int destStart, int length)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | src | An array of Coordinates |
Int32 | srcStart | The index to start copying from |
Coordinate[] | dest | The array to receive the deep-copied coordinates |
Int32 | destStart | The destination index to start copying to |
Int32 | length | The number of items to copy |
Dimension(Coordinate[])
Determine dimension based on subclass of Coordinate.
Declaration
public static int Dimension(Coordinate[] pts)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | pts | pts supplied coordinates |
Returns
Type | Description |
---|---|
Int32 | 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.
Declaration
public static void EnforceConsistency(Coordinate[] array)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | array | Modified in place to coordinates of consistent dimension and measures. |
EnforceConsistency(Coordinate[], Int32, Int32)
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.
Declaration
public static Coordinate[] EnforceConsistency(Coordinate[] array, int dimension, int measures)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | array | A coordinate array |
Int32 | dimension | |
Int32 | measures |
Returns
Type | Description |
---|---|
Coordinate[] | Input array or copy created if required to enforce consistency. |
Envelope(Coordinate[])
Computes the Envelope(Coordinate[]) of the coordinates.
Declaration
public static Envelope Envelope(Coordinate[] coordinates)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coordinates | the Coordinate array to scan. |
Returns
Type | Description |
---|---|
Envelope | the Envelope(Coordinate[]) of the |
Equals(Coordinate[], Coordinate[])
Returns true
if the two arrays are identical, both null
, or pointwise
equal (as compared using Coordinate.Equals).
Declaration
public static bool Equals(Coordinate[] coord1, Coordinate[] coord2)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coord1 | First array of Coordinates. |
Coordinate[] | coord2 | Second array of Coordinates. |
Returns
Type | Description |
---|---|
Boolean |
|
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.
Declaration
public static bool Equals(Coordinate[] coord1, Coordinate[] coord2, IComparer<Coordinate[]> coordinateComparer)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coord1 | An array of Coordinates. |
Coordinate[] | coord2 | Another array of Coordinates. |
IComparer<Coordinate[]> | coordinateComparer | A IComparer for Coordinates. |
Returns
Type | Description |
---|---|
Boolean |
Extract(Coordinate[], Int32, Int32)
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.
Declaration
public static Coordinate[] Extract(Coordinate[] pts, int start, int end)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | pts | The input array. |
Int32 | start | The index of the start of the subsequence to extract. |
Int32 | end | The index of the end of the subsequence to extract. |
Returns
Type | Description |
---|---|
Coordinate[] | A subsequence of the input array. |
HasRepeatedOrInvalidPoints(Coordinate[])
Tests whether an array has any repeated or invalid coordinates.
Declaration
public static bool HasRepeatedOrInvalidPoints(Coordinate[] coord)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coord | An array of coordinates |
Returns
Type | Description |
---|---|
Boolean |
|
HasRepeatedPoints(Coordinate[])
Returns whether Equals(Object) returns true for any two consecutive coordinates in the given array.
Declaration
public static bool HasRepeatedPoints(Coordinate[] coord)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coord | An array of |
Returns
Type | Description |
---|---|
Boolean | 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.
Declaration
public static int IncreasingDirection(Coordinate[] pts)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | pts | The array of Coordinates to test. |
Returns
Type | Description |
---|---|
Int32 |
|
IndexOf(Coordinate, Coordinate[])
Returns the index of coordinate
in coordinates
.
The first position is 0; the second is 1; etc.
Declaration
public static int IndexOf(Coordinate coordinate, Coordinate[] coordinates)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | coordinate | A Coordinate to search for. |
Coordinate[] | coordinates | A Coordinate array to search. |
Returns
Type | Description |
---|---|
Int32 | The position of |
Intersection(Coordinate[], Envelope)
Extracts the coordinates which intersect an Envelope(Coordinate[]).
Declaration
public static Coordinate[] Intersection(Coordinate[] coordinates, Envelope env)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coordinates | The coordinates to scan |
Envelope | env | The envelope to intersect with |
Returns
Type | Description |
---|---|
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.
Declaration
public static bool IsRing(Coordinate[] pts)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | pts | An array of Coordinates |
Returns
Type | Description |
---|---|
Boolean | true if the coordinate form a ring. |
Measures(Coordinate[])
Determine number of measures based on subclass of Coordinate.
Declaration
public static int Measures(Coordinate[] pts)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | pts | supplied coordinates |
Returns
Type | Description |
---|---|
Int32 | number of measures recorded |
MinCoordinate(Coordinate[])
Returns the minimum coordinate, using the usual lexicographic comparison.
Declaration
public static Coordinate MinCoordinate(Coordinate[] coordinates)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coordinates | Array to search. |
Returns
Type | Description |
---|---|
Coordinate | The minimum coordinate in the array, found using |
PointNotInList(Coordinate[], Coordinate[])
Finds a Coordinate in a list of Coordinates which is not contained in another list of Coordinates.
Declaration
public static Coordinate PointNotInList(Coordinate[] testPts, Coordinate[] pts)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | testPts | The Coordinates to test. |
Coordinate[] | pts | An array of Coordinates to test the input points against. |
Returns
Type | Description |
---|---|
Coordinate | A Coordinate from |
RemoveNull(Coordinate[])
Collapses a coordinate array to remove all null elements.
Declaration
public static Coordinate[] RemoveNull(Coordinate[] coord)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coord | The coordinate array to collapse |
Returns
Type | Description |
---|---|
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.
Declaration
public static Coordinate[] RemoveRepeatedOrInvalidPoints(Coordinate[] coord)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coord | An array of coordinates |
Returns
Type | Description |
---|---|
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.
Declaration
public static Coordinate[] RemoveRepeatedPoints(Coordinate[] coord)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coord | An array of |
Returns
Type | Description |
---|---|
Coordinate[] | The array with repeated coordinates removed |
Reverse(Coordinate[])
Reverses the coordinates in an array in-place.
Declaration
public static void Reverse(Coordinate[] coord)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coord | Array of Coordinates. |
Scroll(Coordinate[], Coordinate)
Shifts the positions of the coordinates until firstCoordinate
is first.
Declaration
public static void Scroll(Coordinate[] coordinates, Coordinate firstCoordinate)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coordinates | Array to rearrange. |
Coordinate | firstCoordinate | Coordinate to make first. |
Scroll(Coordinate[], Int32)
Shifts the positions of the coordinates until the coordinate
at indexOfFirstCoordinate
is first.
Declaration
public static void Scroll(Coordinate[] coordinates, int indexOfFirstCoordinate)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coordinates | The array of coordinates to arrange |
Int32 | indexOfFirstCoordinate | The index of the coordinate to make first |
Scroll(Coordinate[], Int32, Boolean)
Shifts the positions of the coordinates until the coordinate
at indexOfFirstCoordinate
is first.
Declaration
public static void Scroll(Coordinate[] coordinates, int indexOfFirstCoordinate, bool ensureRing)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | coordinates | The array of coordinates to arrange |
Int32 | indexOfFirstCoordinate | The index of the coordinate to make first |
Boolean | ensureRing | A 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.
Declaration
public static Coordinate[] ToCoordinateArray(IEnumerable<Coordinate> coordList)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Coordinate> | coordList | IEnumerable<T> of coordinates. |
Returns
Type | Description |
---|---|
Coordinate[] |