Changes between Version 5 and Version 6 of UsersWikiplpgsqlfunctions


Ignore:
Timestamp:
04/19/09 00:39:50 (16 years ago)
Author:
robe
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiplpgsqlfunctions

    v5 v6  
    77 * '''Find UTM (WGS84)  SRID for a point (in any SRID)'''
    88
    9  {{{
     9{{{
     10#!sql
    1011 -- Function: utmzone(geometry)
    1112 -- DROP FUNCTION utmzone(geometry);
     
    2021
    2122 BEGIN
    22      geomgeog:=transform($1,4326);
     23     geomgeog:= ST_Transform($1,4326);
    2324
    24      IF (y(geomgeog))>0 THEN
     25     IF (ST_Y(geomgeog))>0 THEN
    2526        pref:=32600;
    2627     ELSE
     
    2829     END IF;
    2930
    30      zone:=floor((x(geomgeog)+180)/6)+1;
     31     zone:=floor((ST_X(geomgeog)+180)/6)+1;
    3132
    3233     RETURN zone+pref;
     
    3839 * '''Find Length of Day for a given location and date'''
    3940{{{
     41#!sql
    4042 CREATE OR REPLACE FUNCTION daylength(geometry, date)
    41  RETURNS double precision AS 'select 24*(ACOS(1-(1-TAN(radians(Y(transform($1,4326))))*TAN(.409088 * COS(.0172024 * extract(doy from $2)))))/PI());'
     43 RETURNS double precision AS
     44$$
     45SELECT 24*(ACOS(1-(1-TAN(radians(Y(transform($1,4326))))*TAN(.409088 * COS(.0172024 * extract(doy from $2)))))/PI());
     46$$
    4247 LANGUAGE 'sql';
    4348}}}
     
    4550 * '''Rotate Geometry around a point(geom,x,y)'''
    4651{{{
     52#!sql
    4753CREATE OR REPLACE FUNCTION RotateAtPoint(geometry, double precision, double precision, double precision)
    48  RETURNS geometry AS 'SELECT translate( rotate( translate( $1, -1*$2, -1*$3), $4), $2, $3)'
     54 RETURNS geometry AS
     55$$
     56SELECT ST_Translate( ST_Rotate( ST_Translate( $1, -1*$2, -1*$3), $4), $2, $3)
     57$$
    4958   LANGUAGE 'sql';
    5059}}}
     
    5261 * '''Create Ellipse (x,y,rx,ry,rotation,#of segments in 1/4 of ellipse)'''
    5362{{{
     63#!sql
    5464CREATE OR REPLACE FUNCTION Ellipse(double precision, double precision, double precision, double precision, double precision, integer)
    5565 RETURNS geometry AS
    56  'SELECT translate( rotate( scale( buffer(makepoint(0,0), 0.5, $6), $3, $4), $5), $1, $2)'
     66 $$
     67   SELECT ST_Translate( ST_Rotate( ST_Scale( ST_Buffer(ST_Point(0,0), 0.5, $6), $3, $4), $5), $1, $2)
     68$$
    5769 LANGUAGE 'sql';
    5870}}}