[postgis-tickets] [PostGIS] #4888: st_azimuth geography calculation reslut mismatch version 3.1.1
PostGIS
trac at osgeo.org
Mon Mar 22 07:04:55 PDT 2021
#4888: st_azimuth geography calculation reslut mismatch version 3.1.1
---------------------+---------------------------
Reporter: gislars | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 3.1.2
Component: postgis | Version: 3.1.x
Keywords: |
---------------------+---------------------------
I'm doing calculation of directions and with postgis version 3.1.1. I get
different or wrong results. It depends on the direction.
I created a test case:
{{{
SELECT ST_Azimuth('POINT(0 0)'::geography, 'POINT(0 1)'::geography) AS
a_north,
ST_Azimuth('POINT(0 0)'::geography, 'POINT(1 1)'::geography) AS
a_northeast,
ST_Azimuth('POINT(0 0)'::geography, 'POINT(1 0)'::geography) AS
a_east,
ST_Azimuth('POINT(0 1)'::geography, 'POINT(0 0)'::geography) AS
a_north_reverse,
ST_Azimuth('POINT(1 1)'::geography, 'POINT(0 0)'::geography) AS
a_northeast_reverse,
ST_Azimuth('POINT(1 0)'::geography, 'POINT(0 0)'::geography) AS
a_east_reverse
union all
select
ST_Azimuth('POINT(0 0)'::geometry, 'POINT(0 1)'::geometry) AS
a_north,
ST_Azimuth('POINT(0 0)'::geometry, 'POINT(1 1)'::geometry) AS
a_northeast,
ST_Azimuth('POINT(0 0)'::geometry, 'POINT(1 0)'::geometry) AS
a_east,
ST_Azimuth('POINT(0 1)'::geometry, 'POINT(0 0)'::geometry) AS
a_north_reverse,
ST_Azimuth('POINT(1 1)'::geometry, 'POINT(0 0)'::geometry) AS
a_northeast_reverse,
ST_Azimuth('POINT(1 0)'::geometry, 'POINT(0 0)'::geometry) AS
a_east_reverse
}}}
the result:
|| a_north || a_northeast || a_east || a_north_reverse ||
a_northeast_reverse || a_east_reverse ||
|| 3.141592653589793 || 0.788680084525966 || 1.5707963267948966 ||
3.141592653589793 || 5.494352906159104 || 4.71238898038469 ||
|| 0 || 0.7853981633974483 || 1.5707963267948966 || 3.141592653589793
|| 3.9269908169872423 || 4.71238898038469 ||
the same result but converted to degrees:
|| a_north || a_northeast || a_east || a_north_reverse ||
a_northeast_reverse || a_east_reverse ||
|| 180 || 45.18804022935888 || 90 || 180 || 314.80323267835513 || 270
||
|| 0 || 45 || 90 || 180 || 225.00000000000006 || 270 ||
The first row is displaying the results for geography type, the second for
geometry type.
These are the results for postgis version 2.5.2
|| a_north || a_northeast || a_east || a_north_reverse ||
a_northeast_reverse || a_east_reverse ||
|| 0 || 45.18804022935888 || 90 || 180 || 225.19676732164487 ||
-90 ||
|| 0 || 45 || 90 || 180 || 225.00000000000006 || -90 ||
The value of a_northeast_reverse and a_north value type geography isn't
correct, it should be 0 (a_north) or 225 (a_northeast_reverse).
The other values are ok. The difference for a_east_reverse is 360
degree/2pi, the change was introduced in #4718
Am I doing something wrong here? I'm not seeing what the problem might be.
I couldn't figure out if it is actual a postgis problem or proj problem.
Could someone verify this or help me to get the correct values?
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4888>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list