-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsicob_find_srid.sql
More file actions
30 lines (29 loc) · 1.22 KB
/
Copy pathsicob_find_srid.sql
File metadata and controls
30 lines (29 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
SET CLIENT_ENCODING TO 'utf8';
CREATE OR REPLACE FUNCTION public.sicob_find_srid(character varying, character varying, character varying)
RETURNS integer
LANGUAGE plpgsql
IMMUTABLE STRICT
AS $function$
DECLARE
schem varchar = $1;
tabl varchar = $2;
sr int4;
BEGIN
--DEVUELVE EL CODIGO DEL SISTEMA DE PROYECCION SRID CORRESPONDIENTE AL CAMPO GEOMETRICO
--PERTENECIENTE A LA TABLA, parametros: esquema, nombre de la tabla, nombre del campo geometrico.
-------------------------------------------------------------------------------------------------
-- if the table contains a . and the schema is empty
-- split the table into a schema and a table
-- otherwise drop through to default behavior
IF ( schem = '' and strpos(tabl,'.') > 0 ) THEN
schem = substr(tabl,1,strpos(tabl,'.')-1);
tabl = substr(tabl,length(schem)+2);
END IF;
select SRID into sr from geometry_columns where (f_table_schema = schem or schem = '') and f_table_name = tabl and f_geometry_column = $3;
IF NOT FOUND THEN
RAISE EXCEPTION 'find_srid() - could not find the corresponding SRID - is the geometry registered in the GEOMETRY_COLUMNS table? Is there an uppercase/lowercase mismatch?';
END IF;
return sr;
END;
$function$