[SCM] PostGIS branch master updated. 3.6.0rc2-434-gacc6afbd9

git at osgeo.org git at osgeo.org
Wed Apr 8 02:23:04 PDT 2026


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  acc6afbd9212beaf8e2039c7f2369584a6c9ec77 (commit)
      from  cf42b890bf892d5498af532f1e8804355b44e71d (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 acc6afbd9212beaf8e2039c7f2369584a6c9ec77
Author: Sandro Santilli <strk at kbt.io>
Date:   Thu Jan 29 11:33:51 2026 +0100

    FindVertexSegmentPairsBelowDistance function
    
    References #6034
    
    Includes tests and documentation

diff --git a/NEWS b/NEWS
index 19c16e4bc..1a59e317b 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ This version requires GEOS 3.10 or higher
 
 * New Features *
 
+ - [topology] FindVertexSegmentPairsBelowDistance function (Sandro Santilli)
  - ST_CoverageEdges, returns MultiLinestring of distinct shared edges in
           polygonal coverage (Paul Ramsey)
  - ST_MinimumSpanningTree, window function to calculate MST (Paul Ramsey)
diff --git a/doc/extras_topology.xml b/doc/extras_topology.xml
index 4b0aa308a..31fe66eaf 100644
--- a/doc/extras_topology.xml
+++ b/doc/extras_topology.xml
@@ -3313,6 +3313,47 @@ and is thus usable to build edge ring linking.
 			</refsection>
 		</refentry>
 
+		<refentry xml:id="FindVertexSegmentPairsBelowDistance">
+			<refnamediv>
+				<refname>FindVertexSegmentPairsBelowDistance</refname>
+
+				<refpurpose>
+                    Find pairs of topology vertex/segment that are closer than tolerated distance
+				</refpurpose>
+			</refnamediv>
+
+			<refsynopsisdiv>
+				<funcsynopsis>
+					<funcprototype>
+					<funcdef>setof record <function>FindVertexSegmentPairsBelowDistance</function></funcdef>
+					<paramdef><type>varchar </type> <parameter>atopology</parameter></paramdef>
+					<paramdef><type>float8 </type> <parameter>tolerance</parameter></paramdef>
+					</funcprototype>
+				</funcsynopsis>
+			</refsynopsisdiv>
+
+			<refsection>
+                <title>Description</title>
+
+                <para>
+Returns a relation in which each tuple is a pair of vertex/segment where
+the vertex is NOT an endpoint of the segment but the distance between
+them is below the given tolerance.
+                </para>
+
+                <!-- use this format if new function -->
+                <para role="availability" conformance="3.7">Availability: 3.7</para>
+			</refsection>
+
+			<!-- Optionally add a "See Also" section -->
+			<refsection>
+				<title>See Also</title>
+				<para>
+<xref linkend="ValidateTopologyPrecision"/>
+				</para>
+			</refsection>
+		</refentry>
+
 	</section>
 
 
diff --git a/topology/Makefile.in b/topology/Makefile.in
index 25cae0bfa..3319cf98c 100644
--- a/topology/Makefile.in
+++ b/topology/Makefile.in
@@ -130,12 +130,13 @@ topology.sql: \
 	sql/polygonize.sql.in \
 	sql/export/gml.sql.in \
 	sql/export/TopoJSON.sql.in \
-	sql/query/getnodebypoint.sql.in \
+	sql/query/FindVertexSegmentPairsBelowDistance.sql.in \
 	sql/query/getedgebypoint.sql.in \
 	sql/query/getfacebypoint.sql.in \
-	sql/query/GetRingEdges.sql.in \
-	sql/query/GetNodeEdges.sql.in \
 	sql/query/GetFaceContainingPoint.sql.in \
+	sql/query/getnodebypoint.sql.in \
+	sql/query/GetNodeEdges.sql.in \
+	sql/query/GetRingEdges.sql.in \
 	sql/manage/AddTopoGeometryColumn.sql.in \
 	sql/manage/CopyTopology.sql.in \
 	sql/manage/CreateTopology.sql.in \
diff --git a/topology/sql/query/FindVertexSegmentPairsBelowDistance.sql.in b/topology/sql/query/FindVertexSegmentPairsBelowDistance.sql.in
new file mode 100644
index 000000000..8d5096235
--- /dev/null
+++ b/topology/sql/query/FindVertexSegmentPairsBelowDistance.sql.in
@@ -0,0 +1,46 @@
+-- Finds pairs of vertice/segment from a topology that are below a given distance.
+-- The vertex must NOT be part of the segment.
+--
+-- Presence of such proximities represent a missed snap opportunity during topology building
+-- and can sometime be fixed by adding a new node where the vertex is, like:
+--
+-- SELECT topology.TopoGeo_AddPoint('topo', ST_PointN(geom,v.vert))
+-- FROM topo.edge, LATERAL topology.findVertexSegmentPairsBelowDistance('topo', 1e-6) v
+-- WHERE edge_id = v.vert_edge;
+--
+CREATE OR REPLACE FUNCTION topology.findVertexSegmentPairsBelowDistance(toponame varchar, tolerance float8)
+RETURNS TABLE (seg_edge int, segno int, vert_edge int, vertno int, vert_geom geometry)
+AS $BODY$
+DECLARE
+  sql text;
+BEGIN
+  sql := format($$
+    SELECT
+      e1.edge_id seg_edge,
+      s.path[1] segno,
+      e2.edge_id vert_edge,
+      p.path[1] vertno,
+      p.geom vert_geom
+    FROM
+      %1$I.edge e1,
+      %1$I.edge e2,
+      LATERAL ST_DumpSegments(e1.geom) s,
+      LATERAL ST_DumpPoints(e2.geom) p
+    WHERE
+      e1.edge_id != e2.edge_id
+      AND ST_Expand(e1.geom, %2$L) && e2.geom
+      AND ST_Distance(s.geom, p.geom) < %2$L
+      AND NOT (
+        ST_Equals(p.geom, ST_PointN(s.geom, 1))
+          OR
+        ST_Equals(p.geom, ST_PointN(s.geom, 2))
+      )
+    $$,
+    toponame,
+    tolerance
+  );
+
+  RETURN QUERY EXECUTE sql;
+END;
+$BODY$
+LANGUAGE 'plpgsql';
diff --git a/topology/test/regress/findvertexsegmentpairsbelowdistance.sql b/topology/test/regress/findvertexsegmentpairsbelowdistance.sql
new file mode 100644
index 000000000..ac3aac9b0
--- /dev/null
+++ b/topology/test/regress/findvertexsegmentpairsbelowdistance.sql
@@ -0,0 +1,11 @@
+\set VERBOSITY terse
+set client_min_messages to ERROR;
+
+\i :top_builddir/topology/test/load_topology.sql
+
+SELECT 't1', 'count', count(*) FROM topology.FindVertexSegmentPairsBelowDistance('city_data', 1);
+SELECT 't2', seg_edge, segno, vert_edge, vertno, ST_AsText(vert_geom)
+FROM topology.FindVertexSegmentPairsBelowDistance('city_data', 1.1)
+ORDER BY 1,2,3,4;
+
+SELECT NULL FROM topology.DropTopology('city_data');
diff --git a/topology/test/regress/findvertexsegmentpairsbelowdistance_expected b/topology/test/regress/findvertexsegmentpairsbelowdistance_expected
new file mode 100644
index 000000000..000575dbb
--- /dev/null
+++ b/topology/test/regress/findvertexsegmentpairsbelowdistance_expected
@@ -0,0 +1,12 @@
+t1|count|0
+t2|1|1|2|5|POINT(17 30)
+t2|1|2|2|5|POINT(17 30)
+t2|1|4|26|1|POINT(4 31)
+t2|1|4|26|4|POINT(4 34)
+t2|1|4|26|5|POINT(4 31)
+t2|1|5|26|1|POINT(4 31)
+t2|1|5|26|2|POINT(7 31)
+t2|1|5|26|5|POINT(4 31)
+t2|2|4|1|2|POINT(16 30)
+t2|2|4|1|3|POINT(16 38)
+t2|2|5|1|2|POINT(16 30)
diff --git a/topology/test/tests.mk b/topology/test/tests.mk
index ba1d2e204..3c70599d7 100644
--- a/topology/test/tests.mk
+++ b/topology/test/tests.mk
@@ -99,5 +99,6 @@ TESTS += \
 	$(top_srcdir)/topology/test/regress/validatetopology.sql \
 	$(top_srcdir)/topology/test/regress/validatetopology_large.sql \
 	$(top_srcdir)/topology/test/regress/verifylargeids.sql \
-	$(top_srcdir)/topology/test/regress/fix_topogeometry_columns.sql
+	$(top_srcdir)/topology/test/regress/fix_topogeometry_columns.sql \
+	$(top_srcdir)/topology/test/regress/findvertexsegmentpairsbelowdistance.sql
 
diff --git a/topology/topology.sql.in b/topology/topology.sql.in
index c364af34d..e96d9068e 100644
--- a/topology/topology.sql.in
+++ b/topology/topology.sql.in
@@ -1379,6 +1379,7 @@ LANGUAGE 'plpgsql' VOLATILE STRICT;
 #include "sql/query/getedgebypoint.sql.in"
 #include "sql/query/getfacebypoint.sql.in"
 #include "sql/query/GetFaceContainingPoint.sql.in"
+#include "sql/query/FindVertexSegmentPairsBelowDistance.sql.in"
 
 --  Populating
 #include "sql/populate.sql.in"

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

Summary of changes:
 NEWS                                               |  1 +
 doc/extras_topology.xml                            | 41 +++++++++++++++++++
 topology/Makefile.in                               |  7 ++--
 .../FindVertexSegmentPairsBelowDistance.sql.in     | 46 ++++++++++++++++++++++
 .../findvertexsegmentpairsbelowdistance.sql        | 11 ++++++
 .../findvertexsegmentpairsbelowdistance_expected   | 12 ++++++
 topology/test/tests.mk                             |  3 +-
 topology/topology.sql.in                           |  1 +
 8 files changed, 118 insertions(+), 4 deletions(-)
 create mode 100644 topology/sql/query/FindVertexSegmentPairsBelowDistance.sql.in
 create mode 100644 topology/test/regress/findvertexsegmentpairsbelowdistance.sql
 create mode 100644 topology/test/regress/findvertexsegmentpairsbelowdistance_expected


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list