Package org.apache.lucene.geo
Class Polygon2D
java.lang.Object
org.apache.lucene.geo.Polygon2D
- All Implemented Interfaces:
Component2D
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.lucene.geo.Component2D
Component2D.WithinRelation
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Component2D
tree of holes, or nullprivate final double
maximum X of this geometry's bounding box areaprivate final double
maximum Y of this geometry's bounding box areaprivate final double
minimum X of this geometry's bounding box areaprivate final double
minimum Y of this geometry's bounding box area(package private) final EdgeTree
Edges of the polygon represented as a 2-d interval tree. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Polygon2D
(double minX, double maxX, double minY, double maxY, double[] x, double[] y, Component2D holes) private
Polygon2D
(Polygon polygon, Component2D holes) private
Polygon2D
(XYPolygon polygon, Component2D holes) -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(double x, double y) Returns true if the point is contained within this polygon.boolean
containsLine
(double minX, double maxX, double minY, double maxY, double aX, double aY, double bX, double bY) return true if this component2D contains the provided line *boolean
containsTriangle
(double minX, double maxX, double minY, double maxY, double aX, double aY, double bX, double bY, double cX, double cY) return true if this component2D contains the provided triangle *(package private) static Component2D
Builds a Polygon2D from LatLon polygon(package private) static Component2D
Builds a Polygon2D from XY polygondouble
getMaxX()
max X value for the component *double
getMaxY()
max Y value for the component *double
getMinX()
min X value for the component *double
getMinY()
min Y value for the component *boolean
intersectsLine
(double minX, double maxX, double minY, double maxY, double aX, double aY, double bX, double bY) return true if this component2D intersects the provided line *boolean
intersectsTriangle
(double minX, double maxX, double minY, double maxY, double aX, double aY, double bX, double bY, double cX, double cY) return true if this component2D intersects the provided triangle *private int
numberOfCorners
(double minX, double maxX, double minY, double maxY) relate
(double minX, double maxX, double minY, double maxY) relates this component2D with a bounding box *withinLine
(double minX, double maxX, double minY, double maxY, double aX, double aY, boolean ab, double bX, double bY) Compute the within relation of this component2D with a line *withinPoint
(double x, double y) Compute the within relation of this component2D with a point *withinTriangle
(double minX, double maxX, double minY, double maxY, double aX, double aY, boolean ab, double bX, double bY, boolean bc, double cX, double cY, boolean ca) Compute the within relation of this component2D with a triangle *Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.lucene.geo.Component2D
containsLine, containsTriangle, intersectsLine, intersectsTriangle, withinLine, withinTriangle
-
Field Details
-
minY
private final double minYminimum Y of this geometry's bounding box area -
maxY
private final double maxYmaximum Y of this geometry's bounding box area -
minX
private final double minXminimum X of this geometry's bounding box area -
maxX
private final double maxXmaximum X of this geometry's bounding box area -
holes
tree of holes, or null -
tree
Edges of the polygon represented as a 2-d interval tree.
-
-
Constructor Details
-
Polygon2D
private Polygon2D(double minX, double maxX, double minY, double maxY, double[] x, double[] y, Component2D holes) -
Polygon2D
-
Polygon2D
-
-
Method Details
-
getMinX
public double getMinX()Description copied from interface:Component2D
min X value for the component *- Specified by:
getMinX
in interfaceComponent2D
-
getMaxX
public double getMaxX()Description copied from interface:Component2D
max X value for the component *- Specified by:
getMaxX
in interfaceComponent2D
-
getMinY
public double getMinY()Description copied from interface:Component2D
min Y value for the component *- Specified by:
getMinY
in interfaceComponent2D
-
getMaxY
public double getMaxY()Description copied from interface:Component2D
max Y value for the component *- Specified by:
getMaxY
in interfaceComponent2D
-
contains
public boolean contains(double x, double y) 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.
- Specified by:
contains
in interfaceComponent2D
-
relate
Description copied from interface:Component2D
relates this component2D with a bounding box *- Specified by:
relate
in interfaceComponent2D
-
intersectsLine
public boolean intersectsLine(double minX, double maxX, double minY, double maxY, double aX, double aY, double bX, double bY) Description copied from interface:Component2D
return true if this component2D intersects the provided line *- Specified by:
intersectsLine
in interfaceComponent2D
-
intersectsTriangle
public boolean intersectsTriangle(double minX, double maxX, double minY, double maxY, double aX, double aY, double bX, double bY, double cX, double cY) Description copied from interface:Component2D
return true if this component2D intersects the provided triangle *- Specified by:
intersectsTriangle
in interfaceComponent2D
-
containsLine
public boolean containsLine(double minX, double maxX, double minY, double maxY, double aX, double aY, double bX, double bY) Description copied from interface:Component2D
return true if this component2D contains the provided line *- Specified by:
containsLine
in interfaceComponent2D
-
containsTriangle
public boolean containsTriangle(double minX, double maxX, double minY, double maxY, double aX, double aY, double bX, double bY, double cX, double cY) Description copied from interface:Component2D
return true if this component2D contains the provided triangle *- Specified by:
containsTriangle
in interfaceComponent2D
-
withinPoint
Description copied from interface:Component2D
Compute the within relation of this component2D with a point *- Specified by:
withinPoint
in interfaceComponent2D
-
withinLine
public Component2D.WithinRelation withinLine(double minX, double maxX, double minY, double maxY, double aX, double aY, boolean ab, double bX, double bY) Description copied from interface:Component2D
Compute the within relation of this component2D with a line *- Specified by:
withinLine
in interfaceComponent2D
-
withinTriangle
public Component2D.WithinRelation withinTriangle(double minX, double maxX, double minY, double maxY, double aX, double aY, boolean ab, double bX, double bY, boolean bc, double cX, double cY, boolean ca) Description copied from interface:Component2D
Compute the within relation of this component2D with a triangle *- Specified by:
withinTriangle
in interfaceComponent2D
-
numberOfCorners
private int numberOfCorners(double minX, double maxX, double minY, double maxY) -
create
Builds a Polygon2D from LatLon polygon -
create
Builds a Polygon2D from XY polygon
-