Class PointImpl

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private double x  
      private double y  
      • Fields inherited from class org.locationtech.spatial4j.shape.BaseShape

        ctx
    • Constructor Summary

      Constructors 
      Constructor Description
      PointImpl​(double x, double y, SpatialContext ctx)
      A simple constructor without normalization / validation.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)
      The sub-classes of Shape generally implement the same contract for Object.equals(Object) and Object.hashCode() amongst the same sub-interface type.
      static boolean equals​(Point thiz, java.lang.Object o)
      All Point implementations should use this definition of Object.equals(Object).
      double getArea​(SpatialContext ctx)
      Calculates the area of the shape, in square-degrees.
      Rectangle getBoundingBox()
      Get the bounding box for this Shape.
      Circle getBuffered​(double distance, SpatialContext ctx)
      Returns a buffered version of this shape.
      PointImpl getCenter()
      Returns the center point of this shape.
      double getLat()
      Convenience method that usually maps on Point.getY()
      double getLon()
      Convenience method that usually maps on Point.getX()
      double getX()
      The X coordinate, or Longitude in geospatial contexts.
      double getY()
      The Y coordinate, or Latitude in geospatial contexts.
      boolean hasArea()
      Does the shape have area? This will be false for points and lines.
      int hashCode()  
      static int hashCode​(Point thiz)
      All Point implementations should use this definition of Object.hashCode().
      boolean isEmpty()
      Shapes can be "empty", which is to say it exists nowhere.
      SpatialRelation relate​(Shape other)
      Describe the relationship between the two objects.
      void reset​(double x, double y)
      Expert: Resets the state of this shape given the arguments.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.locationtech.spatial4j.shape.Shape

        getContext
    • Field Detail

      • x

        private double x
      • y

        private double y
    • Constructor Detail

      • PointImpl

        public PointImpl​(double x,
                         double y,
                         SpatialContext ctx)
        A simple constructor without normalization / validation.
    • Method Detail

      • isEmpty

        public boolean isEmpty()
        Description copied from interface: Shape
        Shapes can be "empty", which is to say it exists nowhere. The underlying coordinates are typically NaN.
        Specified by:
        isEmpty in interface Shape
      • reset

        public void reset​(double x,
                          double y)
        Description copied from interface: Point
        Expert: Resets the state of this shape given the arguments. This is a performance feature to avoid excessive Shape object allocation as well as some argument error checking. Mutable shapes is error-prone so use with care.
        Specified by:
        reset in interface Point
      • getX

        public double getX()
        Description copied from interface: Point
        The X coordinate, or Longitude in geospatial contexts.
        Specified by:
        getX in interface Point
      • getY

        public double getY()
        Description copied from interface: Point
        The Y coordinate, or Latitude in geospatial contexts.
        Specified by:
        getY in interface Point
      • getLat

        public double getLat()
        Description copied from interface: Point
        Convenience method that usually maps on Point.getY()
        Specified by:
        getLat in interface Point
      • getLon

        public double getLon()
        Description copied from interface: Point
        Convenience method that usually maps on Point.getX()
        Specified by:
        getLon in interface Point
      • getBoundingBox

        public Rectangle getBoundingBox()
        Description copied from interface: Shape
        Get the bounding box for this Shape. This means the shape is within the bounding box and that it touches each side of the rectangle.

        Postcondition: this.getBoundingBox().relate(this) == CONTAINS

        Specified by:
        getBoundingBox in interface Shape
      • getCenter

        public PointImpl getCenter()
        Description copied from interface: Shape
        Returns the center point of this shape. This is usually the same as getBoundingBox().getCenter() but it doesn't have to be.

        Postcondition: this.relate(this.getCenter()) == CONTAINS

        Specified by:
        getCenter in interface Shape
      • getBuffered

        public Circle getBuffered​(double distance,
                                  SpatialContext ctx)
        Description copied from interface: Shape
        Returns a buffered version of this shape. The buffer is usually a rounded-corner buffer, although some shapes might buffer differently. This is an optional operation.
        Specified by:
        getBuffered in interface Shape
        Returns:
        Not null, and the returned shape should contain the current shape.
      • relate

        public SpatialRelation relate​(Shape other)
        Description copied from interface: Shape
        Describe the relationship between the two objects. For example
        • this is WITHIN other
        • this CONTAINS other
        • this is DISJOINT other
        • this INTERSECTS other
        Note that a Shape implementation may choose to return INTERSECTS when the true answer is WITHIN or CONTAINS for performance reasons. If a shape does this then it must document when it does. Ideally the shape will not do this approximation in all circumstances, just sometimes.

        If the shapes are equal then the result is CONTAINS (preferred) or WITHIN.

        Specified by:
        relate in interface Shape
      • hasArea

        public boolean hasArea()
        Description copied from interface: Shape
        Does the shape have area? This will be false for points and lines. It will also be false for shapes that normally have area but are constructed in a degenerate case as to not have area (e.g. a circle with 0 radius or rectangle with no height or no width).
        Specified by:
        hasArea in interface Shape
      • getArea

        public double getArea​(SpatialContext ctx)
        Description copied from interface: Shape
        Calculates the area of the shape, in square-degrees. If ctx is null then simple Euclidean calculations will be used. This figure can be an estimate.
        Specified by:
        getArea in interface Shape
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Description copied from interface: Shape
        The sub-classes of Shape generally implement the same contract for Object.equals(Object) and Object.hashCode() amongst the same sub-interface type. This means, for example, that multiple Point implementations of different classes are equal if they share the same x & y.
        Specified by:
        equals in interface Shape
        Overrides:
        equals in class java.lang.Object
      • equals

        public static boolean equals​(Point thiz,
                                     java.lang.Object o)
        All Point implementations should use this definition of Object.equals(Object).
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • hashCode

        public static int hashCode​(Point thiz)
        All Point implementations should use this definition of Object.hashCode().