diff options
author | Jeremie Guichard <djebrest@gmail.com> | 2017-03-23 08:13:49 +0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-03-24 09:39:25 -0700 |
commit | 597539ce39ab1054851f5aa96daa0fff29699e8f (patch) | |
tree | 281045e31b92d9952055c954a45883dcb8e02ca3 /core/gpslocation.cpp | |
parent | d83449f3b56c5dbdfbe0f8e5ae908179ba1d6419 (diff) | |
download | subsurface-597539ce39ab1054851f5aa96daa0fff29699e8f.tar.gz |
Fix double to int truncation in C++ code
Wfloat-conversion enabled for C++ part of the code
Fix warnings raised by the flag using lrint
Original issue reported on the mailing list:
The ascent/descent rates are sometimes not what is expected.
E.g. setting the ascent rate to 10m/min results in an actual
ascent rate of 9m/min.
This is due to truncating the ascent rate preference,
then effectively rounding up the time to reach each stop to 2s intervals.
The result being that setting the ascent rate to 10m/min
results in 20s to ascend 3m (9m/min), when it should be exactly 18s.
Reported-by: John Smith <noseygit@hotmail.com>
Reported-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
Diffstat (limited to 'core/gpslocation.cpp')
-rw-r--r-- | core/gpslocation.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/gpslocation.cpp b/core/gpslocation.cpp index 782d37226..ead072772 100644 --- a/core/gpslocation.cpp +++ b/core/gpslocation.cpp @@ -157,8 +157,8 @@ void GpsLocation::newPosition(QGeoPositionInfo pos) gpsTracker gt; gt.when = pos.timestamp().toTime_t(); gt.when += gettimezoneoffset(gt.when); - gt.latitude.udeg = lrint(pos.coordinate().latitude() * 1000000); - gt.longitude.udeg = lrint(pos.coordinate().longitude() * 1000000); + gt.latitude.udeg = (int)(pos.coordinate().latitude() * 1000000); + gt.longitude.udeg = (int)(pos.coordinate().longitude() * 1000000); addFixToStorage(gt); } } @@ -612,8 +612,8 @@ void GpsLocation::downloadFromServer() struct gpsTracker gt; gt.when = timestamp.toMSecsSinceEpoch() / 1000; - gt.latitude.udeg = latitude.toDouble() * 1000000; - gt.longitude.udeg = longitude.toDouble() * 1000000; + gt.latitude.udeg = (int)(latitude.toDouble() * 1000000); + gt.longitude.udeg = (int)(longitude.toDouble() * 1000000); gt.name = name; // add this GPS fix to the QMap and the settings (remove existing fix at the same timestamp first) if (m_trackers.keys().contains(gt.when)) { |