org.apache.lucene.spatial.geopoint.search

## Class GeoPointDistanceQuery

- java.lang.Object
- - org.apache.lucene.search.Query
  - - org.apache.lucene.spatial.geopoint.search.GeoPointInBBoxQuery
    - - org.apache.lucene.spatial.geopoint.search.GeoPointDistanceQuery

- All Implemented Interfaces:
    Cloneable
  Direct Known Subclasses:
    GeoPointDistanceRangeQuery

      public class GeoPointDistanceQuery
      extends GeoPointInBBoxQuery

  Implements a simple point distance query on a GeoPoint field. This is based on `GeoPointInBBoxQuery` and is implemented using a two phase approach. First, like `GeoPointInBBoxQueryImpl` candidate terms are queried using the numeric ranges based on the morton codes of the min and max lat/lon pairs that intersect the boundary of the point-radius circle. Terms passing this initial filter are then passed to a secondary `postFilter` method that verifies whether the decoded lat/lon point fall within the specified query distance (see `SloppyMath.haversin(double, double, double, double)`. All morton value comparisons are subject to the same precision tolerance defined in 1.0E-6 and distance comparisons are subject to the accuracy of the haversine formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)

  Note: This query currently uses haversine which is a sloppy distance calculation (see above reference). For large queries one can expect upwards of 400m error. Vincenty shrinks this to ~40m error but pays a penalty for computing using the spheroid

  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected double` | `centerLat` latitude value (in degrees) for query location
    `protected double` | `centerLon` longitude value (in degrees) for query location
    `protected double` | `radiusMeters` distance (in meters) from lon, lat center location

    - ### Fields inherited from class org.apache.lucene.spatial.geopoint.search.GeoPointInBBoxQuery

      `field, maxLat, maxLon, minLat, minLon, termEncoding`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GeoPointDistanceQuery(String field, double centerLon, double centerLat, double radiusMeters)` Constructs a Query for all `GeoPointField` types within a distance (in meters) from a given point
    `GeoPointDistanceQuery(String field, GeoPointField.TermEncoding termEncoding, double centerLon, double centerLat, double radiusMeters)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object o)`
    `double` | `getCenterLat()` getter method for center latitude value
    `double` | `getCenterLon()` getter method for center longitude value
    `double` | `getRadiusMeters()` getter method for distance value (in meters)
    `int` | `hashCode()`
    `Query` | `rewrite(IndexReader reader)`
    `String` | `toString(String field)`

    - ### Methods inherited from class org.apache.lucene.spatial.geopoint.search.GeoPointInBBoxQuery

      `getField, getMaxLat, getMaxLon, getMinLat, getMinLon`

    - ### Methods inherited from class org.apache.lucene.search.Query

      `clone, createWeight, getBoost, setBoost, toString`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### centerLon

          protected final double centerLon

      longitude value (in degrees) for query location

    - #### centerLat

          protected final double centerLat

      latitude value (in degrees) for query location

    - #### radiusMeters

          protected final double radiusMeters

      distance (in meters) from lon, lat center location

  - ### Constructor Detail

    - #### GeoPointDistanceQuery

          public GeoPointDistanceQuery(String field,
                               double centerLon,
                               double centerLat,
                               double radiusMeters)

      Constructs a Query for all `GeoPointField` types within a distance (in meters) from a given point

    - #### GeoPointDistanceQuery

          public GeoPointDistanceQuery(String field,
                               GeoPointField.TermEncoding termEncoding,
                               double centerLon,
                               double centerLat,
                               double radiusMeters)

  - ### Method Detail

    - #### rewrite

          public Query rewrite(IndexReader reader)
                        throws IOException

      Overrides:
        `rewrite` in class `GeoPointInBBoxQuery`
      Throws:
        `IOException`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `GeoPointInBBoxQuery`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `GeoPointInBBoxQuery`

    - #### toString

          public String toString(String field)

      Overrides:
        `toString` in class `GeoPointInBBoxQuery`

    - #### getCenterLon

          public double getCenterLon()

      getter method for center longitude value

    - #### getCenterLat

          public double getCenterLat()

      getter method for center latitude value

    - #### getRadiusMeters

          public double getRadiusMeters()

      getter method for distance value (in meters)

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.