Class ExtendedCoordinateSequence
- java.lang.Object
-
- org.locationtech.jtsexample.geom.ExtendedCoordinateSequence
-
- All Implemented Interfaces:
Cloneable,CoordinateSequence
public class ExtendedCoordinateSequence extends Object implements CoordinateSequence
Demonstrates how to implement a CoordinateSequence for a new kind of coordinate (anExtendedCoordinatein 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
-
Fields inherited from interface org.locationtech.jts.geom.CoordinateSequence
M, X, Y, Z
-
-
Constructor Summary
Constructors Constructor Description ExtendedCoordinateSequence(int size)Constructs a sequence of a given size, populated with newExtendedCoordinates.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
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Objectclone()Deprecated.ExtendedCoordinateSequencecopy()Returns a deep copy of this collection.static ExtendedCoordinate[]copy(Coordinate[] coordinates)static ExtendedCoordinate[]copy(CoordinateSequence coordSeq)CoordinatecreateCoordinate()Creates a coordinate for use in this sequence.EnvelopeexpandEnvelope(Envelope env)Expands the givenEnvelopeto include the coordinates in the sequence.CoordinategetCoordinate(int i)Returns (possibly a copy of) the i'th coordinate in this sequence.voidgetCoordinate(int index, Coordinate coord)Copies the i'th coordinate in the sequence to the suppliedCoordinate.CoordinategetCoordinateCopy(int index)Returns a copy of the i'th coordinate in this sequence.intgetDimension()Returns the dimension (number of ordinates in each coordinate) for this sequence.intgetMeasures()Returns the number of measures included inCoordinateSequence.getDimension()for each coordinate for this sequence.doublegetOrdinate(int index, int ordinateIndex)Returns the ordinate of a coordinate in this sequence.doublegetX(int index)Returns ordinate X (0) of the specified coordinate.doublegetY(int index)Returns ordinate Y (1) of the specified coordinate.voidsetOrdinate(int index, int ordinateIndex, double value)Sets the value for a given ordinate of a coordinate in this sequence.intsize()Returns the number of coordinates in this sequence.Coordinate[]toCoordinateArray()Returns (possibly copies of) the Coordinates in this collection.StringtoString()-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.locationtech.jts.geom.CoordinateSequence
getM, getZ, hasM, hasZ
-
-
-
-
Constructor Detail
-
ExtendedCoordinateSequence
public ExtendedCoordinateSequence(ExtendedCoordinate[] coordinates)
Copy constructor -- simply aliases the input array, for better performance.
-
ExtendedCoordinateSequence
public ExtendedCoordinateSequence(Coordinate[] copyCoords)
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
public ExtendedCoordinateSequence(CoordinateSequence coordSeq)
Constructor that makes a copy of a CoordinateSequence.
-
ExtendedCoordinateSequence
public ExtendedCoordinateSequence(int size)
Constructs a sequence of a given size, populated with newExtendedCoordinates.- Parameters:
size- the size of the sequence to create
-
-
Method Detail
-
copy
public static ExtendedCoordinate[] copy(Coordinate[] coordinates)
-
copy
public static ExtendedCoordinate[] copy(CoordinateSequence coordSeq)
-
getDimension
public int getDimension()
Description copied from interface:CoordinateSequenceReturns the dimension (number of ordinates in each coordinate) for this sequence.This total includes any measures, indicated by non-zero
CoordinateSequence.getMeasures().- Specified by:
getDimensionin interfaceCoordinateSequence- Returns:
- the dimension of the sequence.
- See Also:
CoordinateSequence.getDimension()
-
getMeasures
public int getMeasures()
Description copied from interface:CoordinateSequenceReturns 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:
getMeasuresin interfaceCoordinateSequence- Returns:
- the number of measures included in dimension
-
createCoordinate
public Coordinate createCoordinate()
Description copied from interface:CoordinateSequenceCreates a coordinate for use in this sequence.The coordinate is created supporting the same number of
CoordinateSequence.getDimension()andCoordinateSequence.getMeasures()as this sequence and is suitable for use withCoordinateSequence.getCoordinate(int, Coordinate).- Specified by:
createCoordinatein interfaceCoordinateSequence- Returns:
- coordinate for use with this sequence
-
getCoordinate
public Coordinate getCoordinate(int i)
Description copied from interface:CoordinateSequenceReturns (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:
getCoordinatein interfaceCoordinateSequence- Parameters:
i- the index of the coordinate to retrieve- Returns:
- the i'th coordinate in the sequence
-
getCoordinateCopy
public Coordinate getCoordinateCopy(int index)
Description copied from interface:CoordinateSequenceReturns 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:
getCoordinateCopyin interfaceCoordinateSequence- Parameters:
index- the index of the coordinate to retrieve- Returns:
- a copy of the i'th coordinate in the sequence
- See Also:
CoordinateSequence.getX(int)
-
getCoordinate
public void getCoordinate(int index, Coordinate coord)Description copied from interface:CoordinateSequenceCopies the i'th coordinate in the sequence to the suppliedCoordinate. Only the first two dimensions are copied.- Specified by:
getCoordinatein interfaceCoordinateSequence- Parameters:
index- the index of the coordinate to copycoord- aCoordinateto receive the value- See Also:
CoordinateSequence.getX(int)
-
getX
public double getX(int index)
Description copied from interface:CoordinateSequenceReturns ordinate X (0) of the specified coordinate.- Specified by:
getXin interfaceCoordinateSequence- Parameters:
index- the coordinate index in the sequence- 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:CoordinateSequenceReturns ordinate Y (1) of the specified coordinate.- Specified by:
getYin interfaceCoordinateSequence- Parameters:
index- the coordinate index in the sequence- 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:CoordinateSequenceReturns 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:
getOrdinatein interfaceCoordinateSequence- Parameters:
index- the coordinate index in the sequenceordinateIndex- the ordinate index in the coordinate (in range [0, dimension-1])- Returns:
- ordinate value
- See Also:
CoordinateSequence.getOrdinate(int, int)
-
setOrdinate
public void setOrdinate(int index, int ordinateIndex, double value)Description copied from interface:CoordinateSequenceSets the value for a given ordinate of a coordinate in this sequence.- Specified by:
setOrdinatein 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)
-
clone
public Object clone()
Deprecated.Description copied from interface:CoordinateSequenceReturns a deep copy of this collection. Called by Geometry#clone.- Specified by:
clonein interfaceCoordinateSequence- Overrides:
clonein classObject- Returns:
- a copy of the coordinate sequence containing copies of all points
-
copy
public ExtendedCoordinateSequence copy()
Description copied from interface:CoordinateSequenceReturns a deep copy of this collection.- Specified by:
copyin interfaceCoordinateSequence- Returns:
- a copy of the coordinate sequence containing copies of all points
-
size
public int size()
Description copied from interface:CoordinateSequenceReturns the number of coordinates in this sequence.- Specified by:
sizein interfaceCoordinateSequence- Returns:
- the size of the sequence
-
toCoordinateArray
public Coordinate[] toCoordinateArray()
Description copied from interface:CoordinateSequenceReturns (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:
toCoordinateArrayin interfaceCoordinateSequence- Returns:
- a array of coordinates containing the point values in this sequence
-
expandEnvelope
public Envelope expandEnvelope(Envelope env)
Description copied from interface:CoordinateSequenceExpands the givenEnvelopeto include the coordinates in the sequence. Allows implementing classes to optimize access to coordinate values.- Specified by:
expandEnvelopein interfaceCoordinateSequence- Parameters:
env- the envelope to expand- Returns:
- a ref to the expanded envelope
-
-