Class CoordinateSequences
Utility functions for manipulating CoordinateSequences.
Inherited Members
Namespace: NetTopologySuite.Geometries
Assembly: NetTopologySuite.dll
Syntax
public static class CoordinateSequences
Methods
| Improve this Doc View SourceCopy(CoordinateSequence, Int32, CoordinateSequence, Int32, Int32)
Copies a section of a CoordinateSequence to another CoordinateSequence. The sequences may have different dimensions; in this case only the common dimensions are copied.
Declaration
public static void Copy(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos, int length)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | src | The sequence to copy coordinates from |
Int32 | srcPos | The starting index of the coordinates to copy |
CoordinateSequence | dest | The sequence to which the coordinates should be copied to |
Int32 | destPos | The starting index of the coordinates in |
Int32 | length | The number of coordinates to copy |
CopyCoord(CoordinateSequence, Int32, CoordinateSequence, Int32)
Copies a coordinate of a CoordinateSequence to another CoordinateSequence. The sequences may have different dimensions; in this case only the common dimensions are copied.
Declaration
public static void CopyCoord(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | src | The sequence to copy coordinate from |
Int32 | srcPos | The index of the coordinate to copy |
CoordinateSequence | dest | The sequence to which the coordinate should be copied to |
Int32 | destPos | The index of the coordinate in |
EnsureValidRing(CoordinateSequenceFactory, CoordinateSequence)
Ensures that a CoordinateSequence forms a valid ring, returning a new closed sequence of the correct length if required. If the input sequence is already a valid ring, it is returned without modification. If the input sequence is too short or is not closed, it is extended with one or more copies of the start point.
Declaration
public static CoordinateSequence EnsureValidRing(CoordinateSequenceFactory fact, CoordinateSequence seq)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequenceFactory | fact | The CoordinateSequenceFactory to use to create the new sequence |
CoordinateSequence | seq | The sequence to test |
Returns
Type | Description |
---|---|
CoordinateSequence | The original sequence, if it was a valid ring, or a new sequence which is valid. |
Extend(CoordinateSequenceFactory, CoordinateSequence, Int32)
Extends a given CoordinateSequence.
Because coordinate sequences are fix in size, extending is done by creating a new coordinate sequence of the requested size.
The new, trailing coordinate entries (if any) are filled with the last coordinate of the input sequence
Declaration
public static CoordinateSequence Extend(CoordinateSequenceFactory fact, CoordinateSequence seq, int size)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequenceFactory | fact | The factory to use when creating the new sequence. |
CoordinateSequence | seq | The sequence to extend. |
Int32 | size | The required size of the extended sequence |
Returns
Type | Description |
---|---|
CoordinateSequence | The extended sequence |
IndexOf(Coordinate, CoordinateSequence)
Returns the index of coordinate
in a CoordinateSequence
The first position is 0; the second, 1; etc.
Declaration
public static int IndexOf(Coordinate coordinate, CoordinateSequence seq)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | coordinate | The |
CoordinateSequence | seq | The coordinate sequence to search |
Returns
Type | Description |
---|---|
Int32 | The position of |
IsEqual(CoordinateSequence, CoordinateSequence)
Tests whether two CoordinateSequences are equal.
To be equal, the sequences must be the same length.
They do not need to be of the same dimension,
but the ordinate values for the smallest dimension of the two
must be equal.
Two NaN
ordinates values are considered to be equal.
Declaration
public static bool IsEqual(CoordinateSequence seq1, CoordinateSequence seq2)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | seq1 | a CoordinateSequence |
CoordinateSequence | seq2 | a CoordinateSequence |
Returns
Type | Description |
---|---|
Boolean |
|
IsEqualAt(CoordinateSequence, Int32, CoordinateSequence, Int32)
Tests whether two Coordinate
s CoordinateSequences are equal.
They do not need to be of the same dimension,
but the ordinate values for the common ordinates of the two
must be equal.
Two NaN
ordinates values are considered to be equal.
Declaration
public static bool IsEqualAt(CoordinateSequence seq1, int pos1, CoordinateSequence seq2, int pos2)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | seq1 | A CoordinateSequence |
Int32 | pos1 | The index of the |
CoordinateSequence | seq2 | a CoordinateSequence |
Int32 | pos2 | The index of the |
Returns
Type | Description |
---|---|
Boolean |
|
IsRing(CoordinateSequence)
Tests whether a CoordinateSequence forms a valid LinearRing, by checking the sequence length and closure (whether the first and last points are identical in 2D). Self-intersection is not checked.
Declaration
public static bool IsRing(CoordinateSequence seq)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | seq | The sequence to test |
Returns
Type | Description |
---|---|
Boolean | True if the sequence is a ring |
See Also
| Improve this Doc View SourceMinCoordinate(CoordinateSequence)
Returns the minimum coordinate, using the usual lexicographic comparison.
Declaration
public static Coordinate MinCoordinate(CoordinateSequence seq)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | seq | The coordinate sequence to search |
Returns
Type | Description |
---|---|
Coordinate | The minimum coordinate in the sequence, found using CompareTo(Coordinate) |
MinCoordinateIndex(CoordinateSequence)
Returns the index of the minimum coordinate of the whole coordinate sequence, using the usual lexicographic comparison.
Declaration
public static int MinCoordinateIndex(CoordinateSequence seq)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | seq | The coordinate sequence to search |
Returns
Type | Description |
---|---|
Int32 | The index of the minimum coordinate in the sequence, found using CompareTo(Coordinate) |
MinCoordinateIndex(CoordinateSequence, Int32, Int32)
Returns the index of the minimum coordinate of a part of
the coordinate sequence (defined by from
and to
), using the usual lexicographic
comparison.
Declaration
public static int MinCoordinateIndex(CoordinateSequence seq, int from, int to)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | seq | The coordinate sequence to search |
Int32 | from | The lower search index |
Int32 | to | The upper search index |
Returns
Type | Description |
---|---|
Int32 | The index of the minimum coordinate in the sequence, found using CompareTo(Coordinate) |
Reverse(CoordinateSequence)
Reverses the coordinates in a sequence in-place.
Declaration
public static void Reverse(CoordinateSequence seq)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | seq | The coordinate sequence to reverse. |
Scroll(CoordinateSequence, Coordinate)
Shifts the positions of the coordinates until firstCoordinate
is first.
Declaration
public static void Scroll(CoordinateSequence seq, Coordinate firstCoordinate)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | seq | The coordinate sequence to rearrange |
Coordinate | firstCoordinate | The coordinate to make first"> |
Scroll(CoordinateSequence, Int32)
Shifts the positions of the coordinates until the coordinate at firstCoordinateIndex
is first.
Declaration
public static void Scroll(CoordinateSequence seq, int indexOfFirstCoordinate)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | seq | The coordinate sequence to rearrange |
Int32 | indexOfFirstCoordinate | The index of the coordinate to make first |
Scroll(CoordinateSequence, Int32, Boolean)
Shifts the positions of the coordinates until the coordinate at firstCoordinateIndex
is first.
Declaration
public static void Scroll(CoordinateSequence seq, int indexOfFirstCoordinate, bool ensureRing)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | seq | The coordinate sequence to rearrange |
Int32 | indexOfFirstCoordinate | The index of the coordinate to make first |
Boolean | ensureRing | Makes sure that |
Swap(CoordinateSequence, Int32, Int32)
Swaps two coordinates in a sequence.
Declaration
public static void Swap(CoordinateSequence seq, int i, int j)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | seq | seq the sequence to modify |
Int32 | i | the index of a coordinate to swap |
Int32 | j | the index of a coordinate to swap |
ToString(CoordinateSequence)
Creates a string representation of a CoordinateSequence. The format is:
( ord0,ord1.. ord0,ord1,... ... )
Declaration
public static string ToString(CoordinateSequence cs)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | cs | the sequence to output |
Returns
Type | Description |
---|---|
String | the string representation of the sequence |
TryRawCopy(PackedFloatCoordinateSequence, Int32, PackedFloatCoordinateSequence, Int32, Int32)
Copies a section of a PackedFloatCoordinateSequence to another PackedFloatCoordinateSequence. The sequences must have same dimensions.
Declaration
public static bool TryRawCopy(PackedFloatCoordinateSequence src, int srcPos, PackedFloatCoordinateSequence dest, int destPos, int length)
Parameters
Type | Name | Description |
---|---|---|
PackedFloatCoordinateSequence | src | The sequence to copy coordinates from |
Int32 | srcPos | The starting index of the coordinates to copy |
PackedFloatCoordinateSequence | dest | The sequence to which the coordinates should be copied to |
Int32 | destPos | The starting index of the coordinates in |
Int32 | length | The number of coordinates to copy |
Returns
Type | Description |
---|---|
Boolean |