Changes between Version 30 and Version 31 of UsersWikiplpgsqlfunctions


Ignore:
Timestamp:
Aug 5, 2020, 10:39:11 AM (4 years ago)
Author:
mdavis
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiplpgsqlfunctions

    v30 v31  
    33 
    44This is an area to put utility functions or wrappers around PostGIS.
     5
     6== Rotate Geometry around a point(geom,x,y) ==
     7{{{
     8#!sql
     9CREATE OR REPLACE FUNCTION RotateAtPoint(the_geom geometry, pt_x double precision, pt_y double precision, rotrads double precision)
     10 RETURNS geometry AS
     11$$
     12SELECT ST_Translate( ST_Rotate( ST_Translate( $1, -1*$2, -1*$3), $4), $2, $3)
     13$$
     14   LANGUAGE 'sql';
     15}}}
     16
     17== Construct Ellipse ( x,y, rx,ry [,rotation [,#of segments in 1/4 of ellipse] ] ) ==
     18{{{
     19#!sql
     20CREATE OR REPLACE FUNCTION ST_Ellipse(x double precision, y double precision,
     21  rx double precision, ry double precision,
     22  rotation double precision DEFAULT 0.0, quadSeg integer DEFAULT 8)
     23 RETURNS geometry AS
     24 $$
     25   SELECT ST_Translate( ST_Rotate( ST_Scale( ST_Buffer(ST_Point(0,0), 0.5, quadSeg), rx, ry), rotation), x, y)
     26$$
     27 LANGUAGE 'sql';
     28}}}
    529
    630== Construct an arc given two points on the arc, the centre point and direction or size ==
     
    167191}}}
    168192
    169 == Rotate Geometry around a point(geom,x,y) ==
    170 {{{
    171 #!sql
    172 CREATE OR REPLACE FUNCTION RotateAtPoint(the_geom geometry, pt_x double precision, pt_y double precision, rotrads double precision)
    173  RETURNS geometry AS
    174 $$
    175 SELECT ST_Translate( ST_Rotate( ST_Translate( $1, -1*$2, -1*$3), $4), $2, $3)
    176 $$
    177    LANGUAGE 'sql';
    178 }}}
    179 
    180 == Construct Ellipse ( x,y, rx,ry [,rotation [,#of segments in 1/4 of ellipse] ] ) ==
    181 {{{
    182 #!sql
    183 CREATE OR REPLACE FUNCTION ST_Ellipse(x double precision, y double precision,
    184   rx double precision, ry double precision,
    185   rotation double precision DEFAULT 0.0, quadSeg integer DEFAULT 8)
    186  RETURNS geometry AS
    187  $$
    188    SELECT ST_Translate( ST_Rotate( ST_Scale( ST_Buffer(ST_Point(0,0), 0.5, quadSeg), rx, ry), rotation), x, y)
    189 $$
    190  LANGUAGE 'sql';
    191 }}}
    192193
    193194== Construct a multilinestring consisting of the interior and exterior rings of a polygon/multipolygon ==