From 8561d8cdf848d9b618bdd5168311b9cb373f90e4 Mon Sep 17 00:00:00 2001 From: Regina Obe Date: Tue, 2 Jul 2013 13:55:48 +0000 Subject: [PATCH] useful real world example of using ST_MaxDistance git-svn-id: http://svn.osgeo.org/postgis/trunk@11604 b70326c6-7e19-0410-871a-916f4a2858ee --- doc/reference_measure.xml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/reference_measure.xml b/doc/reference_measure.xml index d9e0dde8e..b147ce023 100644 --- a/doc/reference_measure.xml +++ b/doc/reference_measure.xml @@ -2138,11 +2138,9 @@ The current implementation supports only vertices as the discrete locations. Thi Description - Some useful description here. - - Returns the 2-dimensional maximum distance between two linestrings in + Returns the 2-dimensional maximum distance between two geometries in projected units. If g1 and g2 is the same geometry the function will return the distance between the two vertices most far from each other in that geometry. @@ -2151,7 +2149,12 @@ The current implementation supports only vertices as the discrete locations. Thi Examples - + For each building, find the parcel that best covers it. The answer will return at most one record per building +and will return the parcel that it intersects and parts of building that don't intersect the furthest part of building is closest to this parcel. + 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_MaxDistance(buildings.geom, parcels.geom); + Basic furthest distance the point is to any part of the linepostgis=# SELECT ST_MaxDistance('POINT(0 0)'::geometry, 'LINESTRING ( 2 0, 0 2 )'::geometry); st_maxdistance ----------------- @@ -2168,7 +2171,7 @@ postgis=# SELECT ST_MaxDistance('POINT(0 0)'::geometry, 'LINESTRING ( 2 2, 2 2 ) See Also -, +, , -- 2.40.0