[postgis-tickets] [SCM] PostGIS branch main updated. 3.1.0rc1-390-gdb1d141

git at osgeo.org git at osgeo.org
Tue Aug 10 17:13:50 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  db1d141fa287987a0526a1d9b08939ce523965cf (commit)
      from  b01f7eac5dd1bc7364859ae947e42f82efc7aa00 (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 db1d141fa287987a0526a1d9b08939ce523965cf
Author: Sandro Santilli <strk at kbt.io>
Date:   Wed Aug 11 02:13:26 2021 +0200

    GetFaceContainingPoint: reduce data access in some cases

diff --git a/topology/sql/query/GetFaceContainingPoint.sql.in b/topology/sql/query/GetFaceContainingPoint.sql.in
index 505d0c2..86c6337 100644
--- a/topology/sql/query/GetFaceContainingPoint.sql.in
+++ b/topology/sql/query/GetFaceContainingPoint.sql.in
@@ -109,38 +109,41 @@ BEGIN
       -- dangling, we can return their common
       -- side face, otherwise the point will be
       -- on multiple face boundaries
+
+      -- early exit if the closest edge has
+      -- left_face != right_face, don't bother
+      -- fetching more edges
+      IF closestEdge.left_face != closestEdge.right_face THEN
+        RAISE EXCEPTION 'Two or more faces found';
+      END IF;
+
       sql := format(
         $$
-          WITH incident_edges AS (
-            SELECT
-              left_face,
-              right_face
-            FROM %1$I.edge_data
-            WHERE start_node = $1
+          SELECT
+            left_face,
+            right_face
+          FROM %1$I.edge_data
+          WHERE (
+            start_node = $1
             OR end_node = $1
-          ),
-          side_faces AS (
-            SELECT left_face side_face
-            FROM incident_edges
-              UNION
-            SELECT right_face
-            FROM incident_edges
           )
-          SELECT array_agg(side_face) sideFaces
-          FROM side_faces
+          AND (
+            left_face != $2
+            OR right_face != $2
+          )
+          LIMIT 1
         $$,
         atopology
       );
 #ifdef POSTGIS_TOPOLOGY_DEBUG
       RAISE DEBUG 'SQL: %', sql;
 #endif
-      EXECUTE sql USING closestNode INTO rec;
-      IF array_upper(rec.sideFaces, 1) > 1
+      EXECUTE sql USING closestNode, closestEdge.left_face INTO rec;
+      IF FOUND
       THEN
         RAISE EXCEPTION 'Two or more faces found';
-      ELSE
-        RETURN rec.sideFaces[1];
       END IF;
+      RETURN closestEdge.left_face;
 
     END IF; --} query point is the node
 

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

Summary of changes:
 topology/sql/query/GetFaceContainingPoint.sql.in | 41 +++++++++++++-----------
 1 file changed, 22 insertions(+), 19 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list