kiwi-postgis
Version 0.1.0.0
|
A lightweight class used to store coordinates on the 2-dimensional Cartesian plane. More...
Classes | |
class | DimensionalComparator |
Compares two Coordinates, allowing for either a 2-dimensional or 3-dimensional comparison, and handling NaN values correctly. More... | |
Public Member Functions | |
Coordinate (double x, double y, double z) | |
Constructs a Coordinate at (x,y,z). More... | |
Coordinate () | |
Constructs a Coordinate at (0,0,NaN). More... | |
Coordinate (Coordinate c) | |
Constructs a Coordinate having the same (x,y,z) values as other . More... | |
Coordinate (double x, double y) | |
Constructs a Coordinate at (x,y,NaN). More... | |
void | setCoordinate (Coordinate other) |
Sets this Coordinate s (x,y,z) values to that of other . More... | |
double | getX () |
Retrieves the value of the X ordinate. More... | |
void | setX (double x) |
Sets the X ordinate value. More... | |
double | getY () |
Retrieves the value of the Y ordinate. More... | |
Date | getT () |
void | setY (double y) |
Sets the Y ordinate value. More... | |
double | getZ () |
Retrieves the value of the Z ordinate, if present. More... | |
void | setZ (double z) |
Sets the Z ordinate value. More... | |
void | setT (Date t) |
void | setT (Long t) |
double | getM () |
Retrieves the value of the measure, if present. More... | |
void | setM (double m) |
Sets the measure value, if supported. More... | |
double | getOrdinate (int ordinateIndex) |
Gets the ordinate value for the given index. More... | |
void | setOrdinate (int ordinateIndex, double value) |
Sets the ordinate for the given index to a given value. More... | |
boolean | equals2D (Coordinate other) |
Returns whether the planar projections of the two Coordinate s are equal. More... | |
boolean | equals2D (Coordinate c, double tolerance) |
Tests if another Coordinate has the same values for the X and Y ordinates, within a specified tolerance value. More... | |
boolean | equals3D (Coordinate other) |
Tests if another coordinate has the same values for the X, Y and Z ordinates. More... | |
boolean | equalInZ (Coordinate c, double tolerance) |
Tests if another coordinate has the same value for Z, within a tolerance. More... | |
boolean | equals (Object other) |
Returns true if other has the same values for the x and y ordinates. More... | |
int | compareTo (Coordinate o) |
Compares this Coordinate with the specified Coordinate for order. More... | |
String | toString () |
Returns a String of the form (x,y,z) . More... | |
Object | clone () |
Coordinate | copy () |
Creates a copy of this Coordinate. More... | |
double | distance (Coordinate c) |
Computes the 2-dimensional Euclidean distance to another location. More... | |
double | distance3D (Coordinate c) |
Computes the 3-dimensional Euclidean distance to another location. More... | |
int | hashCode () |
Gets a hashcode for this coordinate. More... | |
Static Public Member Functions | |
static int | hashCode (double x) |
Computes a hash code for a double value, using the algorithm from Joshua Bloch's book Effective Java" More... | |
Public Attributes | |
double | x |
The x-ordinate. More... | |
double | y |
The y-ordinate. More... | |
double | z |
The z-ordinate. More... | |
Date | t =null |
Static Public Attributes | |
static final double | NULL_ORDINATE = Double.NaN |
The value used to indicate a null or missing ordinate value. More... | |
static final int | X = 0 |
Standard ordinate index value for, where X is 0. More... | |
static final int | Y = 1 |
Standard ordinate index value for, where Y is 1. More... | |
static final int | T = 4 |
Standard ordinate index value for, where Y is 1. More... | |
static final int | Z = 2 |
Standard ordinate index value for, where Z is 2. More... | |
static final int | M = 3 |
Standard ordinate index value for, where M is 3. More... | |
Static Private Attributes | |
static final long | serialVersionUID = 6683108902428366910L |
A lightweight class used to store coordinates on the 2-dimensional Cartesian plane.
It is distinct from 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. 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 CoordinateSequence. Use of getZ() and getM() accessors, or getOrdinate(int) are recommended.
Coordinate | ( | double | x, |
double | y, | ||
double | z | ||
) |
Constructs a Coordinate
at (x,y,z).
x | the x-ordinate |
y | the y-ordinate |
z | the z-ordinate |
References Coordinate.x, Coordinate.y, and Coordinate.z.
Coordinate | ( | ) |
Constructs a Coordinate
at (0,0,NaN).
Referenced by Coordinate.clone(), Coordinate.compareTo(), and Coordinate.copy().
Coordinate | ( | Coordinate | c | ) |
Constructs a Coordinate
having the same (x,y,z) values as other
.
c | the Coordinate to copy. |
References Coordinate.getZ(), Coordinate.x, and Coordinate.y.
Coordinate | ( | double | x, |
double | y | ||
) |
Constructs a Coordinate
at (x,y,NaN).
x | the x-value |
y | the y-value |
References Coordinate.NULL_ORDINATE, Coordinate.x, and Coordinate.y.
Object clone | ( | ) |
References Coordinate.clone(), and Coordinate.Coordinate().
Referenced by Coordinate.clone().
int compareTo | ( | Coordinate | o | ) |
Compares this Coordinate with the specified Coordinate for order.
This method ignores the z value when making the comparison. Returns:
1 : this.x > other.x || ((this.x == other.x) && (this.y > other.y))
Note: This method assumes that ordinate values are valid numbers. NaN values are not handled correctly.
o | the Coordinate with which this Coordinate is being compared |
Coordinate
is less than, equal to, or greater than the specified Coordinate
References Coordinate.Coordinate(), Coordinate.x, and Coordinate.y.
Coordinate copy | ( | ) |
Creates a copy of this Coordinate.
References Coordinate.Coordinate().
double distance | ( | Coordinate | c | ) |
Computes the 2-dimensional Euclidean distance to another location.
The Z-ordinate is ignored.
c | a point |
References Coordinate.x, and Coordinate.y.
Referenced by LocatePoint.compute(), LocatePoint.pointAlongSegment(), and LongestLine.relation().
double distance3D | ( | Coordinate | c | ) |
Computes the 3-dimensional Euclidean distance to another location.
c | a coordinate |
References Coordinate.getZ(), Coordinate.x, and Coordinate.y.
boolean equalInZ | ( | Coordinate | c, |
double | tolerance | ||
) |
Tests if another coordinate has the same value for Z, within a tolerance.
c | a coordinate |
tolerance | the tolerance value |
References Coordinate.getZ().
boolean equals | ( | Object | other | ) |
Returns 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.
other | a Coordinate with which to do the comparison. |
true
if other
is a Coordinate
with the same values for the x and y ordinates. References Coordinate.equals2D().
boolean equals2D | ( | Coordinate | other | ) |
Returns whether the planar projections of the two 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. References Coordinate.x, and Coordinate.y.
Referenced by Coordinate.equals().
boolean equals2D | ( | Coordinate | c, |
double | tolerance | ||
) |
Tests if another Coordinate has the same values for the X and Y ordinates, within a specified tolerance value.
The Z ordinate is ignored.
c | a Coordinate with which to do the 2D comparison. |
tolerance | the tolerance value to use |
other
is a Coordinate
with the same values for X and Y. References Coordinate.x, and Coordinate.y.
boolean equals3D | ( | Coordinate | other | ) |
Tests if another coordinate has the same values for the X, Y and Z ordinates.
other | a Coordinate with which to do the 3D comparison. |
other
is a Coordinate
with the same values for X, Y and Z. References Coordinate.getZ(), Coordinate.x, and Coordinate.y.
double getM | ( | ) |
Retrieves the value of the measure, if present.
If no measure value is present returns NaN
.
NaN
Referenced by TWKBWriter.ExtendedPrecisionWriter.checkCoordinate(), Zmflag.operation(), and TWKBWriter.write().
double getOrdinate | ( | int | ordinateIndex | ) |
Gets the ordinate value for the given index.
The base implementation supports values for the index are X, Y, and Z.
ordinateIndex | the ordinate index |
IllegalArgumentException | if the index is not valid |
References Coordinate.getZ(), Coordinate.X, Coordinate.x, Coordinate.Y, Coordinate.y, and Coordinate.Z.
Date getT | ( | ) |
References Coordinate.t.
double getX | ( | ) |
Retrieves the value of the X ordinate.
References Coordinate.x.
Referenced by TWKBWriter.PrecisionWriter.checkCoordinate().
double getY | ( | ) |
Retrieves the value of the Y ordinate.
References Coordinate.y.
Referenced by TWKBWriter.PrecisionWriter.checkCoordinate().
double getZ | ( | ) |
Retrieves the value of the Z ordinate, if present.
If no Z value is present returns NaN
.
NaN
References Coordinate.z.
Referenced by TWKBWriter.ExtendedPrecisionWriter.checkCoordinate(), Coordinate.DimensionalComparator.compare(), Coordinate.Coordinate(), Coordinate.distance3D(), Coordinate.equalInZ(), Coordinate.equals3D(), Coordinate.getOrdinate(), Zmflag.operation(), Coordinate.setCoordinate(), Coordinate.toString(), and TWKBWriter.write().
int hashCode | ( | ) |
Gets a hashcode for this coordinate.
|
static |
Computes a hash code for a double value, using the algorithm from Joshua Bloch's book Effective Java"
x | the value to compute for |
void setCoordinate | ( | Coordinate | other | ) |
Sets this Coordinate
s (x,y,z) values to that of other
.
other | the Coordinate to copy |
References Coordinate.getZ(), Coordinate.x, and Coordinate.y.
void setM | ( | double | m | ) |
Sets the measure value, if supported.
m | the value to set as M |
Referenced by TWKBReader.ExtendedPrecisionReader.readPoint(), and TWKBReader.ExtendedPrecisionReader.readPointArray().
void setOrdinate | ( | int | ordinateIndex, |
double | value | ||
) |
Sets the ordinate for the given index to a given value.
The base implementation supported values for the index are X, Y, and Z.
ordinateIndex | the ordinate index |
value | the value to set |
IllegalArgumentException | if the index is not valid |
References Coordinate.setZ(), Coordinate.X, Coordinate.Y, and Coordinate.Z.
void setT | ( | Date | t | ) |
References Coordinate.t.
void setT | ( | Long | t | ) |
void setX | ( | double | x | ) |
void setY | ( | double | y | ) |
void setZ | ( | double | z | ) |
Sets the Z ordinate value.
z | the value to set as Z |
References Coordinate.z.
Referenced by TWKBReader.ExtendedPrecisionReader.readPoint(), TWKBReader.ExtendedPrecisionReader.readPointArray(), and Coordinate.setOrdinate().
String toString | ( | ) |
Returns a String
of the form (x,y,z) .
String
of the form (x,y,z) References Coordinate.getZ().
Referenced by AsOSMLink.operation().
|
static |
Standard ordinate index value for, where M is 3.
This constant assumes XYZM coordinate sequence definition, please check this assumption using getDimension() and getMeasures() before use.
|
static |
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.
Referenced by Coordinate.Coordinate().
|
staticprivate |
|
static |
Standard ordinate index value for, where Y is 1.
Date t =null |
Referenced by Coordinate.getT(), and Coordinate.setT().
|
static |
Standard ordinate index value for, where X is 0.
Referenced by Coordinate.getOrdinate(), and Coordinate.setOrdinate().
double x |
The x-ordinate.
Referenced by RasterToWorldCoordX.attribute(), WorldToRasterCoordX.attribute(), Coordinate.DimensionalComparator.compare(), Coordinate.compareTo(), Coordinate.Coordinate(), Coordinate.distance(), Coordinate.distance3D(), Coordinate.equals2D(), Coordinate.equals3D(), GeometricMedian.getGeoMedian(), Coordinate.getOrdinate(), Coordinate.getX(), IsConvex.isConvex(), LineLength3D.length3D(), AsOSMLink.operation(), LocatePoint.pointAlongSegment(), LocatePoint.pointAlongSegmentByFraction(), Coordinate.setCoordinate(), and Coordinate.setX().
|
static |
Standard ordinate index value for, where Y is 1.
Referenced by Coordinate.getOrdinate(), and Coordinate.setOrdinate().
double y |
The y-ordinate.
Referenced by RasterToWorldCoordY.attribute(), WorldToRasterCoordY.attribute(), Coordinate.DimensionalComparator.compare(), Coordinate.compareTo(), Coordinate.Coordinate(), Coordinate.distance(), Coordinate.distance3D(), Coordinate.equals2D(), Coordinate.equals3D(), GeometricMedian.getGeoMedian(), Coordinate.getOrdinate(), Coordinate.getY(), IsConvex.isConvex(), LineLength3D.length3D(), AsOSMLink.operation(), LocatePoint.pointAlongSegment(), LocatePoint.pointAlongSegmentByFraction(), Coordinate.setCoordinate(), and Coordinate.setY().
|
static |
Standard ordinate index value for, where Z is 2.
This constant assumes XYZM coordinate sequence definition, please check this assumption using getDimension() and getMeasures() before use.
Referenced by Coordinate.getOrdinate(), and Coordinate.setOrdinate().
double z |
The z-ordinate.
Direct access to this field is discouraged; use getZ().
Referenced by Coordinate.Coordinate(), Coordinate.getZ(), LineLength3D.length3D(), and Coordinate.setZ().