BUG #17037: ST_Azimuth used with geography produces results not in accordance with documentation

Started by PG Bug reporting formalmost 5 years ago2 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 17037
Logged by: Jan Heckman
Email address: jan.heckman@gmail.com
PostgreSQL version: 11.11
Operating system: windows 10 pro 21H1
Description:

The following queries illustrate that ST_Azimuth can fail to follow
https://postgis.net/docs/ST_Azimuth.html with dy < 0 and dx < 0.
The first three queries produce correct results, the last one does not:

select degrees(st_azimuth('POINT(0 1)'::geometry,'POINT(0 0)'::geometry));
degrees
---------
180
(1 row)

select degrees(st_azimuth('POINT(0 1)'::geography,'POINT(0
0)'::geography));
degrees
---------
180
(1 row)

select degrees(st_azimuth('POINT(0 1)'::geometry,'POINT(-0.01
0)'::geometry));
degrees
------------------
180.572938697683
(1 row)

select degrees(st_azimuth('POINT(0 1)'::geography,'POINT(-0.01
0)'::geography));
degrees
------------------
359.423171739084
(1 row)

This behavior occurs also with less 'nice' inputs, e.g.
select degrees(st_azimuth(ST_POINT(4.76389,
52.308601)::geography,'POINT(4.43722 51.956902)'::geography));
degrees
-----------------
330.11876325276
This is NOT the course to fly from airport AMS to airport RTM.

Doing the query with geometry instead of geography produces a better result,
but should be inaccurate for greater distances:
select degrees(st_azimuth(ST_POINT(4.76389,
52.308601)::geometry,'POINT(4.43722 51.956902)'::geometry));
degrees
------------------
222.886982058682

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: PG Bug reporting form (#1)
Re: BUG #17037: ST_Azimuth used with geography produces results not in accordance with documentation

PG Bug reporting form <noreply@postgresql.org> writes:

The following queries illustrate that ST_Azimuth can fail to follow
https://postgis.net/docs/ST_Azimuth.html with dy < 0 and dx < 0.

You need to send this to the appropriate postgis mailing list.
This list is for core-server bugs, and I'm not sure that any
postgis developers follow it closely.

regards, tom lane