[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0rc1-77-g4cc0051

git at osgeo.org git at osgeo.org
Mon Feb 15 03:40:07 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  4cc00518ff38c3f7578c8f342b9e7698db0934eb (commit)
      from  c05040400c0f166910f6c907e1c342b4ef4b9934 (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 4cc00518ff38c3f7578c8f342b9e7698db0934eb
Author: Sandro Santilli <strk at kbt.io>
Date:   Fri Feb 5 16:53:16 2021 +0100

    Implement FindTopology()
    
    Closes #4841
    
    Includes testcase and documentation

diff --git a/NEWS b/NEWS
index ed9584b..2b024e9 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,9 @@ PostGIS 3.2.0
   - #4830, ValidateTopology check for edges side face containment
            (Sandro Santilli)
 
+ * New features*
+  - #4841, FindTopology to quickly get a topology record (Sandro Santilli)
+
 PostGIS 3.1.0
 2020/12/18
 
diff --git a/doc/extras_topology.xml b/doc/extras_topology.xml
index 388f735..574fa6e 100644
--- a/doc/extras_topology.xml
+++ b/doc/extras_topology.xml
@@ -641,6 +641,65 @@ face without edges |   0 |
 				<para><xref linkend="validatetopology_returntype"/>, <xref linkend="Topology_Load_Tiger" /></para>
 			</refsection>
 		</refentry>
+
+		<refentry id="FindTopology">
+			<refnamediv>
+				<refname>FindTopology</refname>
+
+				<refpurpose>Returns a topology record by different means.</refpurpose>
+			</refnamediv>
+
+			<refsynopsisdiv>
+				<funcsynopsis>
+					<funcprototype>
+                        <funcdef>topology <function>FindTopology</function></funcdef>
+                        <paramdef><type>TopoGeometry</type> <parameter>topogeom</parameter></paramdef>
+					</funcprototype>
+					<funcprototype>
+                        <funcdef>topology <function>FindTopology</function></funcdef>
+                        <paramdef><type>regclass</type> <parameter>layerTable</parameter></paramdef>
+                        <paramdef><type>name</type> <parameter>layerColumn</parameter></paramdef>
+					</funcprototype>
+					<funcprototype>
+                        <funcdef>topology <function>FindTopology</function></funcdef>
+                        <paramdef><type>name</type> <parameter>layerSchema</parameter></paramdef>
+                        <paramdef><type>name</type> <parameter>layerTable</parameter></paramdef>
+                        <paramdef><type>name</type> <parameter>layerColumn</parameter></paramdef>
+					</funcprototype>
+					<funcprototype>
+                        <funcdef>topology <function>FindTopology</function></funcdef>
+                        <paramdef><type>text</type> <parameter>topoName</parameter></paramdef>
+					</funcprototype>
+					<funcprototype>
+                        <funcdef>topology <function>FindTopology</function></funcdef>
+                        <paramdef><type>int</type> <parameter>id</parameter></paramdef>
+					</funcprototype>
+				</funcsynopsis>
+			</refsynopsisdiv>
+
+			<refsection>
+                <title>Description</title>
+
+                <para>Takes a topology identifier or the identifier of
+a topology-related object and returns a topology.topology record.</para>
+
+                <!-- use this format if new function -->
+                <para>Availability: 3.2.0</para>
+			</refsection>
+
+
+			<refsection>
+				<title>Examples</title>
+<programlisting>
+SELECT name(findTopology('features.land_parcels', 'feature'));
+   name
+-----------
+ city_data
+(1 row)
+</programlisting>
+			</refsection>
+			<!-- Optionally add a "See Also" section -->
+		</refentry>
 	</sect1>
 
 	<sect1 id="Topology_StatsManagement"
diff --git a/topology/Makefile.in b/topology/Makefile.in
index 68ea0bd..0c48cd2 100644
--- a/topology/Makefile.in
+++ b/topology/Makefile.in
@@ -94,7 +94,7 @@ endif
 
 
 
-# Generate any .sql file from .sql.in.c files by running them through the SQL pre-processor
+# Generate any .sql file from .sql.in files by running them through the SQL pre-processor
 %.sql: %.sql.in
 	$(SQLPP) $< | grep -v '^#' | \
 	$(PERL) -lpe "s'MODULE_PATHNAME'\$(MODULEPATH)'g" > $@
@@ -121,6 +121,7 @@ topology.sql: \
 	sql/query/GetNodeEdges.sql.in \
 	sql/manage/TopologySummary.sql.in \
 	sql/manage/CopyTopology.sql.in \
+	sql/manage/FindTopology.sql.in \
 	sql/manage/ManageHelper.sql.in \
 	sql/topoelement/topoelement_agg.sql.in \
 	sql/topogeometry/type.sql.in \
diff --git a/topology/sql/manage/FindTopology.sql.in b/topology/sql/manage/FindTopology.sql.in
new file mode 100644
index 0000000..484fe7c
--- /dev/null
+++ b/topology/sql/manage/FindTopology.sql.in
@@ -0,0 +1,85 @@
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+--
+-- 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.
+--
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+--{
+--  FindTopology(TopoGeometry)
+--
+-- Return a topology.topology record from a TopoGeometry
+--
+CREATE OR REPLACE FUNCTION topology.FindTopology(TopoGeometry)
+RETURNS topology.topology
+AS $$
+    SELECT * FROM topology.topology
+    WHERE id = topology_id($1);
+$$ LANGUAGE 'sql';
+--}
+
+--{
+--  FindTopology(layerRegclass, layerColumn)
+--
+-- Return a topology.topology record from a layer
+--
+CREATE OR REPLACE FUNCTION topology.FindTopology(regclass, name)
+RETURNS topology.topology
+AS $$
+    SELECT t.*
+    FROM topology.topology t
+    JOIN topology.layer l ON (t.id = l.topology_id)
+    WHERE format('%I.%I', l.schema_name, l.table_name)::regclass = $1
+    AND l.feature_column = $2;
+$$ LANGUAGE 'sql';
+--}
+
+--{
+--  FindTopology(layerSchema, layerTable, layerColumn)
+--
+-- Return a topology.topology record from a layer
+--
+CREATE OR REPLACE FUNCTION topology.FindTopology(name, name, name)
+RETURNS topology.topology
+AS $$
+    SELECT t.*
+    FROM topology.topology t
+    JOIN topology.layer l ON (t.id = l.topology_id)
+    WHERE l.schema_name = $1
+    AND l.table_name = $2
+    AND l.feature_column = $3;
+$$ LANGUAGE 'sql';
+--}
+
+--{
+--  FindTopology(topoName)
+--
+-- Return a topology.topology record from a topology name
+--
+CREATE OR REPLACE FUNCTION topology.FindTopology(text)
+RETURNS topology.topology
+AS $$
+    SELECT *
+    FROM topology.topology
+    WHERE name = $1
+$$ LANGUAGE 'sql';
+--}
+
+--{
+--  FindTopology(topoId)
+--
+-- Return a topology.topology record from a topology id
+--
+CREATE OR REPLACE FUNCTION topology.FindTopology(integer)
+RETURNS topology.topology
+AS $$
+    SELECT *
+    FROM topology.topology
+    WHERE id = $1
+$$ LANGUAGE 'sql';
+--}
diff --git a/topology/test/regress/findtopology.sql b/topology/test/regress/findtopology.sql
new file mode 100644
index 0000000..ff07707
--- /dev/null
+++ b/topology/test/regress/findtopology.sql
@@ -0,0 +1,27 @@
+BEGIN;
+
+CREATE SCHEMA s;
+SELECT NULL FROM CreateTopology('a');
+SELECT NULL FROM CreateTopology('b');
+
+SELECT 'by_name', name(findTopology('a'::text));
+SELECT 'by_id', name(findTopology( id(findTopology('a')) ));
+
+CREATE TABLE s.f(a int);
+SELECT NULL FROM AddTopoGeometryColumn('a', 's', 'f', 'ga', 'POINT');
+SELECT NULL FROM AddTopoGeometryColumn('b', 's', 'f', 'gb', 'POINT');
+
+SELECT 'a_by_layer', name(findTopology('s', 'f', 'ga'));
+SELECT 'b_by_layer', name(findTopology('s', 'f', 'gb'));
+
+SELECT 'by_layer_regclass', name(findTopology('s.f', 'ga'));
+
+SELECT 'a_by_topogeom', name(findTopology(
+  toTopoGeom('POINT(0 0)', 'a', 1, 0)
+));
+
+SELECT 'b_by_topogeom', name(findTopology(
+  toTopoGeom('POINT(0 0)', 'b', 1, 0)
+));
+
+ROLLBACK;
diff --git a/topology/test/regress/findtopology_expected b/topology/test/regress/findtopology_expected
new file mode 100644
index 0000000..b493a1e
--- /dev/null
+++ b/topology/test/regress/findtopology_expected
@@ -0,0 +1,7 @@
+by_name|a
+by_id|a
+a_by_layer|a
+b_by_layer|b
+by_layer_regclass|a
+a_by_topogeom|a
+b_by_topogeom|b
diff --git a/topology/topology.sql.in b/topology/topology.sql.in
index bf93774..89f86fc 100644
--- a/topology/topology.sql.in
+++ b/topology/topology.sql.in
@@ -2107,9 +2107,6 @@ $$
 LANGUAGE 'plpgsql' VOLATILE STRICT;
 --} DropTopology
 
-#include "sql/manage/TopologySummary.sql.in"
-#include "sql/manage/CopyTopology.sql.in"
-
 -- Spatial predicates
 #include "sql/predicates.sql.in"
 
@@ -2147,6 +2144,10 @@ LANGUAGE 'plpgsql' VOLATILE STRICT;
 
 --general management --
 #include "sql/manage/ManageHelper.sql.in"
+#include "sql/manage/TopologySummary.sql.in"
+#include "sql/manage/CopyTopology.sql.in"
+#include "sql/manage/FindTopology.sql.in"
+
 
 CREATE OR REPLACE FUNCTION topology.postgis_topology_scripts_installed() RETURNS text
 	AS _POSTGIS_SQL_SELECT_POSTGIS_SCRIPTS_VERSION

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

Summary of changes:
 NEWS                                        |  3 +
 doc/extras_topology.xml                     | 59 ++++++++++++++++++++
 topology/Makefile.in                        |  3 +-
 topology/sql/manage/FindTopology.sql.in     | 85 +++++++++++++++++++++++++++++
 topology/test/regress/findtopology.sql      | 27 +++++++++
 topology/test/regress/findtopology_expected |  7 +++
 topology/topology.sql.in                    |  7 ++-
 7 files changed, 187 insertions(+), 4 deletions(-)
 create mode 100644 topology/sql/manage/FindTopology.sql.in
 create mode 100644 topology/test/regress/findtopology.sql
 create mode 100644 topology/test/regress/findtopology_expected


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list