Package io.github.sebasbaumh.postgis
Class Point
java.lang.Object
io.github.sebasbaumh.postgis.Geometry
io.github.sebasbaumh.postgis.Point
- All Implemented Interfaces:
Serializable
Point geometry.
- Author:
- Sebastian Baumhekel
- See Also:
-
Field Summary
FieldsFields inherited from class io.github.sebasbaumh.postgis.Geometry
UNKNOWN_SRID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDo some internal consistency checks on the geometry.booleancoordsAreEqual(Point other) copy()Creates a copy of thisPoint.doubleCalculates the distance to the givenPoint.booleanjava.lang.Object equals implementationGets the coordinates of thisGeometry.doublegetM()Gets the measurement.intGets the number of coordinates of thisGeometry.doublegetX()Gets the X-coordinate.doublegetY()Gets the Y-coordinate.doublegetZ()Gets the Z-coordinate.inthashCode()booleanReturns whether we have a measure (4th dimension)booleanis3d()Checks if thisGeometryis 3d.booleanisEmpty()Ist thisGeometryempty, so does it contain no coordinates or other geometries?voidsetM(double m) Sets the measurement.voidsetX(double x) Sets the X-coordinate.voidsetY(double y) Sets the Y-coordinate.voidsetZ(double z) Sets the Z-coordinate.to2d()Gets thisPointas a 2d object.toString()
-
Field Details
-
TYPE
public static final int TYPEThe OGIS geometry type number for points.- See Also:
-
-
Constructor Details
-
Point
public Point()Constructs an empty instance. -
Point
public Point(double x, double y) Constructs a new Point- Parameters:
x- the longitude / x ordinatey- the latitude / y ordinate
-
Point
public Point(double x, double y, double z) Constructs a new Point- Parameters:
x- the longitude / x ordinatey- the latitude / y ordinatez- the radius / height / elevation / z ordinate (can beDouble.NaNfor no coordinate)
-
Point
public Point(double x, double y, double z, double m) Constructs a new Point- Parameters:
x- the longitude / x ordinatey- the latitude / y ordinatez- the radius / height / elevation / z ordinate (can beDouble.NaNfor no coordinate)m- measure (4th dimension)
-
-
Method Details
-
checkConsistency
public boolean checkConsistency()Description copied from class:GeometryDo some internal consistency checks on the geometry. Currently, all Geometries must have a valid dimension (2 or 3) and a valid type. Composed geometries must have all equal SRID, dimensionality and measures, as well as that they do not contain NULL or inconsistent subgeometries. BinaryParser and WKTParser should only generate consistent geometries. BinaryWriter may produce invalid results on inconsistent geometries.- Overrides:
checkConsistencyin classGeometry- Returns:
- true if all checks are passed.
-
coordsAreEqual
- Parameters:
other-Point- Returns:
- true on success, else false
-
copy
Creates a copy of thisPoint.- Returns:
Point
-
distance
Calculates the distance to the givenPoint.- Parameters:
p-Point- Returns:
- distance
-
equals
Description copied from class:Geometryjava.lang.Object equals implementation -
getCoordinates
Description copied from class:GeometryGets the coordinates of thisGeometry.- Specified by:
getCoordinatesin classGeometry- Returns:
- coordinates
-
getM
public double getM()Gets the measurement.- Returns:
- measurement on success, else
Double.NaN
-
getNumberOfCoordinates
public int getNumberOfCoordinates()Description copied from class:GeometryGets the number of coordinates of thisGeometry.- Specified by:
getNumberOfCoordinatesin classGeometry- Returns:
- number of coordinates
-
getX
public double getX()Gets the X-coordinate.- Returns:
- X-coordinate on success, else
Double.NaN
-
getY
public double getY()Gets the Y-coordinate.- Returns:
- Y-coordinate on success, else
Double.NaN
-
getZ
public double getZ()Gets the Z-coordinate.- Returns:
- Z-coordinate on success, else
Double.NaN
-
hashCode
public int hashCode() -
hasMeasure
public boolean hasMeasure()Description copied from class:GeometryReturns whether we have a measure (4th dimension)- Specified by:
hasMeasurein classGeometry- Returns:
- true if the geometry has a measure, false otherwise
-
is3d
public boolean is3d()Description copied from class:GeometryChecks if thisGeometryis 3d. -
isEmpty
public boolean isEmpty()Description copied from class:GeometryIst thisGeometryempty, so does it contain no coordinates or other geometries? -
setM
public void setM(double m) Sets the measurement.- Parameters:
m- measurement
-
setX
public void setX(double x) Sets the X-coordinate.- Parameters:
x- X-coordinate
-
setY
public void setY(double y) Sets the Y-coordinate.- Parameters:
y- Y-coordinate
-
setZ
public void setZ(double z) Sets the Z-coordinate.- Parameters:
z- Z-coordinate
-
to2d
Gets thisPointas a 2d object.- Returns:
Point
-
toString
-