diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2014-12-18 16:12:56 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:35:13 +0300 |
commit | 4796f801c854bb443998ca111915a04d635d168b (patch) | |
tree | 4aa0f6853b789a3a4bef2c3c873c0dc84cc7a0a1 /platform/location.hpp | |
parent | 95931bbb85c62b2c1fd8b950a9b922e4b48e1b12 (diff) |
Matching bearing while route matching
Diffstat (limited to 'platform/location.hpp')
-rw-r--r-- | platform/location.hpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/platform/location.hpp b/platform/location.hpp index 978bf8aeab..576c95a3ee 100644 --- a/platform/location.hpp +++ b/platform/location.hpp @@ -5,6 +5,7 @@ #include "../routing/turns.hpp" #include "../std/string.hpp" +#include "../std/cmath.hpp" namespace location @@ -73,6 +74,22 @@ namespace location return lon != 0. && lon < 180. && lon > -180.; } + + // Convert angle (in degrees counterclockwise from X) to bearing ([0, 360) clockwise from the north) + static inline double AngleToBearing(double a) + { + double reverseAng = fmod(-a + 90, 360.); + if (reverseAng < 0) + reverseAng += 360.; + return reverseAng; + } + + // Convert bearing (in degrees clockwise from the north) to angle ([0, 360) counterclockwise from X) + static inline double BearingToAngle(double a) + { + return AngleToBearing(a); + } + class FollowingInfo { public: |