Package org.eclipse.imagen.media.jts
Class CoordinateSequence2D
Object
CoordinateSequence2D
- All Implemented Interfaces:
Cloneable,CoordinateSequence
A lightweight implementation of JTS
CoordinateSequence for 2D points.- Since:
- 1.1
- Author:
- Michael Bedward
-
Field Summary
Fields inherited from interface CoordinateSequence
M, X, Y, Z -
Constructor Summary
ConstructorsConstructorDescriptionCoordinateSequence2D(double... xy) Creates a newCoordinateSequence2Dobject from a sequence of (x,y) pairs.CoordinateSequence2D(int n) Creates a newCoordinateSequence2Dobject with the given size. -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates a deep copy of this sequence.copy()expandEnvelope(Envelope env) Returns an envelope which containsenvand all points in this sequence.getCoordinate(int index) Gets coordinate values at the specified index.voidgetCoordinate(int index, Coordinate coord) Copies the requested coordinate in the sequence to the suppliedCoordinateobject.getCoordinateCopy(int index) Equivalent togetCoordinate(int).intGets the dimension of points stored by thisCoordinateSequence2D.doublegetOrdinate(int index, int ordinateIndex) Returns the ordinate of a coordinate in this sequence.doublegetX(int index) doublegetY(int index) voidsetOrdinate(int index, int ordinateIndex, double value) Sets the ordinate of a coordinate in this sequence.voidsetX(int index, double value) Sets the X ordinate of the point at the given index.voidsetXY(int index, double x, double y) Sets the coordinate at the given index.voidsetY(int index, double value) Sets the Y ordinate of the point at the given index.intsize()Returns an array of newCoordinateobjects for the point values in this sequence.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CoordinateSequence
createCoordinate, getM, getMeasures, getZ, hasM, hasZ
-
Constructor Details
-
CoordinateSequence2D
public CoordinateSequence2D(int n) Creates a newCoordinateSequence2Dobject with the given size.- Parameters:
n- capacity (number of coordinates)
-
CoordinateSequence2D
public CoordinateSequence2D(double... xy) Creates a newCoordinateSequence2Dobject from a sequence of (x,y) pairs.// Example: create an object with 3 coordinates specified // as xy pairs CoordinateSequence cs = new CoordinateSequence2D(1.1, 1.2, 2.1, 2.2, 3.1, 3.2);- Parameters:
xy- x and y values ordered asx0, y0, x1, y1...; ifnullan empty object is created- Throws:
IllegalArgumentException- if the number of values inxyis greater than 0 but not even
-
-
Method Details
-
getDimension
public int getDimension()Gets the dimension of points stored by thisCoordinateSequence2D.- Specified by:
getDimensionin interfaceCoordinateSequence- Returns:
- always returns 2
-
getCoordinate
Gets coordinate values at the specified index.- Specified by:
getCoordinatein interfaceCoordinateSequence- Parameters:
index- an index ≥0 and <size()- Returns:
- a new
Coordinateobject
-
getCoordinateCopy
Equivalent togetCoordinate(int).- Specified by:
getCoordinateCopyin interfaceCoordinateSequence- Parameters:
index- an index ≥0 and <size()- Returns:
- a new
Coordinateobject
-
getCoordinate
Copies the requested coordinate in the sequence to the suppliedCoordinateobject.- Specified by:
getCoordinatein interfaceCoordinateSequence- Parameters:
index- an index ≥0 and <size()coord- the destination object; ffnulla newCoordinatewill e created.
-
getX
public double getX(int index) - Specified by:
getXin interfaceCoordinateSequence- Parameters:
index- an index ≥0 and <size()
-
getY
public double getY(int index) - Specified by:
getYin interfaceCoordinateSequence- Parameters:
index- an index ≥0 and <size()
-
getOrdinate
public double getOrdinate(int index, int ordinateIndex) Returns the ordinate of a coordinate in this sequence.- Specified by:
getOrdinatein interfaceCoordinateSequence- Parameters:
index- an index ≥0 and <size()ordinateIndex- 0 for the X ordinate or 1 for the Y ordinate- Returns:
- the ordinate value
- Throws:
IllegalArgumentException- ifordinateIndexis not either 0 or 1
-
size
public int size()- Specified by:
sizein interfaceCoordinateSequence
-
setOrdinate
public void setOrdinate(int index, int ordinateIndex, double value) Sets the ordinate of a coordinate in this sequence.- Specified by:
setOrdinatein interfaceCoordinateSequence- Parameters:
index- an index ≥0 and <size()ordinateIndex- 0 for the X ordinate or 1 for the Y ordinatevalue- the new ordinate value- Throws:
IllegalArgumentException- ifordinateIndexis not either 0 or 1
-
setX
public void setX(int index, double value) Sets the X ordinate of the point at the given index. Equivalent tosetOrdinate(int, int, double)(index, 0, value).- Parameters:
index- an index ≥0 and <size()value- the new value
-
setY
public void setY(int index, double value) Sets the Y ordinate of the point at the given index. Equivalent tosetOrdinate(int, int, double)(index, 1, value).- Parameters:
index- an index ≥0 and <size()value- the new value
-
setXY
public void setXY(int index, double x, double y) Sets the coordinate at the given index.- Parameters:
index- an index ≥0 and <size()x- the new X ordinate valuey- the new Y ordinate value
-
toCoordinateArray
Returns an array of newCoordinateobjects for the point values in this sequence.- Specified by:
toCoordinateArrayin interfaceCoordinateSequence- Returns:
- array of coordinates
-
expandEnvelope
Returns an envelope which containsenvand all points in this sequence. Ifenvcontains all points it is returned unchanged.- Specified by:
expandEnvelopein interfaceCoordinateSequence- Parameters:
env- the test envelope; ifnulla newEnvelopeis created- Returns:
- an envelope that includes
envplus all points in this sequence
-
clone
Creates a deep copy of this sequence.- Specified by:
clonein interfaceCoordinateSequence- Returns:
- a new sequence with values
-
copy
- Specified by:
copyin interfaceCoordinateSequence
-