1-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2-- 3-- PostGIS - Spatial Types for PostgreSQL 4-- http://postgis.net 5-- 6-- Copyright (C) 2021 Sandro Santilli <strk@kbt.io> 7-- 8-- This is free software; you can redistribute and/or modify it under 9-- the terms of the GNU General Public Licence. See the COPYING file. 10-- 11-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 12 13--{ 14-- FindLayer(TopoGeometry) 15-- 16-- Return a topology.layer record from a TopoGeometry 17-- 18CREATE OR REPLACE FUNCTION topology.FindLayer(tg TopoGeometry) 19RETURNS topology.layer 20AS $$ 21 SELECT * FROM topology.layer 22 WHERE topology_id = topology_id($1) 23 AND layer_id = layer_id($1) 24$$ LANGUAGE 'sql'; 25--} 26 27--{ 28-- FindLayer(layerRegclass, layerColumn) 29-- 30-- Return a topology.layer record from a layer table/column 31-- 32CREATE OR REPLACE FUNCTION topology.FindLayer(layer_table regclass, feature_column name) 33RETURNS topology.layer 34AS $$ 35 SELECT l.* 36 FROM topology.layer l, pg_class c, pg_namespace n 37 WHERE l.schema_name = n.nspname 38 AND l.table_name = c.relname 39 AND c.oid = $1 40 AND c.relnamespace = n.oid 41 AND l.feature_column = $2 42$$ LANGUAGE 'sql'; 43--} 44 45--{ 46-- FindLayer(layerSchema, layerTable, layerColumn) 47-- 48-- Return a topology.layer record from a layer schema/table/column 49-- 50CREATE OR REPLACE FUNCTION topology.FindLayer(schema_name name, table_name name, feature_column name) 51RETURNS topology.layer 52AS $$ 53 SELECT * FROM topology.layer 54 WHERE schema_name = $1 55 AND table_name = $2 56 AND feature_column = $3; 57$$ LANGUAGE 'sql'; 58--} 59 60--{ 61-- FindLayer(topoName) 62-- 63-- Return a topology.layer record from a topology id and layer id 64-- 65CREATE OR REPLACE FUNCTION topology.FindLayer(topology_id integer, layer_id integer) 66RETURNS topology.layer 67AS $$ 68 SELECT * FROM topology.layer 69 WHERE topology_id = $1 70 AND layer_id = $2 71$$ LANGUAGE 'sql'; 72--} 73