org.apache.lucene.geo

## Class Polygon2D

- java.lang.Object
- - org.apache.lucene.geo.Polygon2D

-     public final class Polygon2D
      extends Object

  2D polygon implementation represented as a balanced interval tree of edges.

  Construction takes `O(n log n)` time for sorting and tree construction. `contains()` and `relate()` are `O(n)`, but for most practical polygons are much faster than brute force.

  Loosely based on the algorithm described in http://www-ma2.upc.es/geoc/Schirra-pointPolygon.pdf.

  NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `double` | `maxLat` maximum latitude of this polygon's bounding box area
    `double` | `maxLon` maximum longitude of this polygon's bounding box area
    `double` | `minLat` minimum latitude of this polygon's bounding box area
    `double` | `minLon` minimum longitude of this polygon's bounding box area

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `contains(double latitude, double longitude)` Returns true if the point is contained within this polygon.
    `static Polygon2D` | `create(Polygon... polygons)` Builds a Polygon2D from multipolygon
    `PointValues.Relation` | `relate(double minLat, double maxLat, double minLon, double maxLon)` Returns relation to the provided rectangle
    `PointValues.Relation` | `relateTriangle(double ax, double ay, double bx, double by, double cx, double cy)` Returns relation to the provided triangle

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### minLat

          public final double minLat

      minimum latitude of this polygon's bounding box area

    - #### maxLat

          public final double maxLat

      maximum latitude of this polygon's bounding box area

    - #### minLon

          public final double minLon

      minimum longitude of this polygon's bounding box area

    - #### maxLon

          public final double maxLon

      maximum longitude of this polygon's bounding box area

  - ### Method Detail

    - #### contains

          public boolean contains(double latitude,
                                  double longitude)

      Returns true if the point is contained within this polygon.

      See https://www.ecse.rpi.edu/~wrf/Research/Short_Notes/pnpoly.html for more information.

    - #### relateTriangle

          public PointValues.Relation relateTriangle(double ax,
                                                     double ay,
                                                     double bx,
                                                     double by,
                                                     double cx,
                                                     double cy)

      Returns relation to the provided triangle

    - #### relate

          public PointValues.Relation relate(double minLat,
                                             double maxLat,
                                             double minLon,
                                             double maxLon)

      Returns relation to the provided rectangle

    - #### create

          public static Polygon2D create(Polygon... polygons)

      Builds a Polygon2D from multipolygon

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