Opened 4 years ago
Closed 3 years ago
#4880 closed defect (fixed)
ST_Azimuth with geography type returns incorrect value
Reported by: | francoisb | Owned by: | robe |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 3.1.4 |
Component: | documentation | Version: | 3.1.x |
Keywords: | angle | Cc: |
Description
It seems #4718 is a regression.
Perfect west 270° (3π/2 rad) - the only value in the regression test from tickets.sql which had a negative result in the previous code - is by chance correct, but all other expected results in the range 180°-360° (π-2π rad) are incorrect.
Second, a perfect north (value exactly 0) is now incorrectly returned as 180° (π rad), instead of 0.
The fix is simple. Expected formula in lwgeodetic.c line 2180 is:
return az < 0 ? az + 2.0 * M_PI : az;
instead of:
return az > 0 ? az : M_PI - az;
Regression test from tickets.sql should add additional values, say at 45° (Northeast, π/4) and at 315° (Northwest, 7π/4).
Documentation for ST_Azimuth could be extended to read:
North = 0; Northeast = π/4; East = π/2; Southeast = 3π/4; South = π; Southwest 5π/4; West = 3π/2; Northwest = 7π/4
instead of:
North = 0; East = π/2; South = π; West = 3π/2
Change History (7)
comment:1 by , 4 years ago
comment:2 by , 4 years ago
Milestone: | PostGIS 3.1.2 → 3.1.3 |
---|
comment:5 by , 3 years ago
Component: | postgis → documentation |
---|---|
Owner: | changed from | to
This is a duplicate of #4840, actually.
The documentation change suggestion could still be applied, though.