Package org.locationtech.jts.geom
Class CoordinateSequences
java.lang.Object
org.locationtech.jts.geom.CoordinateSequences
Utility functions for manipulating
CoordinateSequence
s- Version:
- 1.7
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
copy
(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos, int length) Copies a section of aCoordinateSequence
to anotherCoordinateSequence
.static void
copyCoord
(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos) Copies a coordinate of aCoordinateSequence
to anotherCoordinateSequence
.private static CoordinateSequence
createClosedRing
(CoordinateSequenceFactory fact, CoordinateSequence seq, int size) static CoordinateSequence
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 boolean
isEqual
(CoordinateSequence cs1, CoordinateSequence cs2) Tests whether twoCoordinateSequence
s are equal.static boolean
isRing
(CoordinateSequence seq) Tests whether aCoordinateSequence
forms a validLinearRing
, by checking the sequence length and closure (whether the first and last points are identical in 2D).static void
Reverses the coordinates in a sequence in-place.static void
swap
(CoordinateSequence seq, int i, int j) Swaps two coordinates in a sequence.static String
Creates a string representation of aCoordinateSequence
.
-
Constructor Details
-
CoordinateSequences
public CoordinateSequences()
-
-
Method Details
-
reverse
Reverses the coordinates in a sequence in-place. -
swap
Swaps two coordinates in a sequence.- Parameters:
seq
- the sequence to modifyi
- the index of a coordinate to swapj
- the index of a coordinate to swap
-
copy
public static void copy(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos, int length) Copies a section of aCoordinateSequence
to anotherCoordinateSequence
. The sequences may have different dimensions; in this case only the common dimensions are copied.- Parameters:
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 copy
-
copyCoord
public static void copyCoord(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos) Copies a coordinate of aCoordinateSequence
to anotherCoordinateSequence
. The sequences may have different dimensions; in this case only the common dimensions are copied.- Parameters:
src
- the sequence to copy fromsrcPos
- the source coordinate to copydest
- the sequence to copy todestPos
- the destination coordinate to copy to
-
isRing
Tests whether aCoordinateSequence
forms a validLinearRing
, by checking the sequence length and closure (whether the first and last points are identical in 2D). Self-intersection is not checked.- Parameters:
seq
- the sequence to test- Returns:
- true if the sequence is a ring
- See Also:
-
ensureValidRing
public 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. 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.- Parameters:
fact
- the CoordinateSequenceFactory to use to create the new sequenceseq
- the sequence to test- Returns:
- the original sequence, if it was a valid ring, or a new sequence which is valid.
-
createClosedRing
private static CoordinateSequence createClosedRing(CoordinateSequenceFactory fact, CoordinateSequence seq, int size) -
extend
public static CoordinateSequence extend(CoordinateSequenceFactory fact, CoordinateSequence seq, int size) -
isEqual
Tests whether twoCoordinateSequence
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. TwoNaN
ordinates values are considered to be equal.- Parameters:
cs1
- a CoordinateSequencecs2
- a CoordinateSequence- Returns:
- true if the sequences are equal in the common dimensions
-
toString
Creates a string representation of aCoordinateSequence
. The format is:( ord0,ord1.. ord0,ord1,... ... )
- Parameters:
cs
- the sequence to output- Returns:
- the string representation of the sequence
-