public final class Polygon2D extends Object
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.
| 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
|
| 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
|
public final double minLat
public final double maxLat
public final double minLon
public final double maxLon
public boolean contains(double latitude,
double longitude)
See https://www.ecse.rpi.edu/~wrf/Research/Short_Notes/pnpoly.html for more information.
public PointValues.Relation relate(double minLat, double maxLat, double minLon, double maxLon)
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.