JTS Topology Suite version 1.12

com.vividsolutions.jts.geom.impl
Class CoordinateArraySequence

java.lang.Object
  extended by com.vividsolutions.jts.geom.impl.CoordinateArraySequence
All Implemented Interfaces:
CoordinateSequence, java.io.Serializable, java.lang.Cloneable

public class CoordinateArraySequence
extends java.lang.Object
implements CoordinateSequence, java.io.Serializable

The CoordinateSequence implementation that Geometrys use by default. In this implementation, Coordinates returned by #toArray and #getCoordinate are live -- modifications to them are actually changing the CoordinateSequence's underlying data.

Version:
1.7
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.vividsolutions.jts.geom.CoordinateSequence
M, X, Y, Z
 
Constructor Summary
CoordinateArraySequence(Coordinate[] coordinates)
          Constructs a sequence based on the given array (the array is not copied).
CoordinateArraySequence(CoordinateSequence coordSeq)
          Constructs a sequence based on the given array (the array is not copied).
CoordinateArraySequence(int size)
          Constructs a sequence of a given size, populated with new Coordinates.
 
Method Summary
 java.lang.Object clone()
          Creates a deep copy of the Object
 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 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 size of the coordinate sequence
 Coordinate[] toCoordinateArray()
          This method exposes the internal Array of Coordinate Objects
 java.lang.String toString()
          Returns the string Representation of the coordinate array
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CoordinateArraySequence

public CoordinateArraySequence(Coordinate[] coordinates)
Constructs a sequence based on the given array (the array is not copied).

Parameters:
coordinates - the coordinate array that will be referenced.

CoordinateArraySequence

public CoordinateArraySequence(int size)
Constructs a sequence of a given size, populated with new Coordinates.

Parameters:
size - the size of the sequence to create

CoordinateArraySequence

public CoordinateArraySequence(CoordinateSequence coordSeq)
Constructs a sequence based on the given array (the array is not copied).

Parameters:
coordinates - the coordinate array that will be referenced.
Method Detail

getDimension

public int getDimension()
Description copied from interface: CoordinateSequence
Returns the dimension (number of ordinates in each coordinate) for this sequence.

Specified by:
getDimension in interface CoordinateSequence
Returns:
the dimension of the sequence.
See Also:
CoordinateSequence.getDimension()

getCoordinate

public Coordinate getCoordinate(int i)
Get the Coordinate with index i.

Specified by:
getCoordinate in interface CoordinateSequence
Parameters:
i - the index of the coordinate
Returns:
the requested Coordinate instance

getCoordinateCopy

public Coordinate getCoordinateCopy(int i)
Get a copy of the Coordinate with index i.

Specified by:
getCoordinateCopy in interface CoordinateSequence
Parameters:
i - the index of the coordinate
Returns:
a copy of the requested Coordinate

getCoordinate

public void getCoordinate(int index,
                          Coordinate coord)
Description copied from interface: CoordinateSequence
Copies the i'th coordinate in the sequence to the supplied Coordinate. Only the first two dimensions are copied.

Specified by:
getCoordinate in interface CoordinateSequence
Parameters:
index - the index of the coordinate to copy
coord - a Coordinate to receive the value
See Also:
CoordinateSequence.getX(int)

getX

public double getX(int index)
Description copied from interface: CoordinateSequence
Returns ordinate X (0) of the specified coordinate.

Specified by:
getX in interface CoordinateSequence
Returns:
the value of the X ordinate in the index'th coordinate
See Also:
CoordinateSequence.getX(int)

getY

public double getY(int index)
Description copied from interface: CoordinateSequence
Returns ordinate Y (1) of the specified coordinate.

Specified by:
getY in interface CoordinateSequence
Returns:
the value of the Y ordinate in the index'th coordinate
See Also:
CoordinateSequence.getY(int)

getOrdinate

public double getOrdinate(int index,
                          int ordinateIndex)
Description copied from interface: CoordinateSequence
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).

Specified by:
getOrdinate in interface CoordinateSequence
Parameters:
index - the coordinate index in the sequence
ordinateIndex - the ordinate index in the coordinate (in range [0, dimension-1])
See Also:
CoordinateSequence.getOrdinate(int, int)

clone

public java.lang.Object clone()
Creates a deep copy of the Object

Specified by:
clone in interface CoordinateSequence
Overrides:
clone in class java.lang.Object
Returns:
The deep copy

size

public int size()
Returns the size of the coordinate sequence

Specified by:
size in interface CoordinateSequence
Returns:
the number of coordinates

setOrdinate

public void setOrdinate(int index,
                        int ordinateIndex,
                        double value)
Description copied from interface: CoordinateSequence
Sets the value for a given ordinate of a coordinate in this sequence.

Specified by:
setOrdinate in interface CoordinateSequence
Parameters:
index - the coordinate index in the sequence
ordinateIndex - the ordinate index in the coordinate (in range [0, dimension-1])
value - the new ordinate value
See Also:
CoordinateSequence.setOrdinate(int, int, double)

toCoordinateArray

public Coordinate[] toCoordinateArray()
This method exposes the internal Array of Coordinate Objects

Specified by:
toCoordinateArray in interface CoordinateSequence
Returns:
the Coordinate[] array.

expandEnvelope

public Envelope expandEnvelope(Envelope env)
Description copied from interface: CoordinateSequence
Expands the given Envelope to include the coordinates in the sequence. Allows implementing classes to optimize access to coordinate values.

Specified by:
expandEnvelope in interface CoordinateSequence
Parameters:
env - the envelope to expand
Returns:
a ref to the expanded envelope

toString

public java.lang.String toString()
Returns the string Representation of the coordinate array

Overrides:
toString in class java.lang.Object
Returns:
The string

JTS Topology Suite version 1.12