Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#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)

Change History (6)

comment:1 by pramsey, 3 years ago

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 ever uses the Southing/Westing version.

Last edited 3 years ago by pramsey (previous) (diff)

comment:2 by Paul Ramsey <pramsey@…>, 3 years ago

Resolution: fixed
Status: newclosed

In e2b8950/git:

Swap axes that have 'Lat' in the first axis. Don't swap axes that are 'Easting' first. After that, believe the directionality provided and swap any 'north' axes. If you still don't know what to do, just leave the axes alone.
Closes #4748

comment:3 by Paul Ramsey <pramsey@…>, 3 years ago

In 6f35cc3/git:

Swap axes that have 'Lat' in the first axis. Don't swap axes that are 'Easting' first. After that, believe the directionality provided and swap any 'north' axes. If you still don't know what to do, just leave the axes alone.
References #4748

comment:4 by Paul Ramsey <pramsey@…>, 3 years ago

In 826ac5c1/git:

Add test for polar stereographic transform. References #4748

comment:5 by Paul Ramsey <pramsey@…>, 3 years ago

In 04d1673/git:

Only do axis flips on CRS that have a "Lat" as the first column. Otherwise just take the EPSG database order. References #4842, #4748

comment:6 by Paul Ramsey <pramsey@…>, 3 years ago

In 4f6d81f/git:

Only do axis flips on CRS that have a "Lat" as the first column. Otherwise just take the EPSG database order. References #4842, #4748

Note: See TracTickets for help on using tickets.