Table of Contents

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 CoordinateSequence

The sequence to copy coordinates from

srcPos int

The starting index of the coordinates to copy

dest CoordinateSequence

The sequence to which the coordinates should be copied to

destPos int

The starting index of the coordinates in

length int

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.

public static void CopyCoord(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos)

Parameters

src CoordinateSequence

The sequence to copy coordinate from

srcPos int

The index of the coordinate to copy

dest CoordinateSequence

The sequence to which the coordinate should be copied to

destPos int

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.

public static CoordinateSequence EnsureValidRing(CoordinateSequenceFactory fact, CoordinateSequence seq)

Parameters

fact CoordinateSequenceFactory

The CoordinateSequenceFactory to use to create the new sequence

seq CoordinateSequence

The 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 sequence
public static CoordinateSequence Extend(CoordinateSequenceFactory fact, CoordinateSequence seq, int size)

Parameters

fact CoordinateSequenceFactory

The factory to use when creating the new sequence.

seq CoordinateSequence

The sequence to extend.

size int

The 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 Coordinate

The Coordinate to search for

seq CoordinateSequence

The 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 CoordinateSequence

a CoordinateSequence

seq2 CoordinateSequence

a CoordinateSequence

Returns

bool

true if 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

seq1 CoordinateSequence

A CoordinateSequence

pos1 int

The index of the Coordinate in seq1.

seq2 CoordinateSequence

a CoordinateSequence

pos2 int

The index of the Coordinate in seq2.

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 CoordinateSequence

The 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 CoordinateSequence

The 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 CoordinateSequence

The 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 CoordinateSequence

The coordinate sequence to search

from int

The lower search index

to int

The 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 CoordinateSequence

The 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 CoordinateSequence

The coordinate sequence to rearrange

firstCoordinate Coordinate

The 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 CoordinateSequence

The coordinate sequence to rearrange

indexOfFirstCoordinate int

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.

public static void Scroll(CoordinateSequence seq, int indexOfFirstCoordinate, bool ensureRing)

Parameters

seq CoordinateSequence

The coordinate sequence to rearrange

indexOfFirstCoordinate int

The index of the coordinate to make first

ensureRing bool

Makes 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 CoordinateSequence

seq the sequence to modify

i int

the index of a coordinate to swap

j int

the 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 CoordinateSequence

the 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 PackedFloatCoordinateSequence

The sequence to copy coordinates from

srcPos int

The starting index of the coordinates to copy

dest PackedFloatCoordinateSequence

The sequence to which the coordinates should be copied to

destPos int

The starting index of the coordinates in

length int

The number of coordinates to copy

Returns

bool