summaryrefslogtreecommitdiff
path: root/src/positioning
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@theqtcompany.com>2016-04-08 10:41:23 +0200
committerPaolo Angelelli <paolo.angelelli@theqtcompany.com>2016-04-11 13:36:46 +0000
commit4528d53b7429e48c51988002bf35e3615a152cb5 (patch)
treea0365c4b2be0c0fc71e54374e6183ccd55c9df16 /src/positioning
parent46bef1bf9b00727832cad35440c554f26e7457b9 (diff)
downloadqtlocation-4528d53b7429e48c51988002bf35e3615a152cb5.tar.gz
Fix for negative QGeoCoordinate.azimuthTo results in range ]360, 359[
QGeoCoordinate.azimuthTo() currently returns negative value (between 0 and -1) for azimuths that should instead be in the range between 360 and 359. This patch should bring all returned values in the range [0, 360[ (360 excluded). Change-Id: I0b5ee7c3fc2bbeb80ca8167a53c7c16d9e067e29 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/positioning')
-rw-r--r--src/positioning/qgeocoordinate.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/positioning/qgeocoordinate.cpp b/src/positioning/qgeocoordinate.cpp
index f28e1865..0386e859 100644
--- a/src/positioning/qgeocoordinate.cpp
+++ b/src/positioning/qgeocoordinate.cpp
@@ -469,8 +469,9 @@ qreal QGeoCoordinate::azimuthTo(const QGeoCoordinate &other) const
double y = sin(dlon) * cos(lat2Rad);
double x = cos(lat1Rad) * sin(lat2Rad) - sin(lat1Rad) * cos(lat2Rad) * cos(dlon);
+ double azimuth = qgeocoordinate_radToDeg(atan2(y, x)) + 360.0;
double whole;
- double fraction = modf(qgeocoordinate_radToDeg(atan2(y, x)), &whole);
+ double fraction = modf(azimuth, &whole);
return qreal((int(whole + 360) % 360) + fraction);
}