[postgis-tickets] [PostGIS] #2571: Create version of ST_RotateY with pointOrigin like ST_Rotate()

PostGIS trac at osgeo.org
Sat Dec 14 22:23:59 PST 2013


#2571: Create version of ST_RotateY with pointOrigin like ST_Rotate()
---------------------------+------------------------------------------------
 Reporter:  smathermather  |       Owner:  pramsey      
     Type:  patch          |      Status:  new          
 Priority:  medium         |   Milestone:  PostGIS 2.1.2
Component:  postgis        |     Version:  2.1.x        
 Keywords:                 |  
---------------------------+------------------------------------------------
 geometry ST_RotateY(geometry geomA, float rotRadians, geometry
 pointOrigin)

 -- Function: ST_RotateY(geometry, double precision, geometry)
 CREATE OR REPLACE FUNCTION ST_RotateY(geomA geometry, rotRadians double
 precision, pointOrigin geometry)
   RETURNS geometry AS
 $BODY$

 -- Transform geometry to nullsville (0,0,0) so rotRadians will take place
 around the pointOrigin
 WITH transformed AS (
     SELECT ST_Translate(geomA, -1 * ST_X(pointOrigin), -1 *
 ST_Y(pointOrigin), -1 * ST_Z(pointOrigin)) AS the_geom
     ),
 -- Rotate in place
 rotated AS (
     SELECT ST_RotateY(the_geom, rotRadians) AS the_geom FROM transformed
     ),
 -- Translate back home
 rotTrans AS (
     SELECT ST_Translate(the_geom, ST_X(pointOrigin), ST_Y(pointOrigin),
 ST_Z(pointOrigin)) AS the_geom
         FROM rotated
     )
 -- profit
 SELECT the_geom from rotTrans

 ;

 $BODY$
   LANGUAGE sql VOLATILE
   COST 100;

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2571>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list