[postgis-users] Weird behavior in ST_FlipCoordinates

Marcelo Soares Souza marcelo at juntadados.org
Tue Nov 5 10:39:38 PST 2013


  Using Debian GNU/Linux 7.2.0 (amd64), PostgreSQL 9.3.1 and PostGIS
2.2.0dev r12082 (GEOS 3.3.3 and GDAL 1.10.1).

  I've created a test Database with PostGIS extension and inserted two
shapes (Polygon). Then i call the ST_FlipCoordinates function.

  "SELECT id, ST_AsEWKT(ST_FlipCoordinates(shape)) AS ST_FlipCoordinates,
ST_AsEWKT(shape) AS Shape FROM pol;"

  And i got strange result, ST_FlipCoordinates, a IMMUTABLE function,
changed some data in database.

* In the First execution i got

ID 1 (It's Okey)

ST_FlipCoordinates(shape): "SRID=4674;POLYGON((-50.09765625
-2.63578857416661,-59.4140625 -15.4536802243458,-28.30078125
-15.2841851140764,-29.53125 3.68885514314705,-50.09765625
-2.63578857416661))"

shape: "SRID=4674;POLYGON((-2.63578857416661
-50.09765625,-15.4536802243458 -59.4140625,-15.2841851140764
-28.30078125,3.68885514314705 -29.53125,-2.63578857416661 -50.09765625))"

ID 2 (Wrong Result)

ST_FlipCoordinates(shape): "SRID=4674;POLYGON((-8.75479470243561
-24.78515625,-23.2413461023861 -26.015625,-17.4764321971955
-17.578125,-11.5230875068685 -17.2265625,-8.40716816360108
-23.73046875,-8.75479470243561 -24.78515625))"

shape: "SRID=4674;POLYGON((-8.75479470243561
-24.78515625,-23.2413461023861 -26.015625,-17.4764321971955
-17.578125,-11.5230875068685 -17.2265625,-8.40716816360108
-23.73046875,-8.75479470243561 -24.78515625))"

* Second execution i got

ID 1 (Continues Normal)

ST_FlipCoordinates(shape): "SRID=4674;POLYGON((-50.09765625
-2.63578857416661,-59.4140625 -15.4536802243458,-28.30078125
-15.2841851140764,-29.53125 3.68885514314705,-50.09765625
-2.63578857416661))"

shape: "SRID=4674;POLYGON((-2.63578857416661
-50.09765625,-15.4536802243458 -59.4140625,-15.2841851140764
-28.30078125,3.68885514314705 -29.53125,-2.63578857416661 -50.09765625))"

ID 2 (Data Changed permanently and Flipped all data)

ST_FlipCoordinates(shape):"SRID=4674;POLYGON((-24.78515625
-8.75479470243561,-26.015625 -23.2413461023861,-17.578125
-17.4764321971955,-17.2265625 -11.5230875068685,-23.73046875
-8.40716816360108,-24.78515625 -8.75479470243561))"

shape: "SRID=4674;POLYGON((-24.78515625 -8.75479470243561,-26.015625
-23.2413461023861,-17.578125 -17.4764321971955,-17.2265625
-11.5230875068685,-23.73046875 -8.40716816360108,-24.78515625
-8.75479470243561))"

  I've tested in PostgreSQL 9.1 and 9.2, with PostGIS 2.0.4 and 2.1.0 too.

  I've opened a ticket http://trac.osgeo.org/postgis/ticket/2529



More information about the postgis-users mailing list