From: Regina Obe Date: Tue, 2 Jul 2013 16:11:55 +0000 (+0000) Subject: move example to ST_HausdorffDistance X-Git-Tag: 2.2.0rc1~1464 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e7a5fb010b91aabb2eeb8f0d4f32100044a1d9a8;p=postgis move example to ST_HausdorffDistance git-svn-id: http://svn.osgeo.org/postgis/trunk@11608 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/reference_measure.xml b/doc/reference_measure.xml index fc194fc81..9d43aa81a 100644 --- a/doc/reference_measure.xml +++ b/doc/reference_measure.xml @@ -2098,8 +2098,13 @@ The current implementation supports only vertices as the discrete locations. Thi Examples + For each building, find the parcel that best represents it. First we require the parcel intersect with the geometry. + DISTINCT ON guarantees we get each building listed only once, the ORDER BY .. ST_HausdorffDistance gives us a preference of parcel that is most similar to the building. + 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); - postgis=# SELECT st_HausdorffDistance( + postgis=# SELECT ST_HausdorffDistance( 'LINESTRING (0 0, 2 0)'::geometry, 'MULTIPOINT (0 1, 1 0, 2 1)'::geometry); st_hausdorffdistance @@ -2149,11 +2154,7 @@ The current implementation supports only vertices as the discrete locations. Thi Examples - + Basic furthest distance the point is to any part of the line postgis=# SELECT ST_MaxDistance('POINT(0 0)'::geometry, 'LINESTRING ( 2 0, 0 2 )'::geometry); st_maxdistance