public final class CoordinateSequence2D extends Object implements com.vividsolutions.jts.geom.CoordinateSequence, Cloneable
CoordinateSequence
for 2D points.Constructor and Description |
---|
CoordinateSequence2D(double... xy)
Creates a new
CoordinateSequence2D object from a sequence of
(x,y) pairs. |
CoordinateSequence2D(int n)
Creates a new
CoordinateSequence2D object with the given
size. |
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Creates a deep copy of this sequence.
|
com.vividsolutions.jts.geom.Envelope |
expandEnvelope(com.vividsolutions.jts.geom.Envelope env)
Returns an envelope which contains
env and all points
in this sequence. |
com.vividsolutions.jts.geom.Coordinate |
getCoordinate(int index)
Gets coordinate values at the specified index.
|
void |
getCoordinate(int index,
com.vividsolutions.jts.geom.Coordinate coord)
Copies the requested coordinate in the sequence to the supplied
Coordinate object. |
com.vividsolutions.jts.geom.Coordinate |
getCoordinateCopy(int index)
Equivalent to
getCoordinate(int) . |
int |
getDimension()
Gets the dimension of points stored by this
CoordinateSequence2D . |
double |
getOrdinate(int index,
int ordinateIndex)
Returns the ordinate of a coordinate in this sequence.
|
double |
getX(int index) |
double |
getY(int index) |
void |
setOrdinate(int index,
int ordinateIndex,
double value)
Sets the ordinate of a coordinate in this sequence.
|
void |
setX(int index,
double value)
Sets the X ordinate of the point at the given index.
|
void |
setXY(int index,
double x,
double y)
Sets the coordinate at the given index.
|
void |
setY(int index,
double value)
Sets the Y ordinate of the point at the given index.
|
int |
size() |
com.vividsolutions.jts.geom.Coordinate[] |
toCoordinateArray()
Returns an array of new
Coordinate objects for the point values
in this sequence. |
public CoordinateSequence2D(int n)
CoordinateSequence2D
object with the given
size.n
- capacity (number of coordinates)public CoordinateSequence2D(double... xy)
CoordinateSequence2D
object 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);
xy
- x and y values ordered as x0, y0, x1, y1...
;
if null
an empty object is createdIllegalArgumentException
- if the number of values in xy
is
greater than 0 but not evenpublic int getDimension()
CoordinateSequence2D
.getDimension
in interface com.vividsolutions.jts.geom.CoordinateSequence
public com.vividsolutions.jts.geom.Coordinate getCoordinate(int index)
getCoordinate
in interface com.vividsolutions.jts.geom.CoordinateSequence
index
- an index ≥0 and < size()
Coordinate
objectpublic com.vividsolutions.jts.geom.Coordinate getCoordinateCopy(int index)
getCoordinate(int)
.getCoordinateCopy
in interface com.vividsolutions.jts.geom.CoordinateSequence
index
- an index ≥0 and < size()
Coordinate
objectpublic void getCoordinate(int index, com.vividsolutions.jts.geom.Coordinate coord)
Coordinate
object.getCoordinate
in interface com.vividsolutions.jts.geom.CoordinateSequence
index
- an index ≥0 and < size()
coord
- the destination object; ff null
a new
Coordinate
will e created.public double getX(int index)
getX
in interface com.vividsolutions.jts.geom.CoordinateSequence
index
- an index ≥0 and < size()
public double getY(int index)
getY
in interface com.vividsolutions.jts.geom.CoordinateSequence
index
- an index ≥0 and < size()
public double getOrdinate(int index, int ordinateIndex)
getOrdinate
in interface com.vividsolutions.jts.geom.CoordinateSequence
index
- an index ≥0 and < size()
ordinateIndex
- 0 for the X ordinate or 1 for the Y ordinateIllegalArgumentException
- if ordinateIndex
is not
either 0 or 1public int size()
size
in interface com.vividsolutions.jts.geom.CoordinateSequence
public void setOrdinate(int index, int ordinateIndex, double value)
setOrdinate
in interface com.vividsolutions.jts.geom.CoordinateSequence
index
- an index ≥0 and < size()
ordinateIndex
- 0 for the X ordinate or 1 for the Y ordinatevalue
- the new ordinate valueIllegalArgumentException
- if ordinateIndex
is not
either 0 or 1public void setX(int index, double value)
setOrdinate(int, int, double)
(index, 0, value).index
- an index ≥0 and < size()
value
- the new valuepublic void setY(int index, double value)
setOrdinate(int, int, double)
(index, 1, value).index
- an index ≥0 and < size()
value
- the new valuepublic void setXY(int index, double x, double y)
index
- an index ≥0 and < size()
x
- the new X ordinate valuey
- the new Y ordinate valuepublic com.vividsolutions.jts.geom.Coordinate[] toCoordinateArray()
Coordinate
objects for the point values
in this sequence.toCoordinateArray
in interface com.vividsolutions.jts.geom.CoordinateSequence
public com.vividsolutions.jts.geom.Envelope expandEnvelope(com.vividsolutions.jts.geom.Envelope env)
env
and all points
in this sequence. If env
contains all points it is
returned unchanged.expandEnvelope
in interface com.vividsolutions.jts.geom.CoordinateSequence
env
- the test envelope; if null
a new Envelope
is createdenv
plus all points
in this sequenceCopyright © 2006–2018 GeoSolutions. All rights reserved.