[postgis-devel] [PostGIS] #354: ST_FlipCoordinates(geometry)
PostGIS
trac at osgeo.org
Tue Dec 22 11:05:26 PST 2009
#354: ST_FlipCoordinates(geometry)
--------------------------+-------------------------------------------------
Reporter: pramsey | Owner: pramsey
Type: enhancement | Status: new
Priority: low | Milestone: PostGIS 2.0.0
Component: postgis | Version: trunk
Resolution: | Keywords:
--------------------------+-------------------------------------------------
Comment (by kneufeld):
Until this gets implemented in C, this could be a simple SQL function
wrapper.
It's been many years since I've done matrix algebra so I might not have
this exactly right, but this does seem to work.
{{{
SELECT ST_AsText(ST_Affine(
column1,
cos(pi()/2), sin(pi()/2),
sin(pi()/2), cos(pi()/2),
0, 0
))
FROM (VALUES
('POINT(4 3)'),
('LINESTRING(1 2, 59 34, -9 3)'),
('POLYGON (( 2 13, 6 12, 4 8, 2 7, 2 13 ),
( 4 12, 3 10, 3 9, 4 10, 4 12 ))')
) a;
st_astext
-------------------------------------------------------------
POINT(3 4)
LINESTRING(2 1,34 59,3 -9)
POLYGON((13 2,12 6,8 4,7 2,13 2),(12 4,10 3,9 3,10 4,12 4))
(3 rows)
}}}
Note: anyone wishing to use [http://postgis.refractions.net/documentation/
manual-svn/ST_Affine.html ST_Affine] to swap ordinates may need to push
the results through [http://postgis.refractions.net/documentation/manual-
svn/ST_SnapToGrid.html ST_SnapToGrid] since matrix computation is done on
the coordinates.
{{{
SELECT ST_AsText(ST_Affine(
'POINT(0 4)'::geometry,
cos(pi()/2), sin(pi()/2),
sin(pi()/2), cos(pi()/2),
0, 0
st_astext
--------------------------------
POINT(4 2.44929359829471e-016)
(1 row)
));
}}}
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/354#comment:1>
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-devel
mailing list