public class SimplePointInAreaLocator extends Object implements PointOnGeometryLocator
Polygonal
Geometry
,
using a simple O(n) algorithm.
The algorithm used reports if a point lies in the interior, exterior, or exactly on the boundary of the Geometry.
Instance methods are provided to implement
the interface SimplePointInAreaLocator
.
However, they provide no performance
advantage over the class methods.
This algorithm is suitable for use in cases where
only a few points will be tested.
If many points will be tested,
IndexedPointInAreaLocator
may provide better performance.
Constructor and Description |
---|
SimplePointInAreaLocator(Geometry geom)
Create an instance of a point-in-area locator,
using the provided areal geometry.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
containsPointInPolygon(Coordinate p,
Polygon poly)
Determines whether a point lies in a
Polygon . |
static boolean |
isContained(Coordinate p,
Geometry geom)
Determines whether a point is contained in a
Geometry ,
or lies on its boundary. |
int |
locate(Coordinate p)
|
static int |
locate(Coordinate p,
Geometry geom)
|
static int |
locatePointInPolygon(Coordinate p,
Polygon poly)
|
public SimplePointInAreaLocator(Geometry geom)
geom
- the areal geometry to locate inpublic static int locate(Coordinate p, Geometry geom)
Location
of a point in an areal Geometry
.
The return value is one of:
Location.INTERIOR
if the point is in the geometry interior
Location.BOUNDARY
if the point lies exactly on the boundary
Location.EXTERIOR
if the point is outside the geometry
p
- the point to testgeom
- the areal geometry to testpublic static boolean isContained(Coordinate p, Geometry geom)
Geometry
,
or lies on its boundary.
This is a convenience method for
Location.EXTERIOR != locate(p, geom)
p
- the point to testgeom
- the geometry to testpublic static int locatePointInPolygon(Coordinate p, Polygon poly)
Location
of a point in a Polygon
.
The return value is one of:
Location.INTERIOR
if the point is in the geometry interior
Location.BOUNDARY
if the point lies exactly on the boundary
Location.EXTERIOR
if the point is outside the geometry
locate(Coordinate, Geometry)
instead.p
- the point to testpoly
- the geometry to testpublic static boolean containsPointInPolygon(Coordinate p, Polygon poly)
Polygon
.
If the point lies on the polygon boundary it is
considered to be inside.p
- the point to testpoly
- the geometry to testpublic int locate(Coordinate p)
Location
of a point in an areal Geometry
.
The return value is one of:
Location.INTERIOR
if the point is in the geometry interior
Location.BOUNDARY
if the point lies exactly on the boundary
Location.EXTERIOR
if the point is outside the geometry
locate
in interface PointOnGeometryLocator
p
- the point to testCopyright © 2024. All rights reserved.