public class Coordinate extends Objectimplements Comparable , Cloneable , Serializable
Point
, which is a subclass of
Geometry
. Unlike objects of type
Point
(which contain additional information such as an envelope, a precision model, and spatial reference system information), a
Coordinate
only contains ordinate values and accessor methods.
Coordinate
s are two-dimensional points, with an additional Z-ordinate. JTS does not support any operations on the Z-ordinate except the basic accessor functions. If an Z-ordinate value is not specified or not defined, constructed coordinates have a Z-ordinate of NaN
(which is also the value of NULL_ORDINATE
). The standard comparison functions ignore the Z-ordinate.
Modifier and Type | Class and Description |
---|---|
static class |
Coordinate
Compares two
Coordinate s, allowing for either a 2-dimensional or 3-dimensional comparison, and handling NaN values correctly.
|
Modifier and Type | Field and Description |
---|---|
static double |
NULL_ORDINATE
The value used to indicate a null or missing ordinate value.
|
double |
x
The x-coordinate.
|
static int |
X
Standard ordinate index values
|
double |
y
The y-coordinate.
|
static int |
Y
|
double |
z
The z-coordinate.
|
static int |
Z
|
Constructor and Description |
---|
Coordinate()
Constructs a
Coordinate at (0,0,NaN).
|
Coordinate(Coordinate
Constructs a
Coordinate having the same (x,y,z) values as
other .
|
Coordinate(double x, double y)
Constructs a
Coordinate at (x,y,NaN).
|
Coordinate(double x, double y, double z)
Constructs a
Coordinate at (x,y,z).
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
|
int |
compareTo(Object
Compares this
Coordinate with the specified
Coordinate for order.
|
double |
distance(Coordinate
Computes the 2-dimensional Euclidean distance to another location.
|
boolean |
equals(Object
Returns
true if
other has the same values for the x and y ordinates.
|
boolean |
equals2D(Coordinate
Returns whether the planar projections of the two
Coordinate s are equal.
|
boolean |
equals3D(Coordinate
Returns
true if
other has the same values for x, y and z.
|
double |
getOrdinate(int ordinateIndex)
Gets the ordinate value for the given index.
|
int |
hashCode()
Gets a hashcode for this coordinate.
|
static int |
hashCode(double x)
Computes a hash code for a double value, using the algorithm from Joshua Bloch's book
Effective Java"
|
void |
setCoordinate(Coordinate
Sets this
Coordinate s (x,y,z) values to that of
other .
|
void |
setOrdinate(int ordinateIndex, double value)
Sets the ordinate for the given index to a given value.
|
String |
toString()
Returns a
String of the form
(x,y,z) .
|
public static final double NULL_ORDINATE
public static final int X
public static final int Y
public static final int Z
public double x
public double y
public double z
public Coordinate(double x, double y, double z)
Coordinate
at (x,y,z).
x
- the x-value
y
- the y-value
z
- the z-value
public Coordinate()
Coordinate
at (0,0,NaN).
public Coordinate(Coordinatec)
Coordinate
having the same (x,y,z) values as
other
.
c
- the
Coordinate
to copy.
public Coordinate(double x, double y)
Coordinate
at (x,y,NaN).
x
- the x-value
y
- the y-value
public void setCoordinate(Coordinateother)
Coordinate
s (x,y,z) values to that of
other
.
other
- the
Coordinate
to copy
public double getOrdinate(int ordinateIndex)
X
,
Y
, and
Z
.
ordinateIndex
- the ordinate index
IllegalArgumentException
- if the index is not valid
public void setOrdinate(int ordinateIndex, double value)
X
,
Y
, and
Z
.
ordinateIndex
- the ordinate index
value
- the value to set
IllegalArgumentException
- if the index is not valid
public boolean equals2D(Coordinateother)
Coordinate
s are equal.
other
- a
Coordinate
with which to do the 2D comparison.
true
if the x- and y-coordinates are equal; the z-coordinates do not have to be equal.
public boolean equals(Objectother)
true
if
other
has the same values for the x and y ordinates. Since Coordinates are 2.5D, this routine ignores the z value when making the comparison.
public int compareTo(Objecto)
Coordinate
with the specified
Coordinate
for order. This method ignores the z value when making the comparison. Returns:
compareTo
in interface
Comparable
o
- the
Coordinate
with which this
Coordinate
is being compared
Coordinate
is less than, equal to, or greater than the specified
Coordinate
public boolean equals3D(Coordinateother)
true
if
other
has the same values for x, y and z.
other
- a
Coordinate
with which to do the 3D comparison.
true
if
other
is a
Coordinate
with the same values for x, y and z.
public StringtoString()
String
of the form
(x,y,z) .
public Objectclone()
public double distance(Coordinatep)
p
- a point
public int hashCode()
public static int hashCode(double x)