Package org.locationtech.jtsexample.geom
Class ExtendedCoordinateSequence
java.lang.Object
org.locationtech.jtsexample.geom.ExtendedCoordinateSequence
- All Implemented Interfaces:
Cloneable
,CoordinateSequence
Demonstrates how to implement a CoordinateSequence for a new kind of
coordinate (an
ExtendedCoordinate
in this example). In this
implementation, Coordinates returned by #toArray and #get are live -- parties
that change them are actually changing the ExtendedCoordinateSequence's
underlying data.- Version:
- 1.7
-
Field Summary
FieldsFields inherited from interface org.locationtech.jts.geom.CoordinateSequence
M, X, Y, Z
-
Constructor Summary
ConstructorsConstructorDescriptionExtendedCoordinateSequence
(int size) Constructs a sequence of a given size, populated with newExtendedCoordinate
s.ExtendedCoordinateSequence
(Coordinate[] copyCoords) Constructor that makes a copy of an array of Coordinates.ExtendedCoordinateSequence
(CoordinateSequence coordSeq) Constructor that makes a copy of a CoordinateSequence.ExtendedCoordinateSequence
(ExtendedCoordinate[] coordinates) Copy constructor -- simply aliases the input array, for better performance. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Deprecated.copy()
Returns a deep copy of this collection.static ExtendedCoordinate[]
copy
(Coordinate[] coordinates) static ExtendedCoordinate[]
copy
(CoordinateSequence coordSeq) expandEnvelope
(Envelope env) Expands the givenEnvelope
to include the coordinates in the sequence.getCoordinate
(int i) Returns (possibly a copy of) the i'th coordinate in this sequence.void
getCoordinate
(int index, Coordinate coord) Copies the i'th coordinate in the sequence to the suppliedCoordinate
.getCoordinateCopy
(int index) Returns a copy of the i'th coordinate in this sequence.int
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 number of coordinates in this sequence.Returns (possibly copies of) the Coordinates in this collection.toString()
-
Field Details
-
coordinates
-
-
Constructor Details
-
ExtendedCoordinateSequence
Copy constructor -- simply aliases the input array, for better performance. -
ExtendedCoordinateSequence
Constructor that makes a copy of an array of Coordinates. Always makes a copy of the input array, since the actual class of the Coordinates in the input array may be different from ExtendedCoordinate. -
ExtendedCoordinateSequence
Constructor that makes a copy of a CoordinateSequence. -
ExtendedCoordinateSequence
public ExtendedCoordinateSequence(int size) Constructs a sequence of a given size, populated with newExtendedCoordinate
s.- Parameters:
size
- the size of the sequence to create
-
-
Method Details
-
copy
-
copy
-
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 interfaceCoordinateSequence
- Returns:
- the dimension of the sequence.
- See Also:
-
getCoordinate
Description copied from interface:CoordinateSequence
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.
- Specified by:
getCoordinate
in interfaceCoordinateSequence
- Parameters:
i
- the index of the coordinate to retrieve- Returns:
- the i'th coordinate in the sequence
-
getCoordinateCopy
Description copied from interface:CoordinateSequence
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.- Specified by:
getCoordinateCopy
in interfaceCoordinateSequence
- Parameters:
index
- the index of the coordinate to retrieve- Returns:
- a copy of the i'th coordinate in the sequence
- See Also:
-
getCoordinate
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:
-
getX
public double getX(int index) Description copied from interface:CoordinateSequence
Returns ordinate X (0) of the specified coordinate.- Specified by:
getX
in interfaceCoordinateSequence
- Parameters:
index
-- Returns:
- the value of the X ordinate in the index'th coordinate
- See Also:
-
getY
public double getY(int index) Description copied from interface:CoordinateSequence
Returns ordinate Y (1) of the specified coordinate.- Specified by:
getY
in interfaceCoordinateSequence
- Parameters:
index
-- Returns:
- the value of the Y ordinate in the index'th coordinate
- See Also:
-
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 interfaceCoordinateSequence
- Parameters:
index
- the coordinate index in the sequenceordinateIndex
- the ordinate index in the coordinate (in range [0, dimension-1])- See Also:
-
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:
-
clone
Deprecated.Description copied from interface:CoordinateSequence
Returns a deep copy of this collection. Called by Geometry#clone.- Specified by:
clone
in interfaceCoordinateSequence
- Overrides:
clone
in classObject
- Returns:
- a copy of the coordinate sequence containing copies of all points
-
copy
Description copied from interface:CoordinateSequence
Returns a deep copy of this collection.- Specified by:
copy
in interfaceCoordinateSequence
- Returns:
- a copy of the coordinate sequence containing copies of all points
-
size
public int size()Description copied from interface:CoordinateSequence
Returns the number of coordinates in this sequence.- Specified by:
size
in interfaceCoordinateSequence
- Returns:
- the size of the sequence
-
toCoordinateArray
Description copied from interface:CoordinateSequence
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.- Specified by:
toCoordinateArray
in interfaceCoordinateSequence
- Returns:
- a array of coordinates containing the point values in this sequence
-
expandEnvelope
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
-