|
GEOS 3.16.0dev
|
#include <DirectedHausdorffDistance.h>
Public Types | |
| using | PointPair = std::array< geom::CoordinateXY, 2 > |
| JTS returns Coordinate[]; std::array is the C++ equivalent pair. | |
Public Member Functions | |
| DirectedHausdorffDistance (const geom::Geometry &geom) | |
| DirectedHausdorffDistance (const DirectedHausdorffDistance &)=delete | |
| DirectedHausdorffDistance & | operator= (const DirectedHausdorffDistance &)=delete |
| std::optional< PointPair > | farthestPoints (const geom::Geometry &geom) const |
| std::optional< PointPair > | farthestPoints (const geom::Geometry &geom, double tolerance) const |
| bool | isFullyWithinDistance (const geom::Geometry &geom, double maxDistance) const |
| bool | isFullyWithinDistance (const geom::Geometry &geom, double maxDistance, double tolerance) const |
Static Public Member Functions | |
| static double | distance (const geom::Geometry &a, const geom::Geometry &b) |
| static double | distance (const geom::Geometry &a, const geom::Geometry &b, double tolerance) |
| static std::optional< PointPair > | distancePoints (const geom::Geometry &a, const geom::Geometry &b) |
| static std::optional< PointPair > | distancePoints (const geom::Geometry &a, const geom::Geometry &b, double tolerance) |
| static double | hausdorffDistance (const geom::Geometry &a, const geom::Geometry &b) |
| static std::optional< PointPair > | hausdorffDistancePoints (const geom::Geometry &a, const geom::Geometry &b) |
| static bool | isFullyWithinDistance (const geom::Geometry &a, const geom::Geometry &b, double maxDistance) |
| static bool | isFullyWithinDistance (const geom::Geometry &a, const geom::Geometry &b, double maxDistance, double tolerance) |
Friends | |
| class | DHDSegment |
Computes the directed Hausdorff distance from one geometry to another. The directed Hausdorff distance is the maximum distance any point on a query geometry A can be from a target geometry B. Equivalently, every point in the query geometry is within that distance of the target geometry. The class can compute a pair of points at which the distance is attained: [ farthest A point, nearest B point ].
The directed Hausdorff distance (DHD) is defined as:
DHD(A,B) = max a ∈ A (max b ∈ B (distance(a, b) )
DHD is asymmetric: DHD(A,B) may not be equal to DHD(B,A). Hence it is not a distance metric. The Hausdorff distance is a symmetric distance metric defined as:
HD(A,B) = max(DHD(A,B), DHD(B,A))
This can be computed via the hausdorffDistancePoints(Geometry, Geometry) function.
Points, lines and polygons are supported as input. If the query geometry is polygonal, the point at maximum distance may occur in the interior of a query polygon. For a polygonal target geometry the point always lies on the boundary.
The directed Hausdorff distance can be used to test whether a geometry lies fully within a given distance of another one. The isFullyWithinDistance(Geometry, double) function is provided to execute this test efficiently. It implements heuristic checks and short-circuiting to improve performance.
The class can be used in prepared mode. Creating an instance on a target geometry caches indexes for that geometry. Then farthestPoints(Geometry) or isFullyWithinDistance(Geometry, double) can be called efficiently for multiple query geometries.
If the Hausdorff distance is attained at a non-vertex of the query geometry, the location must be approximated. The algorithm uses a distance tolerance to control the approximation accuracy. The tolerance is automatically determined to balance between accuracy and performance. If more accuracy is desired some function signatures are provided which allow specifying a distance tolerance.
This algorithm is easier to use, more accurate, and much faster than DiscreteHausdorffDistance.
|
explicit |
Create a new instance for a target geometry.
| geom | the geometry to compute the distance from |
|
static |
Computes the directed Hausdorff distance of a query geometry A from a target one B.
| a | the query geometry |
| b | the target geometry |
|
static |
Computes the directed Hausdorff distance of a query geometry A from a target one B, up to a given distance accuracy.
| a | the query geometry |
| b | the target geometry |
| tolerance | the accuracy distance tolerance |
|
static |
Computes a line containing a pair of points which attain the directed Hausdorff distance of a query geometry A from a target one B.
| a | the query geometry |
| b | the target geometry |
|
static |
Computes a line containing a pair of points which attain the directed Hausdorff distance of a query geometry A from a target one B, up to a given distance accuracy.
| a | the query geometry |
| b | the target geometry |
| tolerance | the accuracy distance tolerance |
| std::optional< PointPair > geos::algorithm::distance::DirectedHausdorffDistance::farthestPoints | ( | const geom::Geometry & | geom | ) | const |
Computes a pair of points which attain the directed Hausdorff distance of a query geometry A from the target B. If either geometry is empty the result is empty.
| geom | the query geometry |
| std::optional< PointPair > geos::algorithm::distance::DirectedHausdorffDistance::farthestPoints | ( | const geom::Geometry & | geom, |
| double | tolerance | ||
| ) | const |
Computes a pair of points which attain the directed Hausdorff distance of a query geometry A from the target B, up to a given distance accuracy. If either geometry is empty the result is empty.
| geom | the query geometry |
| tolerance | the approximation distance tolerance |
|
static |
Computes the symmetric Hausdorff distance between two geometries. This is the maximum of the two directed Hausdorff distances.
| a | a geometry |
| b | a geometry |
|
static |
Computes a pair of points which attain the symmetric Hausdorff distance between two geometries. This is the maximum of the two directed Hausdorff distances.
| a | a geometry |
| b | a geometry |
|
static |
Computes whether a query geometry lies fully within a given distance of a target geometry. Equivalently, detects whether any point of the query geometry is farther from the target than the specified distance. This is the case if DHD(A, B) > maxDistance.
| a | the query geometry |
| b | the target geometry |
| maxDistance | the distance limit |
|
static |
Computes whether a query geometry lies fully within a given distance of a target geometry, up to a given distance accuracy. Equivalently, detects whether any point of the query geometry is farther from the target than the specified distance. This is the case if DHD(A, B) > maxDistance.
| a | the query geometry |
| b | the target geometry |
| maxDistance | the distance limit |
| tolerance | the accuracy distance tolerance |
| bool geos::algorithm::distance::DirectedHausdorffDistance::isFullyWithinDistance | ( | const geom::Geometry & | geom, |
| double | maxDistance | ||
| ) | const |
Tests whether a query geometry lies fully within a given distance of the target geometry. Equivalently, detects whether any point of the query geometry is farther from the target than the specified distance. This is the case if DHD(A, B) > maxDistance.
| geom | the query geometry |
| maxDistance | the distance limit |
| bool geos::algorithm::distance::DirectedHausdorffDistance::isFullyWithinDistance | ( | const geom::Geometry & | geom, |
| double | maxDistance, | ||
| double | tolerance | ||
| ) | const |
Tests whether a query geometry lies fully within a given distance of the target geometry, up to a given distance accuracy. Equivalently, detects whether any point of the query geometry is farther from the target than the specified distance. This is the case if DHD(A, B) > maxDistance.
| geom | the query geometry |
| maxDistance | the distance limit |
| tolerance | the accuracy distance tolerance |