I have a PostGIS (PostgreSQL 13/PostGIS 3.1.1 on Debian 11.7) table with points in EPSG:6708, so it's plain coordinates (data from Northern Italy). I need to get lat/long coordinates, so I do:
SELECT ST_AsText(the_geom) AS xy, ST_AsText(ST_Transform(the_geom,4326)) AS ll FROM acq_impianti WHERE gid=426;
xy | ll
--------------------------------------------+-------------------------------------------
POINT(291349.5482259364 5072882.274108588) | POINT(52.9750863624063 2.074122662821441)
which is absolutely wrong; in fact if I do the same transformation using this tool, I obtain:
I can't figure out what I'm doing wrong....
EDIT: Using ST_FlipCoordinates solves the problem, but maybe there is a better way to handle this
SELECT ST_AsText(the_geom) AS xy, ST_AsText(ST_Transform(ST_FlipCoordinates(the_geom),4326)) AS ll FROM acq_impianti WHERE gid=426; xy | ll
--------------------------------------------+---------------------------------------------
POINT(291349.5482259364 5072882.274108588) | POINT(12.316072170259908 45.77796903086367)