Opened 9 years ago

Closed 7 years ago

Last modified 7 years ago

#3468 closed defect (wontfix)

ST_GeogFromText should swap longitude when latitude crosses 90 deg

Reported by: tomvantilburg Owned by: pramsey
Priority: blocker Milestone: PostGIS 2.4.0
Component: postgis Version: 2.2.x
Keywords: Cc:

Description

ST_GeogFromText calculates back from 90 (92 becomes 88 etc.) when entering a latitude higher than 90. This would make (a bit of) sense if the longitude would be swapped by 180 deg, (going over the pole) but it doesn't.

Change History (9)

comment:1 by tomvantilburg, 9 years ago

Reproduce with: SELECT ST_AsText(ST_GeogFromText('POINT(10 91)'))

comment:2 by munderwood, 9 years ago

I agree that the current behaviour poses a problem. Silently turning (10, 91) into (-170, 89) would definitely be better than turning it into (10, 89) as happens now.

An even better option might be to throw an error, preventing the INSERT/UPDATE operation that is trying to set a latitude greater than 90. Best of all would be if there were a flag with which the DBA could make the choice of behaviour. Something like SET out_of_range_latitudes TO wrap|reject|reflect, for example. (I personally don't see any reason to have the "reflect" option for new databases, but it could be used in existing databases for backward compatibility of behaviour.)

comment:3 by pramsey, 9 years ago

Milestone: PostGIS 2.2.2PostGIS 2.2.3

comment:4 by robe, 8 years ago

Milestone: PostGIS 2.2.3PostGIS 2.4.0

comment:5 by dbaston, 7 years ago

Priority: mediumblocker

comment:6 by robe, 7 years ago

oh and this one. I do not consider this a blocker.

comment:7 by robe, 7 years ago

Milestone: PostGIS 2.4.0PostGIS 2.5.0

comment:8 by pramsey, 7 years ago

Resolution: wontfix
Status: newclosed

If I evaluate bearing, then altitude

POINT(10 91) == POINT(-170 89)

If I evaluate altitude, then bearing

POINT(10 91) == POINT(10 89)

I don't think there's any stronger case for flipping to the alternate hemisphere than there is for not doing so. That just leaves erroring out or not, and the case in both bearing and altitude coercion is that a NOTICE is raised, which seems sufficient for me.

postgis24=# SELECT ST_AsText(ST_GeogFromText('POINT(10 91)'));
NOTICE:  Coordinate values were coerced into range [-180 -90, 180 90] for GEOGRAPHY
  st_astext   
--------------
 POINT(10 89)
(1 row)

comment:9 by robe, 7 years ago

Milestone: PostGIS 2.5.0PostGIS 2.4.0
Note: See TracTickets for help on using tickets.