com.vividsolutions.jts.geom.impl

Class PackedCoordinateSequence

Implemented Interfaces:
Cloneable, CoordinateSequence
Known Direct Subclasses:
PackedCoordinateSequence.Double, PackedCoordinateSequence.Float

public abstract class PackedCoordinateSequence
extends java.lang.Object
implements CoordinateSequence

A CoordinateSequence implementation based on a packed arrays. In this implementation, Coordinates returned by #toArray and #get are copies of the internal values. To change the actual values, use the provided setters.

For efficiency, created Coordinate arrays are cached using a soft reference. The cache is cleared each time the coordinate sequence contents are modified through a setter method.

Version:
1.6

Nested Class Summary

static class
PackedCoordinateSequence.Double
Packed coordinate sequence implementation based on doubles
static class
PackedCoordinateSequence.Float
Packed coordinate sequence implementation based on floats

Field Summary

protected SoftReference
coordRef
A soft reference to the Coordinate[] representation of this sequence.
protected int
dimension
The dimensions of the coordinates hold in the packed array

Fields inherited from interface com.vividsolutions.jts.geom.CoordinateSequence

M, X, Y, Z

Method Summary

abstract Object
clone()
Coordinate
getCoordinate(int i)
void
getCoordinate(int i, Coordinate coord)
Coordinate
getCoordinateCopy(int i)
protected abstract Coordinate
getCoordinateInternal(int index)
Returns a Coordinate representation of the specified coordinate, by always building a new Coordinate object
int
getDimension()
abstract double
getOrdinate(int index, int ordinateIndex)
double
getX(int index)
double
getY(int index)
abstract void
setOrdinate(int index, int ordinate, double value)
Sets the ordinate of a coordinate in this sequence.
void
setX(int index, double value)
Sets the first ordinate of a coordinate in this sequence.
void
setY(int index, double value)
Sets the second ordinate of a coordinate in this sequence.
Coordinate[]
toCoordinateArray()

Field Details

coordRef

protected SoftReference coordRef
A soft reference to the Coordinate[] representation of this sequence. Makes repeated coordinate array accesses more efficient.

dimension

protected int dimension
The dimensions of the coordinates hold in the packed array

Method Details

clone

public abstract Object clone()
Specified by:
clone in interface CoordinateSequence
See Also:
java.lang.Object.clone()

getCoordinate

public Coordinate getCoordinate(int i)
Specified by:
getCoordinate in interface CoordinateSequence

getCoordinate

public void getCoordinate(int i,
                          Coordinate coord)
Specified by:
getCoordinate in interface CoordinateSequence

getCoordinateCopy

public Coordinate getCoordinateCopy(int i)
Specified by:
getCoordinateCopy in interface CoordinateSequence

getCoordinateInternal

protected abstract Coordinate getCoordinateInternal(int index)
Returns a Coordinate representation of the specified coordinate, by always building a new Coordinate object
Parameters:
index -
Returns:

getDimension

public int getDimension()
See Also:
com.vividsolutions.jts.geom.CoordinateSequence.getDimension()

getOrdinate

public abstract double getOrdinate(int index,
                                   int ordinateIndex)
Specified by:
getOrdinate in interface CoordinateSequence

getX

public double getX(int index)
Specified by:
getX in interface CoordinateSequence

getY

public double getY(int index)
Specified by:
getY in interface CoordinateSequence

setOrdinate

public abstract void setOrdinate(int index,
                                 int ordinate,
                                 double value)
Sets the ordinate of a coordinate in this sequence.
Warning: for performance reasons the ordinate index is not checked - if it is over dimensions you may not get an exception but a meaningless value.
Specified by:
setOrdinate in interface CoordinateSequence
Parameters:
index - the coordinate index
ordinate - the ordinate index in the coordinate, 0 based, smaller than the number of dimensions
value - the new ordinate value

setX

public void setX(int index,
                 double value)
Sets the first ordinate of a coordinate in this sequence.
Parameters:
index - the coordinate index
value - the new ordinate value

setY

public void setY(int index,
                 double value)
Sets the second ordinate of a coordinate in this sequence.
Parameters:
index - the coordinate index
value - the new ordinate value

toCoordinateArray

public Coordinate[] toCoordinateArray()
Specified by:
toCoordinateArray in interface CoordinateSequence