#4748 closed defect (fixed)
Incorrect coordinate transformation
Reported by: | Matthew Blissett | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 3.1.0 |
Component: | postgis | Version: | master |
Keywords: | Cc: |
Description
Converting coordinates to EPSG:3031 projection gives incorrect results, with the coordinates swapped:
SELECT postgis_full_version(); POSTGIS="3.1.0dev b9c792c" [EXTENSION] PGSQL="120" GEOS="3.9.0dev-CAPI-1.14.0" PROJ="7.2.0" LIBXML="2.9.4" LIBJSON="0.12.1" LIBPROTOBUF="1.3.1" WAGYU="0.5.0 (Internal)" TOPOLOGY SELECT ST_AsEWKT(ST_Transform(ST_SetSRID(ST_Point(-36.75, -54.25), 4326), 3031)); SRID=3031;POINT(3213318.496649317 -2399498.730067588)
The expected result, and the result on 3.0.2, is SRID=3031;POINT(-2399498.73006759 3213318.49664932)
.
There was some discussion on IRC: http://irclogs.geoapt.com/postgis/%23postgis.2020-08-24.log starting at 20:28:
PaulRamsey: axis swapping behaviour changed in proj too
ReginaObe: did things switch in proj 6?
PaulRamsey: yes, that's when it got the in built epsg database and went to epsg axis ordering
ReginaObe: okay on my 3.1.0alpha2 with proj 5.2.0 I get SRID=3031;POINT(-2399498.73006759 3213318.49664932)
So this case is interesting because it it's polar stereographic, and the axis swap logic was "swap if the first axis has a 'north' direction". Well... all the axes in the Antarctic have a north direction. So this is a weird axis that is "Easting" but also "north". I've changed up the logic to leave all "E" axes alone, and only then look at axis direction.
It's possible this will result in "unexpected" results in Krovak or some other Southing/Westing systems, but there seem to be almost none of those, so maybe we'll never run across it. I cannot do anything definitive at this time, because I have no idea how users of Krovak like to consume their coordinates. There's a "GIS oriented" form of Krovak that uses Easting/Northing, so maybe nobody every using the Southing/Westing version.