Coordinate class
A lightweight class used to store coordinates on the 2-dimensional Cartesian plane.
It is distinct from {@link Point}, which is a subclass of {@link Geometry}.
Unlike objects of type {@link 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.
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.
Apart from the basic accessor functions, JTS supports
only specific operations involving the Z-ordinate.
Implementations may optionally support Z-ordinate and M-measure values as appropriate for a {@link CoordinateSequence}. Use of {@link #getZ()} and {@link #getM()} accessors, or {@link #getOrdinate(int)} are recommended.
@version 1.16
- Implemented types
- Implementers
Constructors
- Coordinate(double x, double y)
-
Constructs a
Coordinate
at (x,y,NaN). - Coordinate.empty2D()
-
Constructs a
Coordinate
at (0,0,NaN). - Coordinate.fromCoordinate(Coordinate c)
-
Constructs a
Coordinate
having the same (x,y,z) values asother
. - Coordinate.fromXYZ(double x, double y, double z)
-
Constructs a
Coordinate
at (x,y,z). - Coordinate.fromYX(double y, double x)
Properties
Methods
-
clone(
) → Object -
compareTo(
Coordinate other) → int -
Compares this {@link Coordinate} with the specified {@link Coordinate} for order.
This method ignores the z value when making the comparison.
Returns:
override
-
copy(
) → Coordinate - Creates a copy of this Coordinate.
-
distance(
Coordinate c) → double - Computes the 2-dimensional Euclidean distance to another location. The Z-ordinate is ignored.
-
distance3D(
Coordinate c) → double - Computes the 3-dimensional Euclidean distance to another location.
-
equalInZ(
Coordinate c, double tolerance) → bool - Tests if another coordinate has the same value for Z, within a tolerance.
-
equals(
Object other) → bool -
Returns
true
ifother
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. -
equals2D(
Coordinate other) → bool -
Returns whether the planar projections of the two
Coordinate
s are equal. -
equals2DWithTolerance(
Coordinate c, double tolerance) → bool - Tests if another Coordinate has the same values for the X and Y ordinates, within a specified tolerance value. The Z ordinate is ignored.
-
equals3D(
Coordinate other) → bool - Tests if another coordinate has the same values for the X, Y and Z ordinates.
-
getM(
) → double - Retrieves the value of the measure, if present. If no measure value is present returns NaN.
-
getOrdinate(
int ordinateIndex) → double - Gets the ordinate value for the given index.
-
getX(
) → double - Retrieves the value of the X ordinate.
-
getY(
) → double - Retrieves the value of the Y ordinate.
-
getZ(
) → double - Retrieves the value of the Z ordinate, if present. If no Z value is present returns NaN.
-
isValid(
) → bool - Tests if the coordinate has valid X and Y ordinate values. An ordinate value is valid iff it is finite.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setCoordinate(
Coordinate other) → void -
Sets this
Coordinate
s (x,y,z) values to that ofother
. -
setM(
double m) → void - Sets the measure value, if supported.
-
setOrdinate(
int ordinateIndex, double value) → void - Sets the ordinate for the given index to a given value.
-
setX(
double x) → void - Sets the X ordinate value.
-
setY(
double y) → void - Sets the Y ordinate value.
-
setZ(
double z) → void - Sets the Z ordinate value.
-
toString(
) → String -
Returns a
String
of the form (x,y,z) .override
Operators
-
operator +(
Coordinate other) → Coordinate -
Returns the (vector-) sum of this and
other
. -
operator -(
Coordinate other) → Coordinate -
operator ==(
Object o) → bool -
The equality operator.
override
Static Properties
- NULL_ORDINATE → double
-
The value used to indicate a null or missing ordinate value.
In particular, used for the value of ordinates for dimensions
greater than the defined dimension of a coordinate.
final