## Name

ST_HausdorffDistance — 返回两个几何图形之间的Hausdorff 距离。

## Synopsis

`float ST_HausdorffDistance(`geometry g1, geometry g2`)`;

`float ST_HausdorffDistance(`geometry g1, geometry g2, float densifyFrac`)`;

## 描述

 该算法不等同于标准 Hausdorff距离。 然而，它计算出的近似值对于大部分有用案例都是正确的。 一种重要的情况是线串彼此大致平行且长度大致相等。 这是线路匹配的有用指标。

## 示例

```SELECT ST_HausdorffDistance(geomA, geomB),
ST_Distance(geomA, geomB)
FROM (SELECT 'LINESTRING (20 70, 70 60, 110 70, 170 70)'::geometry AS geomA,
'LINESTRING (20 90, 130 90, 60 100, 190 100)'::geometry AS geomB) AS t;
st_hausdorffdistance | st_distance
----------------------+-------------
37.26206567625497 |          20
```

```SELECT ST_HausdorffDistance(
'LINESTRING (130 0, 0 0, 0 150)'::geometry,
'LINESTRING (10 10, 10 150, 130 10)'::geometry,
0.5);
----------------------
70
```

```SELECT DISTINCT ON (buildings.gid) buildings.gid, parcels.parcel_id
FROM buildings
INNER JOIN parcels
ON ST_Intersects(buildings.geom, parcels.geom)
ORDER BY buildings.gid, ST_HausdorffDistance(buildings.geom, parcels.geom);
```