| 5 | |
| 6 | == Rotate Geometry around a point(geom,x,y) == |
| 7 | {{{ |
| 8 | #!sql |
| 9 | CREATE OR REPLACE FUNCTION RotateAtPoint(the_geom geometry, pt_x double precision, pt_y double precision, rotrads double precision) |
| 10 | RETURNS geometry AS |
| 11 | $$ |
| 12 | SELECT 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 |
| 20 | CREATE 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 | }}} |
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 | | }}} |