Opened 14 years ago
Closed 14 years ago
#6541 closed defect (fixed)
[patch] bugfix in coordinate heading function
Reported by: | anonymous | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core | Version: | latest |
Keywords: | heading atan2 | Cc: |
Description
This fixes three bugs in LatLon.heading(LatLon other) .
- The case of (d_lon==0) and (d_lat<0) was treated wrong. Instead of yielding pi which would smoothly bridge the neighbouring values, a value of 0 was returned in this special case. The usage of atan2 helps a lot in avoiding such problems.
- The transition from 359° to 1° was not treated properly. Instead of 2° it would have assumed -358° for the horizontal distance which gives an unexpected heading.
- a cosine factor was introduced to the difference of longitudes to account for the convercenge of meridians towards the pole. Please check if this functionality is exactly what calling functions expect!
Attachments (1)
Change History (6)
by , 14 years ago
Attachment: | heading.patch added |
---|
comment:1 by , 14 years ago
Summary: | bugfix in coordinate heading function → [patch] bugfix in coordinate heading function |
---|
follow-up: 3 comment:2 by , 14 years ago
follow-up: 4 comment:3 by , 14 years ago
Replying to bastiK:
Thanks for the link! I understand that the angle with the old LatLon.heading function must have varied a lot, since the longitude values were distorted by a factor of cos(latitude). My proposed version should be a correct linearisation which might yield reasonable results if max(delta_lat, delta_lon) << |90° - |lat| |.
The version from SimplifyAreaAction - although I don't see completely through it - seems to come from proper spherical geometry using great_circle arcs and therefore yielding exact results without any approximation. This is of course superior to my proposed linearised version and therefore LatLon.heading should be replaced by the version from simplifyarea.
I would be happy to see a short comment in the function about which consideration led to the formula.
comment:4 by , 14 years ago
Replying to anonymous:
I would be happy to see a short comment in the function about which consideration led to the formula.
A lot of sin & cos ... looks legit. :)
comment:5 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
In [4206] - change heading formula to something sane.
I remember, we had to introduce http://trac.openstreetmap.org/browser/applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaAction.java#L435 because LatLon.heading was too inaccurate.
In particular: If you have 3 points a, b and c, then heading(b,a) - heading(c,b) should be the angle. With LatLon.heading, this angle varies a lot, when you rotate the 3 points. With SimplifyAreaAction.heading it should be constant when rotating.
Maybe we can just replace LatLon.heading by the version from simplifyarea?