com.vividsolutions.jts.geom
Interface CoordinateSequence
- Cloneable
- CoordinateArraySequence, PackedCoordinateSequence, PackedCoordinateSequence.Double, PackedCoordinateSequence.Float
public interface CoordinateSequence
extends Cloneable
The internal representation of a list of coordinates inside a Geometry.
There are some cases in which you might want Geometries to store their
points using something other than the JTS Coordinate class. For example, you
may want to experiment with another implementation, such as an array of x's
and an array of y's. Or you might want to use your own coordinate class, one
that supports extra attributes like M-values.
You can do this by implementing the CoordinateSequence and
CoordinateSequenceFactory interfaces. You would then create a
GeometryFactory parameterized by your CoordinateSequenceFactory, and use
this GeometryFactory to create new Geometries. All of these new Geometries
will use your CoordinateSequence implementation.
For an example, see the code for
com.vividsolutions.jtsexample.geom.TwoArrayCoordinateSequenceExample
.
static int | M
|
static int | X - Standard ordinate index values
|
static int | Y
|
static int | Z
|
Object | clone() - Returns a deep copy of this collection.
|
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.
|
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.
|
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.
|
M
public static final int M
X
public static final int X
Standard ordinate index values
Y
public static final int Y
Z
public static final int Z
clone
public Object clone()
Returns a deep copy of this collection.
Called by Geometry#clone.
- a copy of the coordinate sequence containing copies of all points
expandEnvelope
public Envelope expandEnvelope(Envelope env)
Expands the given
Envelope
to include the coordinates in the sequence.
Allows implementing classes to optimize access to coordinate values.
env
- the envelope to expand
- a ref to the expanded envelope
getCoordinate
public Coordinate getCoordinate(int i)
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.
i
- the index of the coordinate to retrieve
- the i'th coordinate in the sequence
getCoordinate
public void getCoordinate(int index,
Coordinate coord)
Copies the i'th coordinate in the sequence to the supplied
Coordinate
. Only the first two dimensions are copied.
index
- the index of the coordinate to copycoord
- a Coordinate
to receive the value
getCoordinateCopy
public Coordinate getCoordinateCopy(int i)
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.
i
- the index of the coordinate to retrieve
- a copy of the i'th coordinate in the sequence
getOrdinate
public 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).
index
- the coordinate index in the sequenceordinateIndex
- the ordinate index in the coordinate (in range [0, dimension-1])
getX
public double getX(int index)
Returns ordinate X (0) of the specified coordinate.
- the value of the X ordinate in the index'th coordinate
getY
public double getY(int index)
Returns ordinate Y (1) of the specified coordinate.
- the value of the Y ordinate in the index'th coordinate
setOrdinate
public void setOrdinate(int index,
int ordinateIndex,
double value)
Sets the value for a given ordinate of a coordinate in this sequence.
index
- the coordinate index in the sequenceordinateIndex
- the ordinate index in the coordinate (in range [0, dimension-1])value
- the new ordinate value
size
public int size()
Returns the number of coordinates in this sequence.
toCoordinateArray
public 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.
- a array of coordinates containing the point values in this sequence