Class GeoPointDistanceQuery

  • 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.haversinMeters(double, double, double, double). 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

    • Field Detail

      • centerLat

        protected final double centerLat
        latitude value (in degrees) for query location
      • centerLon

        protected final double centerLon
        longitude value (in degrees) for query location
      • radiusMeters

        protected final double radiusMeters
        distance (in meters) from lat, lon center location
      • sortKey

        protected final double sortKey
        partial haversin computation
    • Method Detail

      • rewrite

        public Query rewrite(IndexReader reader)
        Description copied from class: Query
        Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.
        rewrite in class GeoPointInBBoxQuery
      • equals

        public boolean equals(Object o)
        Description copied from class: Query
        Override and implement query instance equivalence properly in a subclass. This is required so that QueryCache works properly. Typically a query will be equal to another only if it's an instance of the same class and its document-filtering properties are identical that other instance. Utility methods are provided for certain repetitive code.
        equals in class GeoPointInBBoxQuery
        See Also:
        Query.sameClassAs(Object), Query.classHash()
      • 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)