[postgis-tickets] [SCM] PostGIS branch main updated. 3.1.0rc1-282-ga724cfc

git at osgeo.org git at osgeo.org
Wed Jul 7 06:37:42 PDT 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, main has been updated
       via  a724cfca065ca748aa8894639477ceb4ed76d5d6 (commit)
      from  1735811117212c292740df7edc96414ee73f4b85 (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 a724cfca065ca748aa8894639477ceb4ed76d5d6
Author: Sandro Santilli <strk at kbt.io>
Date:   Wed Jul 7 12:15:38 2021 +0200

    Rewrite edge coverage check to speed it up

diff --git a/topology/sql/manage/ValidateTopology.sql.in b/topology/sql/manage/ValidateTopology.sql.in
index ceca303..e22eff1 100644
--- a/topology/sql/manage/ValidateTopology.sql.in
+++ b/topology/sql/manage/ValidateTopology.sql.in
@@ -616,45 +616,84 @@ BEGIN
 
   -- Check edges are covered by their left-right faces (#4830)
   RAISE DEBUG 'Checking for edges coverage';
-  FOR rec IN
-    WITH edge_coverage AS (
+  FOR rec IN --{
+    WITH
+    face_coverage AS (
+      SELECT f.face_id, array_agg(e.edge_id) covered_edges
+      FROM face_check f, edge_data e
+      WHERE ST_Covers(f.geom, e.geom)
+      GROUP BY f.face_id
+    ),
+    edges_to_check AS (
+      SELECT
+        e.*
+      FROM edge_data e
+      WHERE ( bbox IS NULL OR e.geom && bbox )
+      AND e.edge_id NOT IN (
+        SELECT unnest(invalid_edges)
+      )
+    ),
+    edge_coverage AS (
       SELECT
         e.edge_id,
         e.left_face,
         e.right_face,
-        array_agg(COALESCE(f.face_id, 0)) covered_by
-      FROM
-        edge_data e
-        LEFT JOIN face_check f ON ( ST_Covers(f.geom, e.geom) )
-        -- skip invalid edges (toxic, and will be already reported previously)
-        WHERE
-          (
-            invalid_edges IS NULL OR NOT e.edge_id = ANY(invalid_edges)
-          )
-          AND
-          (
-            bbox IS NULL OR e.geom && bbox
-          )
-      GROUP BY
-        e.edge_id, e.left_face, e.right_face
+        array_agg(DISTINCT fc.face_id)
+          filter (WHERE fc.face_id IS NOT NULL) faces_covering
+      FROM edges_to_check e
+      LEFT JOIN face_coverage fc ON (
+        e.edge_id = ANY(fc.covered_edges)
+      )
+      GROUP BY edge_id, left_face, right_face
     )
-    SELECT
-       *,
-       left_face = ANY(covered_by) left_face_covered,
-       right_face = ANY(covered_by) right_face_covered
-       from edge_coverage
+    SELECT *
+    FROM edge_coverage
     WHERE
-      ( left_face != 0 AND NOT left_face = ANY(covered_by) )
+      -- Edges dangling in universal face needs be
+      -- NOT covered by any face
+      (
+        left_face = 0 AND
+        right_face = 0 AND
+        faces_covering IS NOT NULL
+      )
+      OR
+      (
+        left_face != 0 AND
+        (
+          faces_covering IS NULL OR
+          NOT left_face = ANY(faces_covering)
+        )
+      )
       OR
-      ( right_face != 0 AND NOT right_face = ANY(covered_by) )
+      (
+        right_face != 0 AND
+        (
+          faces_covering IS NULL OR
+          NOT right_face = ANY(faces_covering)
+        )
+      )
       OR
-      ( right_face = 0 AND left_face = 0 AND covered_by[1] != 0 )
+      (
+        (
+          ( right_face = 0 AND left_face != 0 )
+          OR
+          ( right_face != 0 AND left_face = 0 )
+        )
+        AND
+        (
+          faces_covering IS NULL OR
+          array_upper(faces_covering, 1) != 1
+        )
+      )
     ORDER BY edge_id
-  LOOP --{
+  LOOP --}{
       retrec.id1 := rec.edge_id;
-      retrec.id2 := NULL; -- TODO: write expected containing_face here ?
-      IF rec.left_face = 0 AND rec.right_face = 0 THEN
+      retrec.id2 := NULL;
+      IF rec.left_face = 0
+         AND rec.right_face = 0
+      THEN
         retrec.error := 'edge covered by some face has universal face on both sides';
+        --retrec.error := format('edge covered by faces %s has universal face on both sides', rec.faces_covering);
         RETURN NEXT retrec;
       ELSE
         retrec.error := 'edge not covered by both its side faces';

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

Summary of changes:
 topology/sql/manage/ValidateTopology.sql.in | 95 ++++++++++++++++++++---------
 1 file changed, 67 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list