public interface CoordinateSequence extends Cloneable
This allows Geometries to store their
points using something other than the JTS Coordinate
class.
For example, a storage-efficient implementation
might store coordinate sequences as an array of x's
and an array of y's.
Or a custom coordinate class might support extra attributes like M-values.
Implementing a custom coordinate storage structure
requires implementing the CoordinateSequence
and
CoordinateSequenceFactory
interfaces.
To use the custom CoordinateSequence, create a
new GeometryFactory
parameterized by the CoordinateSequenceFactory
The GeometryFactory
can then be used to create new Geometry
s.
The new Geometries
will use the custom CoordinateSequence implementation.
For an example, see the code for ExtendedCoordinateExample.
CoordinateArraySequenceFactory
,
PackedCoordinateSequenceFactory
Modifier and Type | Field and Description |
---|---|
static int |
M
Standard ordinate index value for, where M is 3.
|
static int |
X
Standard ordinate index value for, where X is 0
|
static int |
Y
Standard ordinate index value for, where Y is 1
|
static int |
Z
Standard z-ordinate index
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Deprecated.
Recommend
copy() |
CoordinateSequence |
copy()
Returns a deep copy of this collection.
|
default Coordinate |
createCoordinate()
Creates a coordinate for use in this sequence.
|
Envelope |
expandEnvelope(Envelope env)
Expands the given
Envelope to include the coordinates in the sequence. |
Coordinate |
getCoordinate(int i)
Returns (possibly a copy of) the i'th coordinate in this sequence.
|
void |
getCoordinate(int index,
Coordinate coord)
Copies the i'th coordinate in the sequence to the supplied
Coordinate . |
Coordinate |
getCoordinateCopy(int i)
Returns a copy of the i'th coordinate in this sequence.
|
int |
getDimension()
Returns the dimension (number of ordinates in each coordinate) for this sequence.
|
default double |
getM(int index)
Returns ordinate M of the specified coordinate if available.
|
default int |
getMeasures()
Returns the number of measures included in
getDimension() for each coordinate for this
sequence. |
double |
getOrdinate(int index,
int ordinateIndex)
Returns the ordinate of a coordinate in this sequence.
|
double |
getX(int index)
Returns ordinate X (0) of the specified coordinate.
|
double |
getY(int index)
Returns ordinate Y (1) of the specified coordinate.
|
default double |
getZ(int index)
Returns ordinate Z of the specified coordinate if available.
|
default boolean |
hasM()
Tests whether the coordinates in the sequence have measures associated with them.
|
default boolean |
hasZ()
|
void |
setOrdinate(int index,
int ordinateIndex,
double value)
Sets the value for a given ordinate of a coordinate in this sequence.
|
int |
size()
Returns the number of coordinates in this sequence.
|
Coordinate[] |
toCoordinateArray()
Returns (possibly copies of) the Coordinates in this collection.
|
static final int X
static final int Y
static final int Z
static final int M
This constant assumes XYZM coordinate sequence definition, please check this assumption
using getDimension()
and getMeasures()
before use.
int getDimension()
This total includes any measures, indicated by non-zero getMeasures()
.
default int getMeasures()
getDimension()
for each coordinate for this
sequence.
For a measured coordinate sequence a non-zero value is returned.
default boolean hasZ()
getZ(int)
is supported.default boolean hasM()
getMeasures()
> 0
. See getMeasures()
to determine the number of measures
present.getM(int)
is supported.getMeasures()
,
getM(int)
default Coordinate createCoordinate()
The coordinate is created supporting the same number of getDimension()
and getMeasures()
as this sequence and is suitable for use with getCoordinate(int, Coordinate)
.
Coordinate getCoordinate(int i)
Note that in the future the semantics of this method may change to guarantee that the Coordinate returned is always a copy. Callers should not to assume that they can modify a CoordinateSequence by modifying the object returned by this method.
i
- the index of the coordinate to retrieveCoordinate getCoordinateCopy(int i)
i
- the index of the coordinate to retrievevoid getCoordinate(int index, Coordinate coord)
Coordinate
. Only the first two dimensions are copied.index
- the index of the coordinate to copycoord
- a Coordinate
to receive the valuedouble getX(int index)
index
- the coordinate index in the sequencedouble getY(int index)
index
- the coordinate index in the sequencedefault double getZ(int index)
index
- the coordinate index in the sequencedefault double getM(int index)
index
- the coordinate index in the sequencedouble getOrdinate(int index, int ordinateIndex)
Ordinates indices greater than 1 have user-defined semantics
(for instance, they may contain other dimensions or measure
values as described by getDimension()
and getMeasures()
).
index
- the coordinate index in the sequenceordinateIndex
- the ordinate index in the coordinate (in range [0, dimension-1])int size()
void setOrdinate(int index, int ordinateIndex, double value)
index
- the coordinate index in the sequenceordinateIndex
- the ordinate index in the coordinate (in range [0, dimension-1])value
- the new ordinate valueCoordinate[] toCoordinateArray()
Envelope expandEnvelope(Envelope env)
Envelope
to include the coordinates in the sequence.
Allows implementing classes to optimize access to coordinate values.env
- the envelope to expandObject clone()
copy()
CoordinateSequence copy()
Copyright © 2024. All rights reserved.