com.vividsolutions.jts.geom
Interface CoordinateSequence

All Superinterfaces:
java.lang.Cloneable

public interface CoordinateSequence
extends java.lang.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.

A note on performance. If your CoordinateSequence is not based on an array of Coordinates, it may incur a performance penalty when its #toArray method is called because the array needs to be built from scratch.

Version:
1.4.0
See Also:
DefaultCoordinateSequenceFactory, TwoArrayCoordinateSequenceFactory

Method Summary
 java.lang.Object clone()
          Returns a deep copy of this collection.
 Coordinate getCoordinate(int i)
          Returns (possibly a copy of) the ith Coordinate in this collection.
 int size()
          Returns the number of Coordinates (actual or otherwise, as this implementation may not store its data in Coordinate objects).
 Coordinate[] toCoordinateArray()
          Returns (possibly copies of) the Coordinates in this collection.
 

Method Detail

getCoordinate

public Coordinate getCoordinate(int i)
Returns (possibly a copy of) the ith Coordinate in this collection. 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 are advised not to assume that they can modify a CoordinateSequence by modifying the Coordinate returned by this method.


size

public int size()
Returns the number of Coordinates (actual or otherwise, as this implementation may not store its data in Coordinate objects).


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.


clone

public java.lang.Object clone()
Returns a deep copy of this collection. Called by Geometry#clone.