Class Point

java.lang.Object
io.github.sebasbaumh.postgis.Geometry
io.github.sebasbaumh.postgis.Point
All Implemented Interfaces:
Serializable

@NonNullByDefault public class Point extends Geometry
Point geometry.
Author:
Sebastian Baumhekel
See Also:
  • Field Details

    • TYPE

      public static final int TYPE
      The 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 ordinate
      y - the latitude / y ordinate
    • Point

      public Point(double x, double y, double z)
      Constructs a new Point
      Parameters:
      x - the longitude / x ordinate
      y - the latitude / y ordinate
      z - the radius / height / elevation / z ordinate (can be Double.NaN for no coordinate)
    • Point

      public Point(double x, double y, double z, double m)
      Constructs a new Point
      Parameters:
      x - the longitude / x ordinate
      y - the latitude / y ordinate
      z - the radius / height / elevation / z ordinate (can be Double.NaN for no coordinate)
      m - measure (4th dimension)
  • Method Details

    • 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 class Geometry
      Returns:
      true if all checks are passed.
    • coordsAreEqual

      public boolean coordsAreEqual(Point other)
      Checks it the coordinates of the given Point are equal to this Point.
      Parameters:
      other - Point
      Returns:
      true on success, else false
    • copy

      public Point copy()
      Creates a copy of this Point.
      Returns:
      Point
    • distance

      public double distance(Point p)
      Calculates the distance to the given Point.
      Parameters:
      p - Point
      Returns:
      distance
    • equals

      public boolean equals(@Nullable Object other)
      Description copied from class: Geometry
      java.lang.Object equals implementation
      Overrides:
      equals in class Geometry
      Parameters:
      other - geometry to compare
      Returns:
      true if equal, false otherwise
    • getCoordinates

      public Iterable<Point> getCoordinates()
      Description copied from class: Geometry
      Gets the coordinates of this Geometry.
      Specified by:
      getCoordinates in class Geometry
      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 this Geometry.
      Specified by:
      getNumberOfCoordinates in class Geometry
      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()
      Overrides:
      hashCode in class Geometry
    • hasMeasure

      public boolean hasMeasure()
      Description copied from class: Geometry
      Returns whether we have a measure (4th dimension)
      Specified by:
      hasMeasure in class Geometry
      Returns:
      true if the geometry has a measure, false otherwise
    • is3d

      public boolean is3d()
      Description copied from class: Geometry
      Checks if this Geometry is 3d.
      Specified by:
      is3d in class Geometry
      Returns:
      true on success, else false
    • isEmpty

      public boolean isEmpty()
      Description copied from class: Geometry
      Ist this Geometry empty, so does it contain no coordinates or other geometries?
      Specified by:
      isEmpty in class Geometry
      Returns:
      true on success, else false
    • 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

      public Point to2d()
      Gets this Point as a 2d object.
      Returns:
      Point
    • toString

      public String toString()
      Overrides:
      toString in class Object