Class CoordinateSequences
- Namespace
- NetTopologySuite.Geometries
- Assembly
- NetTopologySuite.dll
Utility functions for manipulating CoordinateSequences.
public static class CoordinateSequences
- Inheritance
-
CoordinateSequences
- Inherited Members
Methods
Copy(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.
public static void Copy(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos, int length)
Parameters
src
CoordinateSequenceThe sequence to copy coordinates from
srcPos
intThe starting index of the coordinates to copy
dest
CoordinateSequenceThe sequence to which the coordinates should be copied to
destPos
intThe starting index of the coordinates in
length
intThe 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.
public static void CopyCoord(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos)
Parameters
src
CoordinateSequenceThe sequence to copy coordinate from
srcPos
intThe index of the coordinate to copy
dest
CoordinateSequenceThe sequence to which the coordinate should be copied to
destPos
intThe 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.
public static CoordinateSequence EnsureValidRing(CoordinateSequenceFactory fact, CoordinateSequence seq)
Parameters
fact
CoordinateSequenceFactoryThe CoordinateSequenceFactory to use to create the new sequence
seq
CoordinateSequenceThe sequence to test
Returns
- 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 sequencepublic static CoordinateSequence Extend(CoordinateSequenceFactory fact, CoordinateSequence seq, int size)
Parameters
fact
CoordinateSequenceFactoryThe factory to use when creating the new sequence.
seq
CoordinateSequenceThe sequence to extend.
size
intThe required size of the extended sequence
Returns
- CoordinateSequence
The extended sequence
IndexOf(Coordinate, CoordinateSequence)
Returns the index of coordinate
in a CoordinateSequence
The first position is 0; the second, 1; etc.
public static int IndexOf(Coordinate coordinate, CoordinateSequence seq)
Parameters
coordinate
CoordinateThe
Coordinate
to search forseq
CoordinateSequenceThe coordinate sequence to search
Returns
- int
The position of
coordinate
, or -1 if it is not found
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.
public static bool IsEqual(CoordinateSequence seq1, CoordinateSequence seq2)
Parameters
seq1
CoordinateSequencea CoordinateSequence
seq2
CoordinateSequencea CoordinateSequence
Returns
- bool
true
if the sequences are equal in the common dimensions
IsEqualAt(CoordinateSequence, int, CoordinateSequence, int)
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.
public static bool IsEqualAt(CoordinateSequence seq1, int pos1, CoordinateSequence seq2, int pos2)
Parameters
seq1
CoordinateSequenceA CoordinateSequence
pos1
intThe index of the
Coordinate
inseq1
.seq2
CoordinateSequencea CoordinateSequence
pos2
intThe index of the
Coordinate
inseq2
.
Returns
- bool
true
if the sequences are equal in the common dimensions
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.
public static bool IsRing(CoordinateSequence seq)
Parameters
seq
CoordinateSequenceThe sequence to test
Returns
- bool
True if the sequence is a ring
- See Also
MinCoordinate(CoordinateSequence)
Returns the minimum coordinate, using the usual lexicographic comparison.
public static Coordinate MinCoordinate(CoordinateSequence seq)
Parameters
seq
CoordinateSequenceThe coordinate sequence to search
Returns
- 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.
public static int MinCoordinateIndex(CoordinateSequence seq)
Parameters
seq
CoordinateSequenceThe coordinate sequence to search
Returns
- 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.
public static int MinCoordinateIndex(CoordinateSequence seq, int from, int to)
Parameters
seq
CoordinateSequenceThe coordinate sequence to search
from
intThe lower search index
to
intThe upper search index
Returns
- int
The index of the minimum coordinate in the sequence, found using CompareTo(Coordinate)
Reverse(CoordinateSequence)
Reverses the coordinates in a sequence in-place.
public static void Reverse(CoordinateSequence seq)
Parameters
seq
CoordinateSequenceThe coordinate sequence to reverse.
Scroll(CoordinateSequence, Coordinate)
Shifts the positions of the coordinates until firstCoordinate
is first.
public static void Scroll(CoordinateSequence seq, Coordinate firstCoordinate)
Parameters
seq
CoordinateSequenceThe coordinate sequence to rearrange
firstCoordinate
CoordinateThe coordinate to make first">
Scroll(CoordinateSequence, int)
Shifts the positions of the coordinates until the coordinate at firstCoordinateIndex
is first.
public static void Scroll(CoordinateSequence seq, int indexOfFirstCoordinate)
Parameters
seq
CoordinateSequenceThe coordinate sequence to rearrange
indexOfFirstCoordinate
intThe index of the coordinate to make first
Scroll(CoordinateSequence, int, bool)
Shifts the positions of the coordinates until the coordinate at firstCoordinateIndex
is first.
public static void Scroll(CoordinateSequence seq, int indexOfFirstCoordinate, bool ensureRing)
Parameters
seq
CoordinateSequenceThe coordinate sequence to rearrange
indexOfFirstCoordinate
intThe index of the coordinate to make first
ensureRing
boolMakes sure that
seq
will be a closed ring upon exit
Swap(CoordinateSequence, int, int)
Swaps two coordinates in a sequence.
public static void Swap(CoordinateSequence seq, int i, int j)
Parameters
seq
CoordinateSequenceseq the sequence to modify
i
intthe index of a coordinate to swap
j
intthe index of a coordinate to swap
ToString(CoordinateSequence)
Creates a string representation of a CoordinateSequence. The format is:
( ord0,ord1.. ord0,ord1,... ... )
public static string ToString(CoordinateSequence cs)
Parameters
cs
CoordinateSequencethe sequence to output
Returns
- 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.
public static bool TryRawCopy(PackedFloatCoordinateSequence src, int srcPos, PackedFloatCoordinateSequence dest, int destPos, int length)
Parameters
src
PackedFloatCoordinateSequenceThe sequence to copy coordinates from
srcPos
intThe starting index of the coordinates to copy
dest
PackedFloatCoordinateSequenceThe sequence to which the coordinates should be copied to
destPos
intThe starting index of the coordinates in
length
intThe number of coordinates to copy