org.apache.lucene.geo

## Class Polygon2D

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

-     public class Polygon2D
      extends EdgeTree

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

  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
    --- | ---
    `protected Polygon2D` | `holes` tree of holes, or null

    - ### Fields inherited from class org.apache.lucene.geo.EdgeTree

      `left, maxLat, maxLon, maxX, maxY, minLat, minLon, right, splitX, tree`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `Polygon2D(double minLat, double maxLat, double minLon, double maxLon, double[] lats, double[] lons, Polygon2D holes)`
    `protected` | `Polygon2D(Polygon polygon, Polygon2D holes)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected PointValues.Relation` | `componentRelate(double minLat, double maxLat, double minLon, double maxLon)` Returns relation to the provided rectangle for this component
    `protected PointValues.Relation` | `componentRelateTriangle(double ax, double ay, double bx, double by, double cx, double cy)` Returns relation to the provided triangle for this component
    `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

    - ### Methods inherited from class org.apache.lucene.geo.EdgeTree

      `createTree, internalComponentRelate, pointInTriangle, relate, relateTriangle`

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

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

- - ### Field Detail

    - #### holes

          protected final Polygon2D holes

      tree of holes, or null

  - ### Constructor Detail

    - #### Polygon2D

          protected Polygon2D(double minLat,
                              double maxLat,
                              double minLon,
                              double maxLon,
                              double[] lats,
                              double[] lons,
                              Polygon2D holes)

    - #### Polygon2D

          protected Polygon2D(Polygon polygon,
                              Polygon2D holes)

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

    - #### componentRelate

          protected PointValues.Relation componentRelate(double minLat,
                                                         double maxLat,
                                                         double minLon,
                                                         double maxLon)

      Description copied from class: `EdgeTree`
      Returns relation to the provided rectangle for this component
      Specified by:
        `componentRelate` in class `EdgeTree`

    - #### componentRelateTriangle

          protected PointValues.Relation componentRelateTriangle(double ax,
                                                                 double ay,
                                                                 double bx,
                                                                 double by,
                                                                 double cx,
                                                                 double cy)

      Description copied from class: `EdgeTree`
      Returns relation to the provided triangle for this component
      Specified by:
        `componentRelateTriangle` in class `EdgeTree`

    - #### create

          public static Polygon2D create(Polygon... polygons)

      Builds a Polygon2D from multipolygon

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