Class CoordinateSequences
Utility functions for manipulating CoordinateSequences.
Inherited Members
Namespace: NetTopologySuite.Geometries
Assembly: NetTopologySuite.dll
Syntax
public static class CoordinateSequences
Methods
| Edit this page View SourceCopy(CoordinateSequence, int, CoordinateSequence, int, int)
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 |
| int | srcPos | The starting index of the coordinates to copy |
| CoordinateSequence | dest | The sequence to which the coordinates should be copied to |
| int | destPos | The starting index of the coordinates in |
| int | length | The number of coordinates to copy |
CopyCoord(CoordinateSequence, int, CoordinateSequence, int)
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 |
| int | srcPos | The index of the coordinate to copy |
| CoordinateSequence | dest | The sequence to which the coordinate should be copied to |
| int | 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, int)
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 sequenceDeclaration
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. |
| int | 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 |
|---|---|
| int | 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 |
|---|---|
| bool |
|
IsEqualAt(CoordinateSequence, int, CoordinateSequence, int)
Tests whether two Coordinates 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 |
| int | pos1 | The index of the |
| CoordinateSequence | seq2 | a CoordinateSequence |
| int | pos2 | The index of the |
Returns
| Type | Description |
|---|---|
| bool |
|
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 |
|---|---|
| bool | True if the sequence is a ring |
See Also
| Edit this page 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 |
|---|---|
| int | The index of the minimum coordinate in the sequence, found using CompareTo(Coordinate) |
MinCoordinateIndex(CoordinateSequence, int, int)
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 |
| int | from | The lower search index |
| int | to | The upper search index |
Returns
| Type | Description |
|---|---|
| int | 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, int)
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 |
| int | indexOfFirstCoordinate | The index of the coordinate to make first |
Scroll(CoordinateSequence, int, bool)
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 |
| int | indexOfFirstCoordinate | The index of the coordinate to make first |
| bool | ensureRing | Makes sure that |
Swap(CoordinateSequence, int, int)
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 |
| int | i | the index of a coordinate to swap |
| int | 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, int, PackedFloatCoordinateSequence, int, int)
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 |
| int | srcPos | The starting index of the coordinates to copy |
| PackedFloatCoordinateSequence | dest | The sequence to which the coordinates should be copied to |
| int | destPos | The starting index of the coordinates in |
| int | length | The number of coordinates to copy |
Returns
| Type | Description |
|---|---|
| bool |