[postgis-tickets] [SCM] PostGIS branch master updated. 3.3.0rc2-340-g576233fd6
git at osgeo.org
git at osgeo.org
Wed Nov 16 16:00:47 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 576233fd6321e6bf5eba856ec61313ac4f87f57a (commit)
from 9c7af7f45ca45b4f3df3d8de83030f4166637d38 (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 576233fd6321e6bf5eba856ec61313ac4f87f57a
Author: Sandro Santilli <strk at kbt.io>
Date: Thu Nov 17 00:59:34 2022 +0100
Fix misleading message about doubly connected edges healing
Closes #5289
Includes regress test
diff --git a/topology/sql/cleanup/RemoveUnusedPrimitives.sql.in b/topology/sql/cleanup/RemoveUnusedPrimitives.sql.in
index fba82fbdc..8f58d4008 100644
--- a/topology/sql/cleanup/RemoveUnusedPrimitives.sql.in
+++ b/topology/sql/cleanup/RemoveUnusedPrimitives.sql.in
@@ -580,7 +580,7 @@ BEGIN
removable_nodes_of_degree_2_in_bbox AS (
SELECT
n.node_id,
- array_agg(e.edge_id) edges
+ array_agg(e.edge_id ORDER BY e.edge_id) edges
FROM
unused_connected_nodes_in_bbox n,
%1$I.edge e
@@ -612,15 +612,22 @@ BEGIN
)
GROUP BY n.node_id, r.layer_id, r.topogeo_id
HAVING count(DISTINCT abs(r.element_id)) != 2
+ ),
+ valid_heals AS (
+ SELECT
+ node_id,
+ edges
+ FROM removable_nodes_of_degree_2_in_bbox
+ WHERE node_id NOT IN (
+ SELECT node_id FROM breaking_heals
+ )
)
SELECT
- node_id,
+ array_agg(node_id) connecting_nodes,
edges[1] edge1,
edges[2] edge2
- FROM removable_nodes_of_degree_2_in_bbox
- WHERE node_id NOT IN (
- SELECT node_id FROM breaking_heals
- )
+ FROM valid_heals
+ GROUP BY edges
$$,
topo.name
);
@@ -634,8 +641,8 @@ BEGIN
edge1 := COALESCE( (edgeMap -> rec.edge1::text)::int, rec.edge1);
edge2 := COALESCE( (edgeMap -> rec.edge2::text)::int, rec.edge2);
- RAISE DEBUG 'Should heal edges % (now %) and % (now %) bound by node %',
- rec.edge1, edge1, rec.edge2, edge2, rec.node_id;
+ RAISE DEBUG 'Should heal edges % (now %) and % (now %) bound by nodes %',
+ rec.edge1, edge1, rec.edge2, edge2, rec.connecting_nodes;
IF edge1 = edge2 THEN
-- Nothing to merge here, continue
@@ -646,16 +653,16 @@ BEGIN
BEGIN
-- TODO: replace ST_ModEdgeHeal loop with a faster direct deletion and healing
removedNode := topology.ST_ModEdgeHeal(topo.name, edge1, edge2);
- IF rec.node_id != removedNode THEN
+ IF NOT removedNode = ANY ( rec.connecting_nodes ) THEN
RAISE EXCEPTION 'Healing of edges % and % was reported '
- 'to remove node % while we expected % instead',
- edge1, edge2, removedNode, rec.node_id;
+ 'to remove node % while we expected any of % instead',
+ edge1, edge2, removedNode, rec.connecting_nodes;
END IF;
RAISE DEBUG 'Edge % merged into %, dropping node %', edge2, edge1, removedNode;
ok := 1;
EXCEPTION WHEN OTHERS
THEN
- RAISE WARNING 'Edges % and % joined by node % could not be healed: %', edge1, edge2, rec.node_id, SQLERRM;
+ RAISE WARNING 'Edges % and % joined by node % could not be healed: %', edge1, edge2, rec.connecting_nodes, SQLERRM;
END;
IF ok THEN
-- edge2 was now renamed to edge1, update map
diff --git a/topology/test/regress/removeunusedprimitives.sql b/topology/test/regress/removeunusedprimitives.sql
index cd966cd4d..345ba9f23 100644
--- a/topology/test/regress/removeunusedprimitives.sql
+++ b/topology/test/regress/removeunusedprimitives.sql
@@ -204,6 +204,24 @@ SELECT 't6', 'clean', topology.RemoveUnusedPrimitives('city_data');
SELECT 't6', 'changed', * FROM features.check_changed_features();
SELECT 't6', 'invalidity', * FROM topology.ValidateTopology('city_data');
+
+-- See https://trac.osgeo.org/postgis/ticket/5289
+SELECT NULL FROM (
+ SELECT toTopoGeom(
+ ST_MakeLine(
+ ST_EndPoint( ST_GeometryN(feature,1) ),
+ ST_StartPoint( ST_GeometryN(feature,1) )
+ ),
+ feature
+ ) FROM features.city_streets WHERE feature_name = 'R2'
+) foo;
+UPDATE features.city_streets SET geom = feature::geometry
+WHERE feature_name = 'R2';
+SELECT '#5289', 'clean', topology.RemoveUnusedPrimitives('city_data');
+SELECT '#5289', 'changed', * FROM features.check_changed_features();
+SELECT '#5289', 'invalidity', * FROM topology.ValidateTopology('city_data');
+
+
-- Cleanup
SELECT NULL FROM DropTopology('city_data');
DROP SCHEMA features CASCADE;
diff --git a/topology/test/regress/removeunusedprimitives_expected b/topology/test/regress/removeunusedprimitives_expected
index afcbe4895..400adf603 100644
--- a/topology/test/regress/removeunusedprimitives_expected
+++ b/topology/test/regress/removeunusedprimitives_expected
@@ -7,3 +7,4 @@ t3|clean|1
t4|clean|1
t5|clean|2
t6|clean|3
+#5289|clean|1
-----------------------------------------------------------------------
Summary of changes:
topology/sql/cleanup/RemoveUnusedPrimitives.sql.in | 31 +++++++++++++---------
topology/test/regress/removeunusedprimitives.sql | 18 +++++++++++++
.../test/regress/removeunusedprimitives_expected | 1 +
3 files changed, 38 insertions(+), 12 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list