public class CoordinateArraySequence extends Object implements CoordinateSequence, Serializable
CoordinateSequence
backed by an array of Coordinate
s.
This is the implementation that Geometry
s use by default.
Coordinates returned by #toArray and #getCoordinate are live --
modifications to them are actually changing the
CoordinateSequence's underlying data.
A dimension may be specified for the coordinates in the sequence,
which may be 2 or 3.
The actual coordinates will always have 3 ordinates,
but the dimension is useful as metadata in some situations.M, X, Y, Z
Constructor and Description |
---|
CoordinateArraySequence(Coordinate[] coordinates)
Constructs a sequence based on the given array
of
Coordinate s (the
array is not copied). |
CoordinateArraySequence(Coordinate[] coordinates,
int dimension)
Constructs a sequence based on the given array
of
Coordinate s (the
array is not copied). |
CoordinateArraySequence(Coordinate[] coordinates,
int dimension,
int measures)
Constructs a sequence based on the given array
of
Coordinate s (the array is not copied). |
CoordinateArraySequence(CoordinateSequence coordSeq)
Creates a new sequence based on a deep copy of the given
CoordinateSequence . |
CoordinateArraySequence(int size)
Constructs a sequence of a given size, populated
with new
Coordinate s. |
CoordinateArraySequence(int size,
int dimension)
Constructs a sequence of a given size, populated
with new
Coordinate s. |
CoordinateArraySequence(int size,
int dimension,
int measures)
Constructs a sequence of a given size, populated
with new
Coordinate s. |
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Deprecated.
|
CoordinateArraySequence |
copy()
Creates a deep copy of the CoordinateArraySequence
|
Envelope |
expandEnvelope(Envelope env)
Expands the given
Envelope to include the coordinates in the sequence. |
Coordinate |
getCoordinate(int i)
Get the Coordinate with index i.
|
void |
getCoordinate(int index,
Coordinate coord)
Copies the i'th coordinate in the sequence to the supplied
Coordinate . |
Coordinate |
getCoordinateCopy(int i)
Get a copy of the Coordinate with index i.
|
int |
getDimension()
Returns the dimension (number of ordinates in each coordinate) for this sequence.
|
double |
getM(int index)
Returns ordinate M of the specified coordinate if available.
|
int |
getMeasures()
Returns the number of measures included in
CoordinateSequence.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.
|
double |
getZ(int index)
Returns ordinate Z of the specified coordinate if available.
|
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 size of the coordinate sequence
|
Coordinate[] |
toCoordinateArray()
This method exposes the internal Array of Coordinate Objects
|
String |
toString()
Returns the string Representation of the coordinate array
|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
createCoordinate, hasM, hasZ
public CoordinateArraySequence(Coordinate[] coordinates)
Coordinate
s (the
array is not copied).
The coordinate dimension defaults to 3.coordinates
- the coordinate array that will be referenced.public CoordinateArraySequence(Coordinate[] coordinates, int dimension)
Coordinate
s (the
array is not copied).coordinates
- the coordinate array that will be referenced.dimension
- the dimension of the coordinatespublic CoordinateArraySequence(Coordinate[] coordinates, int dimension, int measures)
Coordinate
s (the array is not copied).
It is your responsibility to ensure the array contains Coordinates of the
indicated dimension and measures (See
CoordinateArrays.enforceConsistency(Coordinate[])
).
coordinates
- the coordinate array that will be referenced.dimension
- the dimension of the coordinatespublic CoordinateArraySequence(int size)
Coordinate
s.size
- the size of the sequence to createpublic CoordinateArraySequence(int size, int dimension)
Coordinate
s.size
- the size of the sequence to createdimension
- the dimension of the coordinatespublic CoordinateArraySequence(int size, int dimension, int measures)
Coordinate
s.size
- the size of the sequence to createdimension
- the dimension of the coordinatespublic CoordinateArraySequence(CoordinateSequence coordSeq)
CoordinateSequence
.
The coordinate dimension is set to equal the dimension of the input.coordSeq
- the coordinate sequence that will be copied.public int getDimension()
CoordinateSequence
This total includes any measures, indicated by non-zero CoordinateSequence.getMeasures()
.
getDimension
in interface CoordinateSequence
CoordinateSequence.getDimension()
public int getMeasures()
CoordinateSequence
CoordinateSequence.getDimension()
for each coordinate for this
sequence.
For a measured coordinate sequence a non-zero value is returned.
getMeasures
in interface CoordinateSequence
public Coordinate getCoordinate(int i)
getCoordinate
in interface CoordinateSequence
i
- the index of the coordinatepublic Coordinate getCoordinateCopy(int i)
getCoordinateCopy
in interface CoordinateSequence
i
- the index of the coordinatepublic void getCoordinate(int index, Coordinate coord)
CoordinateSequence
Coordinate
. Only the first two dimensions are copied.getCoordinate
in interface CoordinateSequence
index
- the index of the coordinate to copycoord
- a Coordinate
to receive the valueCoordinateSequence.getX(int)
public double getX(int index)
CoordinateSequence
getX
in interface CoordinateSequence
index
- the coordinate index in the sequenceCoordinateSequence.getX(int)
public double getY(int index)
CoordinateSequence
getY
in interface CoordinateSequence
index
- the coordinate index in the sequenceCoordinateSequence.getY(int)
public double getZ(int index)
CoordinateSequence
getZ
in interface CoordinateSequence
index
- the coordinate index in the sequenceCoordinateSequence.getZ(int)
public double getM(int index)
CoordinateSequence
getM
in interface CoordinateSequence
index
- the coordinate index in the sequenceCoordinateSequence.getM(int)
public double getOrdinate(int index, int ordinateIndex)
CoordinateSequence
Ordinates indices greater than 1 have user-defined semantics
(for instance, they may contain other dimensions or measure
values as described by CoordinateSequence.getDimension()
and CoordinateSequence.getMeasures()
).
getOrdinate
in interface CoordinateSequence
index
- the coordinate index in the sequenceordinateIndex
- the ordinate index in the coordinate (in range [0, dimension-1])CoordinateSequence.getOrdinate(int, int)
public Object clone()
clone
in interface CoordinateSequence
clone
in class Object
public CoordinateArraySequence copy()
copy
in interface CoordinateSequence
public int size()
size
in interface CoordinateSequence
public void setOrdinate(int index, int ordinateIndex, double value)
CoordinateSequence
setOrdinate
in interface CoordinateSequence
index
- the coordinate index in the sequenceordinateIndex
- the ordinate index in the coordinate (in range [0, dimension-1])value
- the new ordinate valueCoordinateSequence.setOrdinate(int, int, double)
public Coordinate[] toCoordinateArray()
toCoordinateArray
in interface CoordinateSequence
public Envelope expandEnvelope(Envelope env)
CoordinateSequence
Envelope
to include the coordinates in the sequence.
Allows implementing classes to optimize access to coordinate values.expandEnvelope
in interface CoordinateSequence
env
- the envelope to expandCopyright © 2024. All rights reserved.