public class CoordinateSequences extends Object
CoordinateSequence
sConstructor and Description |
---|
CoordinateSequences() |
Modifier and Type | Method and Description |
---|---|
static void |
copy(CoordinateSequence src,
int srcPos,
CoordinateSequence dest,
int destPos,
int length)
Copies a section of a
CoordinateSequence to another CoordinateSequence . |
static void |
copyCoord(CoordinateSequence src,
int srcPos,
CoordinateSequence dest,
int destPos)
Copies a coordinate of a
CoordinateSequence to another CoordinateSequence . |
static CoordinateSequence |
ensureValidRing(CoordinateSequenceFactory fact,
CoordinateSequence seq)
Ensures that a CoordinateSequence forms a valid ring,
returning a new closed sequence of the correct length if required.
|
static CoordinateSequence |
extend(CoordinateSequenceFactory fact,
CoordinateSequence seq,
int size) |
static int |
indexOf(Coordinate coordinate,
CoordinateSequence seq)
Returns the index of
coordinate in a CoordinateSequence
The first position is 0; the second, 1; etc. |
static boolean |
isEqual(CoordinateSequence cs1,
CoordinateSequence cs2)
Tests whether two
CoordinateSequence s are equal. |
static boolean |
isRing(CoordinateSequence seq)
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). |
static Coordinate |
minCoordinate(CoordinateSequence seq)
Returns the minimum coordinate, using the usual lexicographic comparison.
|
static int |
minCoordinateIndex(CoordinateSequence seq)
Returns the index of the minimum coordinate of the whole
coordinate sequence, using the usual lexicographic comparison.
|
static int |
minCoordinateIndex(CoordinateSequence seq,
int from,
int to)
Returns the index of the minimum coordinate of a part of
the coordinate sequence (defined by
from and to ,
using the usual lexicographic comparison. |
static void |
reverse(CoordinateSequence seq)
Reverses the coordinates in a sequence in-place.
|
static void |
scroll(CoordinateSequence seq,
Coordinate firstCoordinate)
Shifts the positions of the coordinates until
firstCoordinate
is first. |
static void |
scroll(CoordinateSequence seq,
int indexOfFirstCoordinate)
Shifts the positions of the coordinates until the coordinate at
firstCoordinateIndex
is first. |
static void |
scroll(CoordinateSequence seq,
int indexOfFirstCoordinate,
boolean ensureRing)
Shifts the positions of the coordinates until the coordinate at
firstCoordinateIndex
is first. |
static void |
swap(CoordinateSequence seq,
int i,
int j)
Swaps two coordinates in a sequence.
|
static String |
toString(CoordinateSequence cs)
Creates a string representation of a
CoordinateSequence . |
public static void reverse(CoordinateSequence seq)
seq
- the coordinate sequence to reversepublic static void swap(CoordinateSequence seq, int i, int j)
seq
- the sequence to modifyi
- the index of a coordinate to swapj
- the index of a coordinate to swappublic static void copy(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos, int length)
CoordinateSequence
to another CoordinateSequence
.
The sequences may have different dimensions;
in this case only the common dimensions are copied.src
- the sequence to copy fromsrcPos
- the position in the source sequence to start copying atdest
- the sequence to copy todestPos
- the position in the destination sequence to copy tolength
- the number of coordinates to copypublic static void copyCoord(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos)
CoordinateSequence
to another CoordinateSequence
.
The sequences may have different dimensions;
in this case only the common dimensions are copied.src
- the sequence to copy fromsrcPos
- the source coordinate to copydest
- the sequence to copy todestPos
- the destination coordinate to copy topublic static boolean isRing(CoordinateSequence seq)
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.seq
- the sequence to testLinearRing
public static CoordinateSequence ensureValidRing(CoordinateSequenceFactory fact, CoordinateSequence seq)
fact
- the CoordinateSequenceFactory to use to create the new sequenceseq
- the sequence to testpublic static CoordinateSequence extend(CoordinateSequenceFactory fact, CoordinateSequence seq, int size)
public static boolean isEqual(CoordinateSequence cs1, CoordinateSequence cs2)
CoordinateSequence
s 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.cs1
- a CoordinateSequencecs2
- a CoordinateSequencepublic static String toString(CoordinateSequence cs)
CoordinateSequence
.
The format is:
( ord0,ord1.. ord0,ord1,... ... )
cs
- the sequence to outputpublic static Coordinate minCoordinate(CoordinateSequence seq)
seq
- the coordinate sequence to searchcompareTo
Comparable.compareTo(Object)
public static int minCoordinateIndex(CoordinateSequence seq)
seq
- the coordinate sequence to searchcompareTo
Comparable.compareTo(Object)
public static int minCoordinateIndex(CoordinateSequence seq, int from, int to)
from
and to
,
using the usual lexicographic comparison.seq
- the coordinate sequence to searchfrom
- the lower search indexto
- the upper search indexcompareTo
Comparable.compareTo(Object)
public static void scroll(CoordinateSequence seq, Coordinate firstCoordinate)
firstCoordinate
is first.seq
- the coordinate sequence to rearrangefirstCoordinate
- the coordinate to make firstpublic static void scroll(CoordinateSequence seq, int indexOfFirstCoordinate)
firstCoordinateIndex
is first.seq
- the coordinate sequence to rearrangeindexOfFirstCoordinate
- the index of the coordinate to make firstpublic static void scroll(CoordinateSequence seq, int indexOfFirstCoordinate, boolean ensureRing)
firstCoordinateIndex
is first.seq
- the coordinate sequence to rearrangeindexOfFirstCoordinate
- the index of the coordinate to make firstensureRing
- makes sure that will be a closed ring upon exitpublic static int indexOf(Coordinate coordinate, CoordinateSequence seq)
coordinate
in a CoordinateSequence
The first position is 0; the second, 1; etc.coordinate
- the Coordinate
to search forseq
- the coordinate sequence to searchcoordinate
, or -1 if it is
not foundCopyright © 2022. All rights reserved.