[postgis-tickets] [SCM] PostGIS branch master updated. 3.2.0-581-g9cf58181c

git at osgeo.org git at osgeo.org
Fri Feb 18 11:24:53 PST 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  9cf58181c69f961edd6976594bbecae55d8f6e80 (commit)
      from  00ef50ce4da9d9001e9ec2c79824f3cfabb0d6d2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 9cf58181c69f961edd6976594bbecae55d8f6e80
Author: Martin Davis <mtnclimb at gmail.com>
Date:   Fri Feb 18 11:24:49 2022 -0800

    Improve doc for ST_HausdorffDistance

diff --git a/doc/html/image_src/Makefile.in b/doc/html/image_src/Makefile.in
index 8d0fe9dc3..6037b2522 100644
--- a/doc/html/image_src/Makefile.in
+++ b/doc/html/image_src/Makefile.in
@@ -75,6 +75,7 @@ IMAGES= \
 	../images/st_extrude03.png \
 	../images/st_generatepoints01.png \
 	../images/st_geometricmedian01.png \
+	../images/st_hausdorffdistance01.png \
 	../images/st_issimple01.png \
 	../images/st_issimple02.png \
 	../images/st_issimple03.png \
diff --git a/doc/html/image_src/st_hausdorffdistance01.wkt b/doc/html/image_src/st_hausdorffdistance01.wkt
new file mode 100644
index 000000000..c41352d64
--- /dev/null
+++ b/doc/html/image_src/st_hausdorffdistance01.wkt
@@ -0,0 +1,4 @@
+ArgA;LINESTRING (20 70, 70 60, 110 70, 170 70)
+ArgB;LINESTRING (20 90, 130 90, 60 100, 190 100)
+Result;LINESTRING (52.69230769230769 63.46153846153846, 60 100)
+Highlight;LINESTRING (20 70, 20 90)
diff --git a/doc/reference_measure.xml b/doc/reference_measure.xml
index 254c80d03..577115939 100644
--- a/doc/reference_measure.xml
+++ b/doc/reference_measure.xml
@@ -890,26 +890,28 @@ The smaller densifyFrac we specify, the more acurate Fréchet distance we get. B
 	  <refsection>
 		<title>Description</title>
 
-		<para>Returns the Hausdorff distance between two geometries, a measure of how similar or dissimilar 2 geometries are.
+		<para>Returns the
+        <ulink url="http://en.wikipedia.org/wiki/Hausdorff_distance">Hausdorff distance</ulink>
+        between two geometries.
+        The Hausdorff distance is a measure of how similar or dissimilar 2 geometries are.
 		</para>
-		<para>Implements algorithm for computing a distance metric which can be thought of as the "Discrete Hausdorff Distance".
-This is the Hausdorff distance restricted to discrete points for one of the geometries. <ulink url="http://en.wikipedia.org/wiki/Hausdorff_distance">Wikipedia article on Hausdorff distance</ulink>
-	<ulink url="http://lin-ear-th-inking.blogspot.com/2009/01/computing-geometric-similarity.html">Martin Davis note on how Hausdorff Distance calculation was used to prove correctness of the CascadePolygonUnion approach.</ulink></para>
-		<para>
-When densifyFrac is specified, this function performs a segment densification before computing the discrete hausdorff distance. The densifyFrac parameter sets the fraction by which to densify each segment. Each segment will be split into a number of equal-length subsegments, whose fraction of the total length is closest to the given fraction.
+		<para>The function actually computes the "Discrete Hausdorff Distance".
+        This is the Hausdorff distance computed at discrete points on the geometries.
+        The <parameter>densifyFrac</parameter> parameter can be specified,
+        to provide a more accurate answer by densifying
+        segments before computing the discrete Hausdorff distance.
+        Each segment is split into a number of equal-length subsegments
+        whose fraction of the segment length is closest to the given fraction.
 		</para>
 		<para>Units are in the units of the spatial reference system of the geometries.
 		</para>
 
 		<note>
 			<para>
-The current implementation supports only vertices as the discrete locations. This could be extended to allow an arbitrary density of points to be used.
-			</para>
-		</note>
-		<note>
-			<para>
-				This algorithm is NOT equivalent to the standard Hausdorff distance. However, it computes an approximation that is correct for a large subset of useful cases.
-			One important part of this subset is Linestrings that are roughly parallel to each other, and roughly equal in length.  This is a useful metric for line matching.
+			This algorithm is NOT equivalent to the standard Hausdorff distance.
+            However, it computes an approximation that is correct for a large subset of useful cases.
+			One important case is Linestrings that are roughly parallel to each other,
+            and roughly equal in length.  This is a useful metric for line matching.
 			</para>
 		</note>
 		<para>Availability: 1.5.0</para>
@@ -918,26 +920,49 @@ The current implementation supports only vertices as the discrete locations. Thi
 
 	  <refsection>
 		<title>Examples</title>
-		    <para>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.</para>
-		<programlisting>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);</programlisting>
-
-				<programlisting>postgis=# SELECT ST_HausdorffDistance(
-				'LINESTRING (0 0, 2 0)'::geometry,
-				'MULTIPOINT (0 1, 1 0, 2 1)'::geometry);
- st_hausdorffdistance
- ----------------------
-					 1
-(1 row)
-			</programlisting>
-			<programlisting>postgis=# SELECT st_hausdorffdistance('LINESTRING (130 0, 0 0, 0 150)'::geometry, 'LINESTRING (10 10, 10 150, 130 10)'::geometry, 0.5);
- st_hausdorffdistance
+
+        <informalfigure>
+            <mediaobject>
+            <imageobject>
+                <imagedata fileref="images/st_hausdorffdistance01.png" />
+            </imageobject>
+            <caption><para>Hausdorff distance (red) and closest distance yellow)
+            between two lines </para></caption>
+            </mediaobject>
+        </informalfigure>
+
+<programlisting>
+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
+</programlisting>
+
+<para><emphasis role="bold">Example:</emphasis> Hausdorff distance with densification.</para>
+<programlisting>
+SELECT ST_HausdorffDistance(
+            'LINESTRING (130 0, 0 0, 0 150)'::geometry,
+            'LINESTRING (10 10, 10 150, 130 10)'::geometry,
+            0.5);
  ----------------------
-					70
-(1 row)
-			</programlisting>
+          70
+</programlisting>
+
+		    <para><emphasis role="bold">Example:</emphasis>
+            For each building, find the parcel that best represents it.
+            First we require that the parcel intersect with the building geometry.
+            <code>DISTINCT ON</code> guarantees we get each building listed only once.
+            <code>ORDER BY .. ST_HausdorffDistance</code> selects the parcel that is most similar to the building.</para>
+
+<programlisting>
+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);
+</programlisting>
 
 	  </refsection>
           <refsection>

-----------------------------------------------------------------------

Summary of changes:
 doc/html/image_src/Makefile.in                |  1 +
 doc/html/image_src/st_hausdorffdistance01.wkt |  4 ++
 doc/reference_measure.xml                     | 89 +++++++++++++++++----------
 3 files changed, 62 insertions(+), 32 deletions(-)
 create mode 100644 doc/html/image_src/st_hausdorffdistance01.wkt


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list