Interface CoordinateSequence
-
- All Superinterfaces:
java.lang.Cloneable
- All Known Implementing Classes:
AxisPlaneCoordinateSequence,CoordinateArraySequence,PackedCoordinateSequence,PackedCoordinateSequence.Double,PackedCoordinateSequence.Float
public interface CoordinateSequence extends java.lang.CloneableThe internal representation of a list of coordinates inside a Geometry.This allows Geometries to store their points using something other than the JTS
Coordinateclass. 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
CoordinateSequenceandCoordinateSequenceFactoryinterfaces. To use the custom CoordinateSequence, create a newGeometryFactoryparameterized by the CoordinateSequenceFactory TheGeometryFactorycan then be used to create newGeometrys. The new Geometries will use the custom CoordinateSequence implementation.For an example, see the code for
ExtendedCoordinateExample.- See Also:
CoordinateArraySequenceFactory,PackedCoordinateSequenceFactory,ExtendedCoordinateExample
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Objectclone()Returns a deep copy of this collection.EnvelopeexpandEnvelope(Envelope env)Expands the givenEnvelopeto include the coordinates in the sequence.CoordinategetCoordinate(int i)Returns (possibly a copy of) the i'th coordinate in this sequence.voidgetCoordinate(int index, Coordinate coord)Copies the i'th coordinate in the sequence to the suppliedCoordinate.CoordinategetCoordinateCopy(int i)Returns a copy of the i'th coordinate in this sequence.intgetDimension()Returns the dimension (number of ordinates in each coordinate) for this sequence.doublegetOrdinate(int index, int ordinateIndex)Returns the ordinate of a coordinate in this sequence.doublegetX(int index)Returns ordinate X (0) of the specified coordinate.doublegetY(int index)Returns ordinate Y (1) of the specified coordinate.voidsetOrdinate(int index, int ordinateIndex, double value)Sets the value for a given ordinate of a coordinate in this sequence.intsize()Returns the number of coordinates in this sequence.Coordinate[]toCoordinateArray()Returns (possibly copies of) the Coordinates in this collection.
-
-
-
Field Detail
-
X
static final int X
Standard ordinate index values- See Also:
- Constant Field Values
-
Y
static final int Y
- See Also:
- Constant Field Values
-
Z
static final int Z
- See Also:
- Constant Field Values
-
M
static final int M
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDimension
int getDimension()
Returns the dimension (number of ordinates in each coordinate) for this sequence.- Returns:
- the dimension of the sequence.
-
getCoordinate
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.
- Parameters:
i- the index of the coordinate to retrieve- Returns:
- the i'th coordinate in the sequence
-
getCoordinateCopy
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.- Parameters:
i- the index of the coordinate to retrieve- Returns:
- a copy of the i'th coordinate in the sequence
-
getCoordinate
void getCoordinate(int index, Coordinate coord)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- aCoordinateto receive the value
-
getX
double getX(int index)
Returns ordinate X (0) of the specified coordinate.- Parameters:
index-- 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-- Returns:
- the value of the Y ordinate in the index'th coordinate
-
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).- Parameters:
index- the coordinate index in the sequenceordinateIndex- the ordinate index in the coordinate (in range [0, dimension-1])
-
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
Envelope expandEnvelope(Envelope env)
Expands the givenEnvelopeto 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
java.lang.Object clone()
Returns a deep copy of this collection. Called by Geometry#clone.- Returns:
- a copy of the coordinate sequence containing copies of all points
-
-