public final class GeoPointInPolygonQuery extends MultiTermQuery
GeoPointInBBoxQueryImpl
and is implemented using a
three phase approach. First, like GeoPointInBBoxQueryImpl
candidate terms are queried using a numeric range based on the morton codes
of the min and max lat/lon pairs. Terms passing this initial filter are passed
to a secondary filter that verifies whether the decoded lat/lon point falls within
(or on the boundary) of the bounding box query. Finally, the remaining candidate
term is passed to the final point in polygon check. All value comparisons are subject
to the same precision tolerance defined in 1.0E-6
NOTES:
1. The polygon coordinates need to be in either clockwise or counter-clockwise order.
2. The polygon must not be self-crossing, otherwise the query may result in unexpected behavior
3. All latitude/longitude values must be in decimal degrees.
4. Complex computational geometry (e.g., dateline wrapping, polygon with holes) is not supported
5. For more advanced GeoSpatial indexing and query operations see spatial moduleMultiTermQuery.RewriteMethod, MultiTermQuery.TopTermsBlendedFreqScoringRewrite, MultiTermQuery.TopTermsBoostOnlyBooleanQueryRewrite, MultiTermQuery.TopTermsScoringBooleanQueryRewrite
Modifier and Type | Field and Description |
---|---|
static MultiTermQuery.RewriteMethod |
GEO_CONSTANT_SCORE_REWRITE |
protected double |
maxLat |
protected double |
maxLon |
protected double |
minLat |
protected double |
minLon |
CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE, CONSTANT_SCORE_BOOLEAN_REWRITE, CONSTANT_SCORE_FILTER_REWRITE, CONSTANT_SCORE_REWRITE, field, rewriteMethod, SCORING_BOOLEAN_QUERY_REWRITE, SCORING_BOOLEAN_REWRITE
Constructor and Description |
---|
GeoPointInPolygonQuery(String field,
double[] polyLons,
double[] polyLats)
Constructs a new GeoPolygonQuery that will match encoded
GeoPointField terms
that fall within or on the boundary of the polygon defined by the input parameters. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
double[] |
getLats()
API utility method for returning the array of latitudinal values for this GeoPolygon
The returned array is not a copy so do not change it!
|
double[] |
getLons()
API utility method for returning the array of longitudinal values for this GeoPolygon
The returned array is not a copy so do not change it!
|
protected TermsEnum |
getTermsEnum(Terms terms,
AttributeSource atts)
Construct the enumeration to be used, expanding the
pattern term.
|
int |
hashCode() |
void |
setRewriteMethod(MultiTermQuery.RewriteMethod method)
Sets the rewrite method to be used when executing the
query.
|
String |
toString(String field)
Prints a query to a string, with
field assumed to be the
default field and omitted. |
getField, getRewriteMethod, getTermsEnum, rewrite
protected final double minLon
protected final double minLat
protected final double maxLon
protected final double maxLat
public static final MultiTermQuery.RewriteMethod GEO_CONSTANT_SCORE_REWRITE
public GeoPointInPolygonQuery(String field, double[] polyLons, double[] polyLats)
GeoPointField
terms
that fall within or on the boundary of the polygon defined by the input parameters.protected TermsEnum getTermsEnum(Terms terms, AttributeSource atts) throws IOException
MultiTermQuery
TermsEnum.EMPTY
if no
terms match). The TermsEnum must already be
positioned to the first matching term.
The given AttributeSource
is passed by the MultiTermQuery.RewriteMethod
to
provide attributes, the rewrite method uses to inform about e.g. maximum competitive boosts.
This is currently only used by TopTermsRewrite
IOException
public void setRewriteMethod(MultiTermQuery.RewriteMethod method)
MultiTermQuery
MultiTermQuery.RewriteMethod
.public boolean equals(Object o)
public int hashCode()
public String toString(String field)
Query
field
assumed to be the
default field and omitted.public double[] getLons()
public double[] getLats()
Copyright © 2000–2015 The Apache Software Foundation. All rights reserved.