Class Point

All Implemented Interfaces:
Geometry, PointTypeGeometry, Serializable, Cloneable
Direct Known Subclasses:
Point.Double, Point.Float, PointM

public abstract class Point extends DefaultGeometry implements PointTypeGeometry
See Also:
  • Field Details

    • PRECISION_FLOAT

      public static final int PRECISION_FLOAT
      A constant used to represent the precision of a single-precision floating point decimal.
      See Also:
    • PRECISION_DOUBLE

      public static final int PRECISION_DOUBLE
      A constant used to represent the precision of a double-precision floating point decimal.
      See Also:
  • Constructor Details

    • Point

      protected Point()
      This is an abstract class that cannot be instantiated directly. Type-specific implementation subclasses are available for instantiation and provide a number of formats for storing the information necessary to satisfy the various accessor methods below.
  • Method Details

    • getCenteredPoint

      public Point getCenteredPoint()
      Description copied from interface: Geometry
      This method returns a point that is typically centered on the geometry. If the geometry is a point, the point is returned. If it is a line, a point on the curve interpolated at 50% is returned. If the geometry is a surface, the centroid is returned if it is inside the polygon, if not, a point inside the polygon (but likely not exactly in the center) will be returned. If the geometry is a collection, the method is called on the first part of the collection.
      Specified by:
      getCenteredPoint in interface Geometry
      Returns:
      a point likely at the center of the geometry
    • getX

      public abstract double getX()
      Returns the X coordinate of this Point in double precision.
      Returns:
      the X coordinate of this Point.
    • getY

      public abstract double getY()
      Returns the Y coordinate of this Point in double precision.
      Returns:
      the Y coordinate of this Point.
    • setX

      public abstract void setX(double x)
      Returns the X coordinate of this Point in double precision.
      Parameters:
      x - the X coordinate of this Point.
    • setY

      public abstract void setY(double y)
      Sets the Y coordinate of this Point in double precision.
      Parameters:
      y - the Y coordinate of this Point.
    • setLocation

      public abstract void setLocation(double x, double y)
      Sets the location of this Point to the specified double coordinates.
      Parameters:
      x - x the X coordinate of this Point.
      y - y the Y coordinate of this Point.
    • translate

      public abstract void translate(double dx, double dy)
      Translates the point by the specified offset
      Specified by:
      translate in interface Geometry
      Parameters:
      dx - x value of the translation
      dy - y value of the translation
    • translate

      public void translate(Point p)
      Translates the point by the specified offset
      Parameters:
      p - the X and Y values of the translation
    • setLocation

      public void setLocation(Point p)
      Sets the location of this Point to the same coordinates as the specified Point object.
      Parameters:
      p - the specified Point the which to set this Point
      Since:
      1.2
    • distanceSq

      public static double distanceSq(double X1, double Y1, double X2, double Y2)
      Returns the square of the distance between two points.
      Parameters:
      X1 - the X coordinate of the first point
      Y1 - the Y coordinate of the first point
      X2 - the X coordinate of the second point
      Y2 - the Y coordinate of the second point
      Returns:
      the square of the distance between the two sets of specified coordinates.
    • distance

      public static double distance(double X1, double Y1, double X2, double Y2)
      Returns the distance between two points.
      Parameters:
      X1 - the X coordinate of the first point
      Y1 - the Y coordinate of the first point
      X2 - the X coordinate of the second point
      Y2 - the Y coordinate of the second point
      Returns:
      the distance between the two sets of specified coordinates.
    • distanceSq

      public double distanceSq(double PX, double PY)
      Returns the square of the distance from this Point to a specified point.
      Parameters:
      PX - the X coordinate of the specified point
      PY - the Y coordinate of the specified point
      Returns:
      the square of the distance between this Point and the specified point.
    • distanceSq

      public double distanceSq(Point pt)
      Returns the square of the distance from this Point to a specified Point.
      Parameters:
      pt - the specified Point
      Returns:
      the square of the distance between this Point to a specified Point.
    • distance

      public double distance(double PX, double PY)
      Returns the distance from this Point to a specified point.
      Parameters:
      PX - the X coordinate of the specified point
      PY - the Y coordinate of the specified point
      Returns:
      the distance between this Point and a specified point.
    • distance

      public double distance(Point pt)
      Returns the distance from this Point to a specified Point.
      Parameters:
      pt - the specified Point
      Returns:
      the distance between this Point and the specified Point.
    • clone

      public abstract Point clone()
      Clones this geometry.
      Specified by:
      clone in interface Geometry
      Specified by:
      clone in class DefaultGeometry
      Returns:
      a deep copy of the current geometry.
    • hashCode

      public int hashCode()
      Returns the hashcode for this Point.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code for this Point.
    • equals

      public boolean equals(Object obj)
      Determines whether two points are equal. Two instances of Point are equal if the values of their x and y member fields, representing their position in the coordinate space, are the same.
      Overrides:
      equals in class Object
      Parameters:
      obj - an object to be compared with this Point
      Returns:
      true if the object to be compared is an instance of Point and has the same values; false otherwise.
    • equals

      public boolean equals(Point point)
    • spatiallyEquals

      public boolean spatiallyEquals(Geometry geometry, PrecisionModel precisionModel)
      Description copied from interface: Geometry
      Tests if this geometry is equal to the argument, on a topological point of view.
      Specified by:
      spatiallyEquals in interface Geometry
      Parameters:
      geometry - the geometry to be tested.
      precisionModel - the precision model to use while comparing geometries.
      Returns:
      whether both geometries are spatially equals.
    • spatiallyEquals

      public boolean spatiallyEquals(Point point, double tolerance)
    • pointIterator

      public PointGeometryIterator pointIterator()
      Specified by:
      pointIterator in interface PointTypeGeometry
    • getGeometryId

      public short getGeometryId()
      Returns the geometry class id. This method is useful for geometry serialization.
      Specified by:
      getGeometryId in interface Geometry
      Returns:
      the geometry id.
    • getGeometryType

      public int getGeometryType()
      Returns the geometry type for this geometry.
      Specified by:
      getGeometryType in interface Geometry
      Returns:
      the geometry type.
      See Also:
    • transform

      public Geometry transform(Transformation tr)
      Creates a clone of the current geometry and returns the new instance transformed with the specified geometry transformation.
      The returned geometry can be of any geometry types after the transformation.
      Specified by:
      transform in interface Geometry
      Parameters:
      tr - the transformation to apply.
      Returns:
      the newly created and transformed geometry instance.
    • boundary

      public Geometry boundary()
      Returns the boundary of this geometry as a line string.
      Always returns null.
      Specified by:
      boundary in interface Geometry
      Returns:
      a line string which defines the boundary of the current geometry.
    • createBounds

      public void createBounds()
      Updates the geometry bounds from the current geometry.
      Has no effect on the Point class.
      Specified by:
      createBounds in interface Geometry
    • area

      public double area()
      Description copied from interface: Geometry
      Returns the geometry area. If the geometry is not a surface, then 0 shall be returned.
      Specified by:
      area in interface Geometry
      Returns:
      the geometry area.
    • length

      public double length()
      Description copied from interface: Geometry
      Returns the geometry length. If the geometry is a surface, then the geometry perimeter shall be returned.
      Specified by:
      length in interface Geometry
      Returns:
      the geometry length.