public class GeoPointDistanceQuery extends GeoPointInBBoxQuery
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
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 lat, lon center location
|
field, maxLat, maxLon, minLat, minLon, termEncoding
Constructor and Description |
---|
GeoPointDistanceQuery(String field,
double centerLat,
double centerLon,
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 centerLat,
double centerLon,
double radiusMeters)
Constructs a Query for all
GeoPointField types within a
distance (in meters) from a given point. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
Override and implement query instance equivalence properly in a subclass.
|
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()
Override and implement query hash code properly in a subclass.
|
Query |
rewrite(IndexReader reader)
Expert: called to re-write queries into primitive queries.
|
String |
toString(String field)
Prints a query to a string, with
field assumed to be the
default field and omitted. |
getField, getMaxLat, getMaxLon, getMinLat, getMinLon
classHash, createWeight, sameClassAs, toString
protected final double centerLat
protected final double centerLon
protected final double radiusMeters
public GeoPointDistanceQuery(String field, double centerLat, double centerLon, double radiusMeters)
GeoPointField
types within a
distance (in meters) from a given pointpublic GeoPointDistanceQuery(String field, GeoPointField.TermEncoding termEncoding, double centerLat, double centerLon, double radiusMeters)
GeoPointField
types within a
distance (in meters) from a given point. Accepts optional
GeoPointField.TermEncoding
parameterpublic Query rewrite(IndexReader reader)
Query
rewrite
in class GeoPointInBBoxQuery
public boolean equals(Object o)
Query
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
Query.sameClassAs(Object)
,
Query.classHash()
public int hashCode()
Query
QueryCache
works properly.hashCode
in class GeoPointInBBoxQuery
Query.equals(Object)
public String toString(String field)
Query
field
assumed to be the
default field and omitted.toString
in class GeoPointInBBoxQuery
public double getCenterLon()
public double getCenterLat()
public double getRadiusMeters()
Copyright © 2000–2017 The Apache Software Foundation. All rights reserved.