Class DiscreteHausdorffDistance
An algorithm for computing a distance metric which is an approximation to the Hausdorff Distance based on a discretization of the input Geometry.
Inherited Members
Namespace: NetTopologySuite.Algorithm.Distance
Assembly: NetTopologySuite.dll
Syntax
public class DiscreteHausdorffDistance
Remarks
The algorithm computes the Hausdorff distance restricted to discrete points for one of the geometries. The points can be either the vertices of the geometries (the default), or the geometries with line segments densified by a given fraction. Also determines two points of the Geometries which are separated by the computed distance.
This algorithm is an approximation to the standard Hausdorff distance. Specifically,
for all geometries a, b: DHD(a, b) <= HD(a, b)
The approximation can be made as close as needed by densifying the input geometries.
In the limit, this value will approach the true Hausdorff distance:
DHD(A, B, densifyFactor) -> HD(A, B) as densifyFactor -> 0.0
The default approximation is exact or close enough for a large subset of useful cases.
Examples of these are:
-
computing distance between
Linestring
s that are roughly parallel to each other, and roughly equal in length. This occurs in matching linear networks. - Testing similarity of geometries.
An example where the default approximation is not close is:
A = LINESTRING (0 0, 100 0, 10 100, 10 100)
B = LINESTRING (0 100, 0 10, 80 10)
DHD(A, B) = 22.360679774997898
HD(A, B) ~= 47.8
Constructors
| Edit this page View SourceDiscreteHausdorffDistance(Geometry, Geometry)
Creates an instance of this class using the provided geometries
Declaration
public DiscreteHausdorffDistance(Geometry g0, Geometry g1)
Parameters
Type | Name | Description |
---|---|---|
Geometry | g0 | A geometry |
Geometry | g1 | Another geometry |
Properties
| Edit this page View SourceCoordinates
Gets a value indicating the
Declaration
public Coordinate[] Coordinates { get; }
Property Value
Type | Description |
---|---|
Coordinate[] |
DensifyFraction
Gets or sets the fraction by which to densify each segment.
Declaration
public double DensifyFraction { get; set; }
Property Value
Type | Description |
---|---|
double |
Remarks
Each segment will be (virtually) split into a number of equal-length sub-segments, whose fraction of the total length is closest to the given fraction.
Methods
| Edit this page View SourceDistance()
Computes the discrete hausdorff distance between the two assigned geometries.
Declaration
public double Distance()
Returns
Type | Description |
---|---|
double | The discrete hausdorff distance |
Distance(Geometry, Geometry)
Computes the Discrete Hausdorff Distance of two Geometrys.
Declaration
public static double Distance(Geometry g0, Geometry g1)
Parameters
Type | Name | Description |
---|---|---|
Geometry | g0 | A geometry |
Geometry | g1 | A geometry |
Returns
Type | Description |
---|---|
double | The Discrete Hausdorff Distance |
Distance(Geometry, Geometry, double)
Computes the Discrete Hausdorff Distance of two Geometrys.
Declaration
public static double Distance(Geometry g0, Geometry g1, double densifyFraction)
Parameters
Type | Name | Description |
---|---|---|
Geometry | g0 | A geometry |
Geometry | g1 | A geometry |
double | densifyFraction | The densify fraction. A value of 0 indicates, that no densification should take place |
Returns
Type | Description |
---|---|
double | The Discrete Hausdorff Distance |
OrientedDistance()
Computes the discrete hausdorff distance between the 1st and the 2nd assigned geometry
Declaration
public double OrientedDistance()
Returns
Type | Description |
---|---|
double | The discrete hausdorff distance. |