[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0rc1-198-g429bf56

git at osgeo.org git at osgeo.org
Thu Jun 3 03:42:23 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, master has been updated
       via  429bf56aa47e55a13555a15d20ef08a1c14d2aba (commit)
      from  3efe42ec18bf1f2a9e3645049b8caf3828ef4f33 (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 429bf56aa47e55a13555a15d20ef08a1c14d2aba
Author: Sandro Santilli <strk at kbt.io>
Date:   Thu Mar 4 18:19:03 2021 +0100

    topology.FindLayer function
    
    Closes #4869

diff --git a/NEWS b/NEWS
index 2f7d515..d45d57f 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ PostGIS 3.2.0
 
  * New features*
   - #4841, FindTopology to quickly get a topology record (Sandro Santilli)
+  - #4869, FindLayer to quickly get a layer record (Sandro Santilli)
   - #4851, TopoGeom_addTopoGeom function (Sandro Santilli)
   - ST_MakeValid(geometry, options) allows alternative validity building
     algorithms with GEOS 3.10 (Paul Ramsey)
diff --git a/topology/Makefile.in b/topology/Makefile.in
index 0c48cd2..c31d10a 100644
--- a/topology/Makefile.in
+++ b/topology/Makefile.in
@@ -121,6 +121,7 @@ topology.sql: \
 	sql/query/GetNodeEdges.sql.in \
 	sql/manage/TopologySummary.sql.in \
 	sql/manage/CopyTopology.sql.in \
+	sql/manage/FindLayer.sql.in \
 	sql/manage/FindTopology.sql.in \
 	sql/manage/ManageHelper.sql.in \
 	sql/topoelement/topoelement_agg.sql.in \
diff --git a/topology/sql/manage/FindLayer.sql.in b/topology/sql/manage/FindLayer.sql.in
new file mode 100644
index 0000000..bcc88c5
--- /dev/null
+++ b/topology/sql/manage/FindLayer.sql.in
@@ -0,0 +1,68 @@
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+--
+-- PostGIS - Spatial Types for PostgreSQL
+-- http://postgis.net
+--
+-- Copyright (C) 2021 Sandro Santilli <strk at kbt.io>
+--
+-- This is free software; you can redistribute and/or modify it under
+-- the terms of the GNU General Public Licence. See the COPYING file.
+--
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+--{
+--  FindLayer(TopoGeometry)
+--
+-- Return a topology.layer record from a TopoGeometry
+--
+CREATE OR REPLACE FUNCTION topology.FindLayer(tg TopoGeometry)
+RETURNS topology.layer
+AS $$
+    SELECT * FROM topology.layer
+    WHERE topology_id = topology_id($1)
+    AND layer_id = layer_id($1)
+$$ LANGUAGE 'sql';
+--}
+
+--{
+--  FindLayer(layerRegclass, layerColumn)
+--
+-- Return a topology.layer record from a layer table/column
+--
+CREATE OR REPLACE FUNCTION topology.FindLayer(layer_table regclass, feature_column name)
+RETURNS topology.layer
+AS $$
+    SELECT * FROM topology.layer
+    WHERE format('%I.%I', schema_name, table_name)::regclass = $1
+    AND feature_column = $2;
+$$ LANGUAGE 'sql';
+--}
+
+--{
+--  FindLayer(layerSchema, layerTable, layerColumn)
+--
+-- Return a topology.layer record from a layer schema/table/column
+--
+CREATE OR REPLACE FUNCTION topology.FindLayer(schema_name name, table_name name, feature_column name)
+RETURNS topology.layer
+AS $$
+    SELECT * FROM topology.layer
+    WHERE schema_name = $1
+    AND table_name = $2
+    AND feature_column = $3;
+$$ LANGUAGE 'sql';
+--}
+
+--{
+--  FindLayer(topoName)
+--
+-- Return a topology.layer record from a topology id and layer id
+--
+CREATE OR REPLACE FUNCTION topology.FindLayer(topology_id integer, layer_id integer)
+RETURNS topology.layer
+AS $$
+    SELECT * FROM topology.layer
+    WHERE topology_id = $1
+      AND layer_id = $2
+$$ LANGUAGE 'sql';
+--}
diff --git a/topology/test/regress/findlayer.sql b/topology/test/regress/findlayer.sql
new file mode 100644
index 0000000..7feec3a
--- /dev/null
+++ b/topology/test/regress/findlayer.sql
@@ -0,0 +1,25 @@
+BEGIN;
+
+CREATE SCHEMA s;
+SELECT NULL FROM CreateTopology('a');
+CREATE TABLE a.l(i int);
+SELECT AddTopoGeometryColumn('a','a','l','g1','POINT');
+SELECT AddTopoGeometryColumn('a','a','l','g2','POINT');
+
+SELECT 'by_regclass_1', layer_id(findLayer('a.l', 'g1'));
+SELECT 'by_regclass_2', layer_id(findLayer('a.l', 'g2'));
+
+SELECT 'by_schema_table_1', layer_id(findLayer('a', 'l', 'g1'));
+SELECT 'by_schema_table_2', layer_id(findLayer('a', 'l', 'g2'));
+
+SELECT 'by_ids_1', layer_id(findLayer(id(FindTopology('a')), layer_id(findLayer('a.l', 'g1'))));
+SELECT 'by_ids_2', layer_id(findLayer(id(FindTopology('a')), layer_id(findLayer('a.l', 'g2'))));
+
+SELECT 'by_topogeom_1', layer_id(findLayer(
+  toTopoGeom('POINT(0 0)', 'a', layer_id(findLayer('a.l','g1')), 0)
+));
+SELECT 'by_topogeom_2', layer_id(findLayer(
+  toTopoGeom('POINT(0 0)', 'a', layer_id(findLayer('a.l','g2')), 0)
+));
+
+ROLLBACK;
diff --git a/topology/test/regress/findlayer_expected b/topology/test/regress/findlayer_expected
new file mode 100644
index 0000000..c15641a
--- /dev/null
+++ b/topology/test/regress/findlayer_expected
@@ -0,0 +1,10 @@
+1
+2
+by_regclass_1|1
+by_regclass_2|2
+by_schema_table_1|1
+by_schema_table_2|2
+by_ids_1|1
+by_ids_2|2
+by_topogeom_1|1
+by_topogeom_2|2
diff --git a/topology/topology.sql.in b/topology/topology.sql.in
index 4f01bc0..fcf610d 100644
--- a/topology/topology.sql.in
+++ b/topology/topology.sql.in
@@ -2191,6 +2191,7 @@ LANGUAGE 'plpgsql' VOLATILE STRICT;
 #include "sql/manage/TopologySummary.sql.in"
 #include "sql/manage/CopyTopology.sql.in"
 #include "sql/manage/FindTopology.sql.in"
+#include "sql/manage/FindLayer.sql.in"
 
 
 CREATE OR REPLACE FUNCTION topology.postgis_topology_scripts_installed() RETURNS text

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

Summary of changes:
 NEWS                                     |  1 +
 topology/Makefile.in                     |  1 +
 topology/sql/manage/FindLayer.sql.in     | 68 ++++++++++++++++++++++++++++++++
 topology/test/regress/findlayer.sql      | 25 ++++++++++++
 topology/test/regress/findlayer_expected | 10 +++++
 topology/topology.sql.in                 |  1 +
 6 files changed, 106 insertions(+)
 create mode 100644 topology/sql/manage/FindLayer.sql.in
 create mode 100644 topology/test/regress/findlayer.sql
 create mode 100644 topology/test/regress/findlayer_expected


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list