[SCM] PostGIS branch master updated. 3.6.0rc2-234-gd44a6df35
git at osgeo.org
git at osgeo.org
Sat Nov 29 12:31:38 PST 2025
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 d44a6df35bf71a6fca4bdb4f997e032ce61591e9 (commit)
from 0673a9acd838953bfa17cb571e064c4486242268 (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 d44a6df35bf71a6fca4bdb4f997e032ce61591e9
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
diff --git a/NEWS b/NEWS
index 5630edbe1..3401fe5f0 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,8 @@ xxxx/xx/xx
* Bug Fixes *
+ - #5948, [topology] Prevent MakeTopologyPrecise from erasing edges when
+ grid size exceeds their extent (Darafei Praliaskouski)
- #5959, Prevent histogram target overflow when analysing massive tables (Darafei Praliaskouski)
- #4828, geometry_columns handles NOT VALID SRID checks without errors (Darafei Praliaskouski)
- #5645, Docs: keep code operators ("=>") intact in translated manuals
diff --git a/doc/extras_topology.xml b/doc/extras_topology.xml
index d50276dd4..d30d68a82 100644
--- a/doc/extras_topology.xml
+++ b/doc/extras_topology.xml
@@ -1121,6 +1121,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