Changes between Version 9 and Version 10 of UsersWikiplpgsqlfunctionsDistance


Ignore:
Timestamp:
Oct 12, 2009, 6:06:38 PM (15 years ago)
Author:
robe
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiplpgsqlfunctionsDistance

    v9 v10  
    11== Distance related helper functions ==
    22[wiki:UsersWikiplpgsqlfunctions Back To PL/PGSQL/SQL Functions]
     3
     4 * '''Find UTM (WGS84)  SRID for a point (in any SRID)'''
     5{{{
     6#!sql
     7 -- Function: utmzone(geometry)
     8 -- DROP FUNCTION utmzone(geometry);
     9
     10 CREATE OR REPLACE FUNCTION utmzone(geometry)
     11   RETURNS integer AS
     12 $BODY$
     13 DECLARE
     14     geomgeog geometry;
     15     zone int;
     16     pref int;
     17
     18 BEGIN
     19     geomgeog:= ST_Transform($1,4326);
     20
     21     IF (ST_Y(geomgeog))>0 THEN
     22        pref:=32600;
     23     ELSE
     24        pref:=32700;
     25     END IF;
     26
     27     zone:=floor((ST_X(geomgeog)+180)/6)+1;
     28
     29     RETURN zone+pref;
     30 END;
     31 $BODY$ LANGUAGE 'plpgsql' IMMUTABLE
     32   COST 100;
     33}}}
     34
    335 * '''An ST_Dwithin like function that uses indexes for degree point data'''
    436[http://www.postgis.org/pipermail/postgis-users/2009-June/023711.html] (use for pre PostGIS 1.5.)