[postgis-tickets] [SCM] PostGIS branch main updated. 3.1.0rc1-276-g098c52a

git at osgeo.org git at osgeo.org
Tue Jul 6 13:22:25 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  098c52a9c998b8d0b520c5b934f0389ea2acad6b (commit)
      from  96cb70a4803f5d9856c811a4684bf801751648da (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 098c52a9c998b8d0b520c5b934f0389ea2acad6b
Author: Sandro Santilli <strk at kbt.io>
Date:   Tue Jul 6 22:20:35 2021 +0200

    Use format() to write GetNodeEdges query

diff --git a/topology/sql/query/GetNodeEdges.sql.in b/topology/sql/query/GetNodeEdges.sql.in
index 9d2deda..56665cf 100644
--- a/topology/sql/query/GetNodeEdges.sql.in
+++ b/topology/sql/query/GetNodeEdges.sql.in
@@ -22,7 +22,7 @@
 CREATE OR REPLACE FUNCTION topology.GetNodeEdges(atopology varchar, anode int)
 	RETURNS SETOF topology.GetFaceEdges_ReturnType
 AS
-$$
+$BODY$
 DECLARE
   curedge int;
   nextedge int;
@@ -33,19 +33,38 @@ DECLARE
 BEGIN
 
   n := 0;
-  sql :=
-    'WITH incident_edges AS ( SELECT edge_id, start_node, end_node, ST_RemoveRepeatedPoints(geom) as geom FROM '
-    || quote_ident(atopology)
-    || '.edge_data WHERE start_node = ' || anode
-    || ' or end_node = ' || anode
-    || ') SELECT edge_id, ST_Azimuth(ST_StartPoint(geom), ST_PointN(geom, 2)) as az FROM  incident_edges WHERE start_node = ' || anode
-    || ' UNION ALL SELECT -edge_id, ST_Azimuth(ST_EndPoint(geom), ST_PointN(geom, ST_NumPoints(geom)-1)) FROM incident_edges WHERE end_node = ' || anode
-    || ' ORDER BY az';
+  sql := format(
+    $$
+      WITH incident_edges AS (
+        SELECT
+          edge_id,
+          start_node,
+          end_node,
+          ST_RemoveRepeatedPoints(geom) as geom
+        FROM %1$I.edge_data
+        WHERE start_node = $1
+        or end_node = $1
+      )
+      SELECT
+        edge_id,
+        ST_Azimuth(ST_StartPoint(geom), ST_PointN(geom, 2)) as az
+      FROM incident_edges
+      WHERE start_node = $1
+        UNION ALL
+      SELECT
+        -edge_id,
+        ST_Azimuth(ST_EndPoint(geom), ST_PointN(geom, ST_NumPoints(geom)-1))
+      FROM incident_edges
+      WHERE end_node = $1
+      ORDER BY az
+    $$,
+    atopology
+  );
 #ifdef POSTGIS_TOPOLOGY_DEBUG
   RAISE DEBUG 'sql: %', sql;
 #endif
 
-  FOR rec IN EXECUTE sql
+  FOR rec IN EXECUTE sql USING anode
   LOOP -- incident edges {
 
 #ifdef POSTGIS_TOPOLOGY_DEBUG
@@ -58,6 +77,6 @@ BEGIN
   END LOOP; -- incident edges }
 
 END
-$$
+$BODY$
 LANGUAGE 'plpgsql' STABLE;
 --} GetNodeEdges

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

Summary of changes:
 topology/sql/query/GetNodeEdges.sql.in | 41 +++++++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 11 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list