[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0rc1-40-gd6fd952

git at osgeo.org git at osgeo.org
Mon Jan 11 06:40:28 PST 2021


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  d6fd9521b664be6e94102d1e4c778eaa85a2fb05 (commit)
      from  2039722000192f082a29a32dce47dd4f899edb93 (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 d6fd9521b664be6e94102d1e4c778eaa85a2fb05
Author: Sandro Santilli <strk at kbt.io>
Date:   Mon Jan 11 13:07:02 2021 +0100

    Have ValidateTopology check for node containing_face
    
    Includes automated testcase
    Closes #3233

diff --git a/NEWS b/NEWS
index 57a8de4..318c8ad 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ PostGIS 3.2.0
  * Breaking changes *
   - Removed `--without-wagyu` build option. Using Wagyu is not mandatory to build with MVT support.
 
+ * Enhancements *
+  - #3233, ValidateTopology check for node's containing_face (Sandro Santilli)
+
 PostGIS 3.1.0
 2020/12/18
 
diff --git a/topology/test/regress/validatetopology.sql b/topology/test/regress/validatetopology.sql
index 4c5e57c..b528aa4 100644
--- a/topology/test/regress/validatetopology.sql
+++ b/topology/test/regress/validatetopology.sql
@@ -22,3 +22,25 @@ SELECT '#1797', '---', null, null ORDER BY 1,2,3,4;
 
 select null from ( select topology.DropTopology('t') ) as dt;
 
+-- Test correctness of node.containing_face
+-- See https://trac.osgeo.org/postgis/ticket/3233
+
+SELECT null from ( select topology.CreateTopology('t') ) as ct;
+SELECT null from ( select TopoGeo_addPolygon('t', 'POLYGON((0 0,10 0,10 10,0 10,0 0))') ) af;
+SELECT null from ( select TopoGeo_addPoint('t', 'POINT(5 5)') ) ap;
+SELECT '#3233.0', (ValidateTopology('t')).* UNION
+SELECT '#3233.0', '---', null, null ORDER BY 1,2,3,4;
+-- 1. Set wrong containing_face for isolated node
+UPDATE t.node SET containing_face = 0 WHERE ST_Equals(geom, 'POINT(5 5)');
+SELECT '#3233.1', (ValidateTopology('t')).* UNION
+SELECT '#3233.1', '---', null, null ORDER BY 1,2,3,4;
+-- 2. Set null containing_face for isolated node
+UPDATE t.node SET containing_face = NULL WHERE ST_Equals(geom, 'POINT(5 5)');
+SELECT '#3233.2', (ValidateTopology('t')).* UNION
+SELECT '#3233.2', '---', null, null ORDER BY 1,2,3,4;
+-- 3. Set containing_face for non-isolated node
+UPDATE t.node SET containing_face = 1 WHERE ST_Equals(geom, 'POINT(5 5)');
+UPDATE t.node SET containing_face = 0 WHERE NOT ST_Equals(geom, 'POINT(5 5)');
+SELECT '#3233.3', (ValidateTopology('t')).* UNION
+SELECT '#3233.3', '---', null, null ORDER BY 1,2,3,4;
+SELECT null from ( select topology.DropTopology('t') ) as dt;
diff --git a/topology/test/regress/validatetopology_expected b/topology/test/regress/validatetopology_expected
index c3de174..2a97b04 100644
--- a/topology/test/regress/validatetopology_expected
+++ b/topology/test/regress/validatetopology_expected
@@ -1,2 +1,9 @@
 #1789|---||
 #1797|---||
+#3233.0|---||
+#3233.1|---||
+#3233.1|isolated node has wrong containing_face|2|
+#3233.2|---||
+#3233.2|isolated node has wrong containing_face|2|
+#3233.3|---||
+#3233.3|not-isolated node has not-null containing_face|1|
diff --git a/topology/topology.sql.in b/topology/topology.sql.in
index 03b4370..e1d60bc 100644
--- a/topology/topology.sql.in
+++ b/topology/topology.sql.in
@@ -1668,6 +1668,34 @@ BEGIN
 
   END LOOP;
 
+  -- Check nodes have correct containing_face (#3233)
+  FOR rec IN EXECUTE format(
+    $SQL$
+      SELECT n.node_id, f.face_id, e.edge_id
+      FROM %1$I.node n
+      LEFT JOIN face_check f ON ( ST_Contains(f.geom, n.geom) )
+      LEFT JOIN %1$I.edge e ON (
+        ST_Equals(ST_StartPoint(e.geom), n.geom) OR
+        ST_Equals(ST_EndPoint(e.geom), n.geom)
+      )
+      WHERE
+       n.containing_face != f.face_id
+        OR
+       ( n.containing_face IS NULL AND f.face_id IS NOT NULL )
+        OR
+       ( n.containing_face IS NOT NULL AND e.edge_id IS NOT NULL )
+    $SQL$, toponame)
+  LOOP
+    IF rec.edge_id IS NOT NULL THEN
+      retrec.error := 'not-isolated node has not-null containing_face';
+    ELSE
+      retrec.error := 'isolated node has wrong containing_face';
+    END IF;
+    retrec.id1 := rec.node_id;
+    retrec.id2 := NULL; -- TODO: write expected containing_face here ?
+    RETURN NEXT retrec;
+  END LOOP;
+
   DROP TABLE face_check;
 
   RETURN;

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

Summary of changes:
 NEWS                                            |  3 +++
 topology/test/regress/validatetopology.sql      | 22 +++++++++++++++++++
 topology/test/regress/validatetopology_expected |  7 +++++++
 topology/topology.sql.in                        | 28 +++++++++++++++++++++++++
 4 files changed, 60 insertions(+)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list