org.apache.lucene.spatial.geopoint.search

## Class GeoPointInPolygonQuery

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

- All Implemented Interfaces:
    Cloneable

      public final class GeoPointInPolygonQuery
      extends GeoPointInBBoxQuery

  Implements a simple point in polygon query on a GeoPoint field. This is based on `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 module

  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[]` | `x`
    `protected double[]` | `y`

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

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

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GeoPointInPolygonQuery(String field, double[] polyLons, double[] polyLats)`
    `GeoPointInPolygonQuery(String field, GeoPointField.TermEncoding termEncoding, 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.

  - ### Method Summary

    Methods
    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!
    `int` | `hashCode()`
    `Query` | `rewrite(IndexReader reader)` throw exception if trying to change rewrite method
    `String` | `toString(String field)` print out this polygon query

    - ### 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

    - #### x

          protected final double[] x

    - #### y

          protected final double[] y

  - ### Constructor Detail

    - #### GeoPointInPolygonQuery

          public GeoPointInPolygonQuery(String field,
                                double[] polyLons,
                                double[] polyLats)

    - #### GeoPointInPolygonQuery

          public GeoPointInPolygonQuery(String field,
                                GeoPointField.TermEncoding termEncoding,
                                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.

  - ### Method Detail

    - #### rewrite

          public Query rewrite(IndexReader reader)
                        throws IOException

      throw exception if trying to change rewrite method
      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)

      print out this polygon query
      Overrides:
        `toString` in class `GeoPointInBBoxQuery`

    - #### getLons

          public 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!

    - #### getLats

          public 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!

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