Interface CoordinateSequence
- All Superinterfaces:
Cloneable
- All Known Implementing Classes:
AxisPlaneCoordinateSequence
,CoordinateArraySequence
,ExtendedCoordinateSequence
,PackedCoordinateSequence
,PackedCoordinateSequence.Double
,PackedCoordinateSequence.Float
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.
- Version:
- 1.7
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionclone()
Deprecated.copy()
Returns a deep copy of this collection.default Coordinate
Creates a coordinate for use in this sequence.expandEnvelope
(Envelope env) Expands the givenEnvelope
to include the coordinates in the sequence.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 suppliedCoordinate
.getCoordinateCopy
(int i) Returns a copy of the i'th coordinate in this sequence.int
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
Returns the number of measures included ingetDimension()
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.Returns (possibly copies of) the Coordinates in this collection.
-
Field Details
-
X
static final int XStandard ordinate index value for, where X is 0- See Also:
-
Y
static final int YStandard ordinate index value for, where Y is 1- See Also:
-
Z
static final int ZStandard z-ordinate index- See Also:
-
M
static final int MStandard ordinate index value for, where M is 3.This constant assumes XYZM coordinate sequence definition, please check this assumption using
getDimension()
andgetMeasures()
before use.- See Also:
-
-
Method Details
-
getDimension
int getDimension()Returns the dimension (number of ordinates in each coordinate) for this sequence.This total includes any measures, indicated by non-zero
getMeasures()
.- Returns:
- the dimension of the sequence.
-
getMeasures
default int getMeasures()Returns the number of measures included ingetDimension()
for each coordinate for this sequence. For a measured coordinate sequence a non-zero value is returned.- For XY sequence measures is zero
- For XYM sequence measure is one
- For XYZ sequence measure is zero
- For XYZM sequence measure is one
- Values greater than one are supported
- Returns:
- the number of measures included in dimension
-
hasZ
default boolean hasZ()- Returns:
- true if
getZ(int)
is supported.
-
hasM
default boolean hasM()Tests whether the coordinates in the sequence have measures associated with them. Returns true ifgetMeasures()
> 0
. SeegetMeasures()
to determine the number of measures present.- Returns:
- true if
getM(int)
is supported. - See Also:
-
createCoordinate
Creates a coordinate for use in this sequence.The coordinate is created supporting the same number of
getDimension()
andgetMeasures()
as this sequence and is suitable for use withgetCoordinate(int, Coordinate)
.- Returns:
- coordinate for use with this sequence
-
getCoordinate
Returns (possibly a copy of) the i'th coordinate in this sequence. Whether or not the Coordinate returned is the actual underlying Coordinate or merely a copy depends on the implementation.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.
- Parameters:
i
- the index of the coordinate to retrieve- Returns:
- the i'th coordinate in the sequence
-
getCoordinateCopy
Returns a copy of the i'th coordinate in this sequence. This method optimizes the situation where the caller is going to make a copy anyway - if the implementation has already created a new Coordinate object, no further copy is needed.- Parameters:
i
- the index of the coordinate to retrieve- Returns:
- a copy of the i'th coordinate in the sequence
-
getCoordinate
Copies the i'th coordinate in the sequence to the suppliedCoordinate
. Only the first two dimensions are copied.- Parameters:
index
- the index of the coordinate to copycoord
- aCoordinate
to receive the value
-
getX
double getX(int index) Returns ordinate X (0) of the specified coordinate.- Parameters:
index
- the coordinate index in the sequence- Returns:
- the value of the X ordinate in the index'th coordinate
-
getY
double getY(int index) Returns ordinate Y (1) of the specified coordinate.- Parameters:
index
- the coordinate index in the sequence- Returns:
- the value of the Y ordinate in the index'th coordinate
-
getZ
default double getZ(int index) Returns ordinate Z of the specified coordinate if available.- Parameters:
index
- the coordinate index in the sequence- Returns:
- the value of the Z ordinate in the index'th coordinate, or Double.NaN if not defined.
-
getM
default double getM(int index) Returns ordinate M of the specified coordinate if available.- Parameters:
index
- the coordinate index in the sequence- Returns:
- the value of the M ordinate in the index'th coordinate, or Double.NaN if not defined.
-
getOrdinate
double getOrdinate(int index, int ordinateIndex) Returns the ordinate of a coordinate in this sequence. Ordinate indices 0 and 1 are assumed to be X and Y.Ordinates indices greater than 1 have user-defined semantics (for instance, they may contain other dimensions or measure values as described by
getDimension()
andgetMeasures()
).- Parameters:
index
- the coordinate index in the sequenceordinateIndex
- the ordinate index in the coordinate (in range [0, dimension-1])- Returns:
- ordinate value
-
size
int size()Returns the number of coordinates in this sequence.- Returns:
- the size of the sequence
-
setOrdinate
void setOrdinate(int index, int ordinateIndex, double value) Sets the value for a given ordinate of a coordinate in this sequence.- Parameters:
index
- the coordinate index in the sequenceordinateIndex
- the ordinate index in the coordinate (in range [0, dimension-1])value
- the new ordinate value
-
toCoordinateArray
Coordinate[] toCoordinateArray()Returns (possibly copies of) the Coordinates in this collection. Whether or not the Coordinates returned are the actual underlying Coordinates or merely copies depends on the implementation. Note that if this implementation does not store its data as an array of Coordinates, this method will incur a performance penalty because the array needs to be built from scratch.- Returns:
- a array of coordinates containing the point values in this sequence
-
expandEnvelope
Expands the givenEnvelope
to include the coordinates in the sequence. Allows implementing classes to optimize access to coordinate values.- Parameters:
env
- the envelope to expand- Returns:
- a ref to the expanded envelope
-
clone
Object clone()Deprecated.Recommendcopy()
Returns a deep copy of this collection. Called by Geometry#clone.- Returns:
- a copy of the coordinate sequence containing copies of all points
-
copy
CoordinateSequence copy()Returns a deep copy of this collection.- Returns:
- a copy of the coordinate sequence containing copies of all points
-
copy()