Package io.github.sebasbaumh.postgis
Class Point
- java.lang.Object
-
- io.github.sebasbaumh.postgis.Geometry
-
- io.github.sebasbaumh.postgis.Point
-
- All Implemented Interfaces:
java.io.Serializable
@NonNullByDefault public class Point extends Geometry
Point geometry.- Author:
- Sebastian Baumhekel
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
TYPE
The OGIS geometry type number for points.-
Fields inherited from class io.github.sebasbaumh.postgis.Geometry
UNKNOWN_SRID
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkConsistency()
Do some internal consistency checks on the geometry.boolean
coordsAreEqual(Point other)
Point
copy()
Creates a copy of thisPoint
.double
distance(Point p)
Calculates the distance to the givenPoint
.boolean
equals(java.lang.Object other)
java.lang.Object equals implementationjava.lang.Iterable<Point>
getCoordinates()
Gets the coordinates of thisGeometry
.double
getM()
Gets the measurement.int
getNumberOfCoordinates()
Gets the number of coordinates of thisGeometry
.double
getX()
Gets the X-coordinate.double
getY()
Gets the Y-coordinate.double
getZ()
Gets the Z-coordinate.int
hashCode()
boolean
hasMeasure()
Returns whether we have a measure (4th dimension)boolean
is3d()
Checks if thisGeometry
is 3d.boolean
isEmpty()
Ist thisGeometry
empty, so does it contain no coordinates or other geometries?void
setM(double m)
Sets the measurement.void
setX(double x)
Sets the X-coordinate.void
setY(double y)
Sets the Y-coordinate.void
setZ(double z)
Sets the Z-coordinate.Point
to2d()
Gets thisPoint
as a 2d object.
-
-
-
Field Detail
-
TYPE
public static final int TYPE
The OGIS geometry type number for points.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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
-
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 ordinatem
- measure (4th dimension)
-
-
Method Detail
-
checkConsistency
public boolean checkConsistency()
Description copied from class:Geometry
Do 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:
checkConsistency
in classGeometry
- Returns:
- true if all checks are passed.
-
coordsAreEqual
public boolean coordsAreEqual(Point other)
- Parameters:
other
-Point
- Returns:
- true on success, else false
-
distance
public double distance(Point p)
Calculates the distance to the givenPoint
.- Parameters:
p
-Point
- Returns:
- distance
-
equals
public boolean equals(@Nullable java.lang.Object other)
Description copied from class:Geometry
java.lang.Object equals implementation
-
getCoordinates
public java.lang.Iterable<Point> getCoordinates()
Description copied from class:Geometry
Gets the coordinates of thisGeometry
.- Specified by:
getCoordinates
in 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:Geometry
Gets the number of coordinates of thisGeometry
.- Specified by:
getNumberOfCoordinates
in 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
-
hasMeasure
public boolean hasMeasure()
Description copied from class:Geometry
Returns whether we have a measure (4th dimension)- Specified by:
hasMeasure
in classGeometry
- Returns:
- true if the geometry has a measure, false otherwise
-
isEmpty
public boolean isEmpty()
Description copied from class:Geometry
Ist thisGeometry
empty, 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
-
-