Package org.locationtech.jts.geom.impl
Class CoordinateArraySequence
- java.lang.Object
-
- org.locationtech.jts.geom.impl.CoordinateArraySequence
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,CoordinateSequence
public class CoordinateArraySequence extends java.lang.Object implements CoordinateSequence, java.io.Serializable
ACoordinateSequence
backed by an array ofCoordinate
s. This is the implementation thatGeometry
s use by default. Coordinates returned by #toArray and #getCoordinate are live -- modifications to them are actually changing the CoordinateSequence's underlying data. A dimension may be specified for the coordinates in the sequence, which may be 2 or 3. The actual coordinates will always have 3 ordinates, but the dimension is useful as metadata in some situations.- Version:
- 1.7
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.locationtech.jts.geom.CoordinateSequence
M, X, Y, Z
-
-
Constructor Summary
Constructors Constructor Description CoordinateArraySequence(int size)
Constructs a sequence of a given size, populated with newCoordinate
s.CoordinateArraySequence(int size, int dimension)
Constructs a sequence of a given size, populated with newCoordinate
s.CoordinateArraySequence(int size, int dimension, int measures)
Constructs a sequence of a given size, populated with newCoordinate
s.CoordinateArraySequence(Coordinate[] coordinates)
Constructs a sequence based on the given array ofCoordinate
s (the array is not copied).CoordinateArraySequence(Coordinate[] coordinates, int dimension)
Constructs a sequence based on the given array ofCoordinate
s (the array is not copied).CoordinateArraySequence(Coordinate[] coordinates, int dimension, int measures)
Constructs a sequence based on the given array ofCoordinate
s (the array is not copied).CoordinateArraySequence(CoordinateSequence coordSeq)
Creates a new sequence based on a deep copy of the givenCoordinateSequence
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.Object
clone()
Deprecated.CoordinateArraySequence
copy()
Creates a deep copy of the CoordinateArraySequenceEnvelope
expandEnvelope(Envelope env)
Expands the givenEnvelope
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 suppliedCoordinate
.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
getM(int index)
Returns ordinate M of the specified coordinate if available.int
getMeasures()
Returns the number of measures included inCoordinateSequence.getDimension()
for 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.double
getZ(int index)
Returns ordinate Z of the specified coordinate if available.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 sequenceCoordinate[]
toCoordinateArray()
This method exposes the internal Array of Coordinate Objectsjava.lang.String
toString()
Returns the string Representation of the coordinate array-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.locationtech.jts.geom.CoordinateSequence
createCoordinate, hasM, hasZ
-
-
-
-
Constructor Detail
-
CoordinateArraySequence
public CoordinateArraySequence(Coordinate[] coordinates)
Constructs a sequence based on the given array ofCoordinate
s (the array is not copied). The coordinate dimension defaults to 3.- Parameters:
coordinates
- the coordinate array that will be referenced.
-
CoordinateArraySequence
public CoordinateArraySequence(Coordinate[] coordinates, int dimension)
Constructs a sequence based on the given array ofCoordinate
s (the array is not copied).- Parameters:
coordinates
- the coordinate array that will be referenced.dimension
- the dimension of the coordinates
-
CoordinateArraySequence
public CoordinateArraySequence(Coordinate[] coordinates, int dimension, int measures)
Constructs a sequence based on the given array ofCoordinate
s (the array is not copied).- Parameters:
coordinates
- the coordinate array that will be referenced.dimension
- the dimension of the coordinates
-
CoordinateArraySequence
public CoordinateArraySequence(int size)
Constructs a sequence of a given size, populated with newCoordinate
s.- Parameters:
size
- the size of the sequence to create
-
CoordinateArraySequence
public CoordinateArraySequence(int size, int dimension)
Constructs a sequence of a given size, populated with newCoordinate
s.- Parameters:
size
- the size of the sequence to createdimension
- the dimension of the coordinates
-
CoordinateArraySequence
public CoordinateArraySequence(int size, int dimension, int measures)
Constructs a sequence of a given size, populated with newCoordinate
s.- Parameters:
size
- the size of the sequence to createdimension
- the dimension of the coordinates
-
CoordinateArraySequence
public CoordinateArraySequence(CoordinateSequence coordSeq)
Creates a new sequence based on a deep copy of the givenCoordinateSequence
. The coordinate dimension is set to equal the dimension of the input.- Parameters:
coordSeq
- the coordinate sequence that will be copied.
-
-
Method Detail
-
getDimension
public int getDimension()
Description copied from interface:CoordinateSequence
Returns the dimension (number of ordinates in each coordinate) for this sequence.This total includes any measures, indicated by non-zero
CoordinateSequence.getMeasures()
.- Specified by:
getDimension
in interfaceCoordinateSequence
- Returns:
- the dimension of the sequence.
- See Also:
CoordinateSequence.getDimension()
-
getMeasures
public int getMeasures()
Description copied from interface:CoordinateSequence
Returns the number of measures included inCoordinateSequence.getDimension()
for each coordinate for this sequence. For a measured coordinate sequence a non-zero value is returned.- For XY sequence measures is zero
- For XYM sequence measure is one
- For XYZ sequence measure is zero
- For XYZM sequence measure is one
- Values greater than one are supported
- Specified by:
getMeasures
in interfaceCoordinateSequence
- Returns:
- the number of measures included in dimension
-
getCoordinate
public Coordinate getCoordinate(int i)
Get the Coordinate with index i.- Specified by:
getCoordinate
in interfaceCoordinateSequence
- 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 interfaceCoordinateSequence
- 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 suppliedCoordinate
. Only the first two dimensions are copied.- Specified by:
getCoordinate
in interfaceCoordinateSequence
- Parameters:
index
- the index of the coordinate to copycoord
- aCoordinate
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 interfaceCoordinateSequence
- 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 interfaceCoordinateSequence
- Returns:
- the value of the Y ordinate in the index'th coordinate
- See Also:
CoordinateSequence.getY(int)
-
getZ
public double getZ(int index)
Description copied from interface:CoordinateSequence
Returns ordinate Z of the specified coordinate if available.- Specified by:
getZ
in interfaceCoordinateSequence
- Returns:
- the value of the Z ordinate in the index'th coordinate, or Double.NaN if not defined.
- See Also:
CoordinateSequence.getZ(int)
-
getM
public double getM(int index)
Description copied from interface:CoordinateSequence
Returns ordinate M of the specified coordinate if available.- Specified by:
getM
in interfaceCoordinateSequence
- Returns:
- the value of the M ordinate in the index'th coordinate, or Double.NaN if not defined.
- See Also:
CoordinateSequence.getM(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 as described by
CoordinateSequence.getDimension()
andCoordinateSequence.getMeasures()
).- Specified by:
getOrdinate
in interfaceCoordinateSequence
- Parameters:
index
- the coordinate index in the sequenceordinateIndex
- the ordinate index in the coordinate (in range [0, dimension-1])- See Also:
CoordinateSequence.getOrdinate(int, int)
-
clone
public java.lang.Object clone()
Deprecated.Creates a deep copy of the Object- Specified by:
clone
in interfaceCoordinateSequence
- Returns:
- The deep copy
-
copy
public CoordinateArraySequence copy()
Creates a deep copy of the CoordinateArraySequence- Specified by:
copy
in interfaceCoordinateSequence
- Returns:
- The deep copy
-
size
public int size()
Returns the size of the coordinate sequence- Specified by:
size
in interfaceCoordinateSequence
- 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 interfaceCoordinateSequence
- Parameters:
index
- the coordinate index in the sequenceordinateIndex
- 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 interfaceCoordinateSequence
- Returns:
- the Coordinate[] array.
-
expandEnvelope
public Envelope expandEnvelope(Envelope env)
Description copied from interface:CoordinateSequence
Expands the givenEnvelope
to include the coordinates in the sequence. Allows implementing classes to optimize access to coordinate values.- Specified by:
expandEnvelope
in interfaceCoordinateSequence
- 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 classjava.lang.Object
- Returns:
- The string
-
-