Class Circle

java.lang.Object
org.opensearch.geometry.Circle
All Implemented Interfaces:
Geometry

public class Circle extends Object implements Geometry
Circle geometry (not part of WKT standard, but used in opensearch) defined by lat/lon coordinates of the center in degrees and optional altitude in meters.
  • Field Details

    • EMPTY

      public static final Circle EMPTY
      Empty circle : x=0, y=0, z=NaN radius=-1
  • Constructor Details

    • Circle

      public Circle(double x, double y, double radiusMeters)
      Create a circle with no altitude.
      Parameters:
      x - Longitude of the center of the circle in degrees
      y - Latitude of the center of the circle in degrees
      radiusMeters - Radius of the circle in meters
    • Circle

      public Circle(double x, double y, double z, double radiusMeters)
      Create a circle with altitude.
      Parameters:
      x - Longitude of the center of the circle in degrees
      y - Latitude of the center of the circle in degrees
      z - Altitude of the center of the circle in meters
      radiusMeters - Radius of the circle in meters
  • Method Details

    • type

      public ShapeType type()
      Specified by:
      type in interface Geometry
      Returns:
      The type of this geometry (always ShapeType.CIRCLE)
    • getY

      public double getY()
      Returns:
      The y (latitude) of the center of the circle in degrees
    • getX

      public double getX()
      Returns:
      The x (longitude) of the center of the circle in degrees
    • getRadiusMeters

      public double getRadiusMeters()
      Returns:
      The radius of the circle in meters
    • getZ

      public double getZ()
      Returns:
      The altitude of the center of the circle in meters (NaN if irrelevant)
    • getLat

      public double getLat()
      Returns:
      The latitude (y) of the center of the circle in degrees
    • getLon

      public double getLon()
      Returns:
      The longitude (x) of the center of the circle in degrees
    • getAlt

      public double getAlt()
      Returns:
      The altitude (z) of the center of the circle in meters (NaN if irrelevant)
    • equals

      public boolean equals(Object o)
      Compare this circle to another circle.
      Overrides:
      equals in class Object
      Parameters:
      o - The other circle
      Returns:
      True if the two circles are equal in all their properties. False if null or different.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      Returns:
      The hashcode of this circle.
    • visit

      public <T, E extends Exception> T visit(GeometryVisitor<T,E> visitor) throws E
      Visit this circle with a GeometryVisitor.
      Specified by:
      visit in interface Geometry
      Type Parameters:
      T - The return type of the visitor
      E - The exception type of the visitor
      Parameters:
      visitor - The visitor
      Returns:
      The result of the visitor
      Throws:
      E - The exception thrown by the visitor
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Geometry
      Returns:
      True if this circle is empty (radius less than 0)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hasZ

      public boolean hasZ()
      Specified by:
      hasZ in interface Geometry
      Returns:
      True if this circle has an altitude. False if NaN.