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
srcCoordinateSequenceThe sequence to copy coordinates from
srcPosintThe starting index of the coordinates to copy
destCoordinateSequenceThe sequence to which the coordinates should be copied to
destPosintThe starting index of the coordinates in
lengthintThe 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
srcCoordinateSequenceThe sequence to copy coordinate from
srcPosintThe index of the coordinate to copy
destCoordinateSequenceThe sequence to which the coordinate should be copied to
destPosintThe 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
factCoordinateSequenceFactoryThe CoordinateSequenceFactory to use to create the new sequence
seqCoordinateSequenceThe 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
factCoordinateSequenceFactoryThe factory to use when creating the new sequence.
seqCoordinateSequenceThe sequence to extend.
sizeintThe 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
coordinateCoordinateThe
Coordinateto search forseqCoordinateSequenceThe 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
seq1CoordinateSequencea CoordinateSequence
seq2CoordinateSequencea CoordinateSequence
Returns
- bool
trueif the sequences are equal in the common dimensions
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.
public static bool IsEqualAt(CoordinateSequence seq1, int pos1, CoordinateSequence seq2, int pos2)
Parameters
seq1CoordinateSequenceA CoordinateSequence
pos1intThe index of the
Coordinateinseq1.seq2CoordinateSequencea CoordinateSequence
pos2intThe index of the
Coordinateinseq2.
Returns
- bool
trueif 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
seqCoordinateSequenceThe 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
seqCoordinateSequenceThe 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
seqCoordinateSequenceThe 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
seqCoordinateSequenceThe coordinate sequence to search
fromintThe lower search index
tointThe 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
seqCoordinateSequenceThe 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
seqCoordinateSequenceThe coordinate sequence to rearrange
firstCoordinateCoordinateThe 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
seqCoordinateSequenceThe coordinate sequence to rearrange
indexOfFirstCoordinateintThe 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
seqCoordinateSequenceThe coordinate sequence to rearrange
indexOfFirstCoordinateintThe index of the coordinate to make first
ensureRingboolMakes sure that
seqwill 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
seqCoordinateSequenceseq the sequence to modify
iintthe index of a coordinate to swap
jintthe 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
csCoordinateSequencethe 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
srcPackedFloatCoordinateSequenceThe sequence to copy coordinates from
srcPosintThe starting index of the coordinates to copy
destPackedFloatCoordinateSequenceThe sequence to which the coordinates should be copied to
destPosintThe starting index of the coordinates in
lengthintThe number of coordinates to copy