Changes between Version 19 and Version 20 of UsersWikiplpgsqlfunctions
- Timestamp:
- 10/12/09 18:06:12 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
UsersWikiplpgsqlfunctions
v19 v20 4 4 5 5 == This is an area to put utility functions or wrappers around PostGIS == 6 [wiki:UsersWikiplpgsqlfunctionsDistance Distance PL/PGSQL/SQL Functions]6 [wiki:UsersWikiplpgsqlfunctionsDistance Distance /Spatial Reference support functions PL/PGSQL/SQL Functions] 7 7 8 8 * '''Generate an arc given two points on the arc, the centre point and direction''' … … 48 48 49 49 50 }}}51 52 * '''Find UTM (WGS84) SRID for a point (in any SRID)'''53 54 {{{55 #!sql56 -- Function: utmzone(geometry)57 -- DROP FUNCTION utmzone(geometry);58 59 CREATE OR REPLACE FUNCTION utmzone(geometry)60 RETURNS integer AS61 $BODY$62 DECLARE63 geomgeog geometry;64 zone int;65 pref int;66 67 BEGIN68 geomgeog:= ST_Transform($1,4326);69 70 IF (ST_Y(geomgeog))>0 THEN71 pref:=32600;72 ELSE73 pref:=32700;74 END IF;75 76 zone:=floor((ST_X(geomgeog)+180)/6)+1;77 78 RETURN zone+pref;79 END;80 $BODY$ LANGUAGE 'plpgsql' IMMUTABLE81 COST 100;82 50 }}} 83 51