1-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2-- 3-- PostGIS - Spatial Types for PostgreSQL 4-- http://postgis.net 5-- 6-- Copyright (C) 2011 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-- Override geometrytype() for topogeometry objects 15-- 16-- Note: For performance reasons, this function always assumes 17-- TopoGeometry are of the MULTI type. This may not always 18-- be the case if you convert the TopoGeometry to an actual 19-- Geometry. 20-- 21-- }{ 22CREATE OR REPLACE FUNCTION topology.GeometryType(tg topology.TopoGeometry) 23 RETURNS text 24AS 25$$ 26 SELECT CASE 27 WHEN type($1) = 1 THEN 'MULTIPOINT' 28 WHEN type($1) = 2 THEN 'MULTILINESTRING' 29 WHEN type($1) = 3 THEN 'MULTIPOLYGON' 30 WHEN type($1) = 4 THEN 'GEOMETRYCOLLECTION' 31 ELSE 'UNEXPECTED' 32 END; 33$$ 34LANGUAGE 'sql' STABLE STRICT; 35-- } 36 37-- { 38-- Override st_geometrytype() for topogeometry objects 39-- 40-- Note: For performance reasons, this function always assumes 41-- TopoGeometry are of the MULTI type. This may not always 42-- be the case if you convert the TopoGeometry to an actual 43-- Geometry. 44-- 45-- }{ 46CREATE OR REPLACE FUNCTION topology.ST_GeometryType(tg topology.TopoGeometry) 47 RETURNS text 48AS 49$$ 50 SELECT CASE 51 WHEN type($1) = 1 THEN 'ST_MultiPoint' 52 WHEN type($1) = 2 THEN 'ST_MultiLinestring' 53 WHEN type($1) = 3 THEN 'ST_MultiPolygon' 54 WHEN type($1) = 4 THEN 'ST_GeometryCollection' 55 ELSE 'ST_Unexpected' 56 END; 57$$ 58LANGUAGE 'sql' STABLE STRICT; 59-- } 60