[SCM] PostGIS branch stable-3.6 updated. 3.6.4-61-gae1c72fa7
git at osgeo.org
git at osgeo.org
Mon Jul 6 10:32:27 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, stable-3.6 has been updated
via ae1c72fa7c510767dff7be53ce0653170b7876a1 (commit)
from 057a15defab7d9a348efd5ecca6110869b85600d (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 ae1c72fa7c510767dff7be53ce0653170b7876a1
Author: Darafei Praliaskouski <me at komzpa.net>
Date: Sun Nov 30 00:26:34 2025 +0400
Guard in MakeTopologyPrecise to prevent EMPTY edges
Closes #5948 for PostGIS 3.6.5
diff --git a/NEWS b/NEWS
index 3a478b3bb..0dbd1265e 100644
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,8 @@ PostGIS 3.6.5
ring-orientation precision regressions (Darafei Praliaskouski)
- GH-1146, Reset interrupt callbacks when PostgreSQL clears
cancellation state (Darafei Praliaskouski)
+- #5948, [topology] Prevent MakeTopologyPrecise from erasing edges when
+ grid size exceeds their extent (Darafei Praliaskouski)
PostGIS 3.6.4
diff --git a/doc/extras_topology.xml b/doc/extras_topology.xml
index 833ad2ca1..bdcfe70b4 100644
--- a/doc/extras_topology.xml
+++ b/doc/extras_topology.xml
@@ -1103,6 +1103,13 @@ parameter, optionally limiting the operation to the objects
intersecting the area specified by the <varname>bbox</varname> parameter.
</para>
+ <para>
+Using a <varname>gridSize</varname> larger than the smallest edge extent
+raises an exception rather than collapsing the edge into an empty
+geometry. This safeguards adjacent topological relationships by
+preventing precision snapping from removing primitives altogether.
+ </para>
+
<note>
<para>
Snapping could make the topology invalid, so it is recommended to
diff --git a/topology/sql/manage/MakeTopologyPrecise.sql.in b/topology/sql/manage/MakeTopologyPrecise.sql.in
index e66eea2fb..3906e0cfb 100644
--- a/topology/sql/manage/MakeTopologyPrecise.sql.in
+++ b/topology/sql/manage/MakeTopologyPrecise.sql.in
@@ -28,6 +28,7 @@ DECLARE
dataBox GEOMETRY;
dataMagnitude FLOAT8;
minGridSize FLOAT8;
+ minEdgeExtent FLOAT8;
BEGIN
topo := findTopology(toponame);
IF topo.id IS NULL THEN
@@ -73,6 +74,29 @@ BEGIN
-- TODO: recursively grow working bbox to include all edges connected
-- to all endpoints of edges intersecting it ?
+ --
+ -- Guard against snapping a whole edge to a single grid point.
+ -- With a grid size wider than the smallest edge extent every vertex would
+ -- quantize to the same coordinate, producing EMPTY geometries and breaking
+ -- the topology. Raising early keeps the caller in control of a safer grid
+ -- selection.
+ --
+ sql := format(
+ $$
+SELECT min(greatest(
+ abs(ST_XMax(geom) - ST_XMin(geom)),
+ abs(ST_YMax(geom) - ST_YMin(geom))
+ ))
+FROM %1$I.edge_data
+WHERE ($1 IS NULL OR geom && $1)
+ $$, topo.name
+ );
+ EXECUTE sql USING bbox INTO minEdgeExtent;
+
+ IF minEdgeExtent IS NOT NULL AND gridSize > minEdgeExtent THEN
+ RAISE EXCEPTION 'Grid size % exceeds smallest edge extent % and would erase edges', gridSize, minEdgeExtent;
+ END IF;
+
sql := format(
$$
UPDATE %1$I.edge_data
diff --git a/topology/test/regress/maketopologyprecise.sql b/topology/test/regress/maketopologyprecise.sql
index 84234cd25..f76b535be 100644
--- a/topology/test/regress/maketopologyprecise.sql
+++ b/topology/test/regress/maketopologyprecise.sql
@@ -11,6 +11,12 @@ SELECT 'prec5', 'e', edge_id, ST_AsEWKT(geom) FROM topo.edge ORDER BY edge_id;
SET client_min_messages TO WARNING;
+-- A tiny topology exercises the guard against collapsing edges into EMPTY.
+SELECT NULL FROM topology.CreateTopology('tiny');
+SELECT NULL FROM topology.TopoGeo_addLineString('tiny', 'LINESTRING(0 0, 1 0)');
+SELECT topology.MakeTopologyPrecise('tiny', gridSize => 5);
+SELECT NULL FROM topology.DropTopology('tiny');
+
-- TODO: test bbox limited made-precise topology
-- Cleanup
diff --git a/topology/test/regress/maketopologyprecise_expected b/topology/test/regress/maketopologyprecise_expected
index 2aad628f6..f3e132dad 100644
--- a/topology/test/regress/maketopologyprecise_expected
+++ b/topology/test/regress/maketopologyprecise_expected
@@ -3,3 +3,4 @@ NOTICE: Every vertex is precise in an empty topology
ERROR: Presence of max ordinate value 1002003008 requires a minimum grid size of 3.60721082879999e-6
start|e|1|LINESTRING(123456789 0.1,6 -1002003004)
prec5|e|1|LINESTRING(123456790 0,5 -1002003005)
+ERROR: Grid size 5 exceeds smallest edge extent 1 and would erase edges
-----------------------------------------------------------------------
Summary of changes:
NEWS | 2 ++
doc/extras_topology.xml | 7 +++++++
topology/sql/manage/MakeTopologyPrecise.sql.in | 24 ++++++++++++++++++++++
topology/test/regress/maketopologyprecise.sql | 6 ++++++
topology/test/regress/maketopologyprecise_expected | 1 +
5 files changed, 40 insertions(+)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list