public class IndexedFacetDistance extends Object
Geometry
s
using a Branch-and-Bound algorithm.
The Branch-and-Bound algorithm operates over a
traversal of R-trees built
on the target and the query geometries.
This approach provides the following benefits:
Geometry.distance(Geometry)
when one or both input geometries are large,
or when evaluating many distance computations against
a single geometry.
This class is thread-safe.
Constructor and Description |
---|
IndexedFacetDistance(Geometry geom)
Creates a new distance-finding instance for a given target
Geometry . |
Modifier and Type | Method and Description |
---|---|
double |
distance(Geometry g)
Computes the distance from the base geometry to
the given geometry.
|
static double |
distance(Geometry g1,
Geometry g2)
Computes the distance between facets of two geometries.
|
boolean |
isWithinDistance(Geometry g,
double maxDistance)
Tests whether the base geometry lies within
a specified distance of the given geometry.
|
static boolean |
isWithinDistance(Geometry g1,
Geometry g2,
double distance)
Tests whether the facets of two geometries lie within a given distance.
|
GeometryLocation[] |
nearestLocations(Geometry g)
Computes the nearest locations on the base geometry
and the given geometry.
|
Coordinate[] |
nearestPoints(Geometry g)
Compute the nearest locations on the target geometry
and the given geometry.
|
static Coordinate[] |
nearestPoints(Geometry g1,
Geometry g2)
Computes the nearest points of the facets of two geometries.
|
public IndexedFacetDistance(Geometry geom)
Geometry
.
Distances will be computed to all facets of the input geometry.
The facets of the geometry are the discrete segments and points
contained in its components.
In the case of Lineal
and Puntal
inputs,
this is equivalent to computing the conventional distance.
In the case of Polygonal
inputs, this is equivalent
to computing the distance to the polygon boundaries.
geom
- a Geometry, which may be of any type.public static double distance(Geometry g1, Geometry g2)
For geometries with many segments or points, this can be faster than using a simple distance algorithm.
g1
- a geometryg2
- a geometrypublic static boolean isWithinDistance(Geometry g1, Geometry g2, double distance)
g1
- a geometryg2
- a geometrydistance
- the distance limitpublic static Coordinate[] nearestPoints(Geometry g1, Geometry g2)
g1
- a geometryg2
- a geometrypublic double distance(Geometry g)
g
- the geometry to compute the distance topublic GeometryLocation[] nearestLocations(Geometry g)
g
- the geometry to compute the nearest location topublic Coordinate[] nearestPoints(Geometry g)
g
- the geometry to compute the nearest point topublic boolean isWithinDistance(Geometry g, double maxDistance)
g
- the geometry to testmaxDistance
- the maximum distance to testCopyright © 2022. All rights reserved.