Class IndexedFacetDistance
java.lang.Object
org.locationtech.jts.operation.distance.IndexedFacetDistance
Computes the distance between the facets (segments and vertices)
of two
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 possibly also the query geometries.
This approach provides the following benefits:
- Performance is improved due to the effects of the R-tree index and the pruning due to the Branch-and-Bound approach
- The spatial index on the target geometry can be cached to allow reuse in an incremental query situation.
getDistance(Geometry)
when one or both
input geometries are large,
or when evaluating many distance computations against
a single geometry.
This class is not thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Tests whether the base geometry lies within a specified distance of the given geometry. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double
Computes the distance between two geometries using the indexed approach.private static double
facetDistance
(Object[] obj) double
Computes the distance from the base geometry to the given geometry.
-
Field Details
-
cachedTree
-
-
Constructor Details
-
IndexedFacetDistance
Creates a new distance-finding instance for a given targetGeometry
.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
andPuntal
inputs, this is equivalent to computing the conventional distance. In the case ofPolygonal
inputs, this is equivalent to computing the distance to the polygons boundaries.- Parameters:
g1
- a Geometry, which may be of any type.
-
-
Method Details
-
distance
Computes the distance between two geometries using the indexed approach.For geometries with many segments or points, this can be faster than using a simple distance algorithm.
- Parameters:
g1
- a geometryg2
- a geometry- Returns:
- the distance between the two geometries
-
getDistance
Computes the distance from the base geometry to the given geometry.- Parameters:
g
- the geometry to compute the distance to- Returns:
- the computed distance
-
facetDistance
-