diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2017-09-30 18:00:34 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2017-10-01 23:55:37 +0300 |
commit | 7713c7e607b11c0828decdbf35d910280153f880 (patch) | |
tree | 8e08d80032ba7cdcaa344042da7e220f217b75c5 /desktop-widgets/subsurfacewebservices.cpp | |
parent | 325c4459ade70f626d6a39fecfb9e0c27f0c5cee (diff) | |
download | subsurface-7713c7e607b11c0828decdbf35d910280153f880.tar.gz |
Use helper function dive_endtime() where apropriate
Calculating dive.when + dive.duration doesn't always give the correct
endtime of a dive especially when a dive has surface interval(s) in
the middle.
Using the helper function dive_endtime() fixes this issue.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'desktop-widgets/subsurfacewebservices.cpp')
-rw-r--r-- | desktop-widgets/subsurfacewebservices.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/desktop-widgets/subsurfacewebservices.cpp b/desktop-widgets/subsurfacewebservices.cpp index 371a8475a..6c982d27f 100644 --- a/desktop-widgets/subsurfacewebservices.cpp +++ b/desktop-widgets/subsurfacewebservices.cpp @@ -12,6 +12,7 @@ #include "core/subsurface-qt/SettingsObjectWrapper.h" #include <errno.h> #include "core/cloudstorage.h" +#include "core/dive.h" #include <QDir> #include <QHttpMultiPart> @@ -70,7 +71,7 @@ static bool merge_locations_into_dives(void) qDebug() << "processing gpsfix @" << get_dive_date_string(gpsfix->when) << "which is withing six hours of dive from" << get_dive_date_string(dive->when) << "until" << - get_dive_date_string(dive->when + dive->duration.seconds); + get_dive_date_string(dive_endtime(dive)); /* * If position is fixed during dive. This is the good one. * Asign and mark position, and end gps_location loop @@ -106,7 +107,7 @@ static bool merge_locations_into_dives(void) if (verbose) qDebug() << "which is closer to the start of the dive, do continue with that"; continue; - } else if (gpsfix->when > dive->when + dive->duration.seconds) { + } else if (gpsfix->when > dive_endtime(dive)) { if (verbose) qDebug() << "which is even later after the end of the dive, so pick the previous one"; copy_gps_location(gpsfix, dive); @@ -115,7 +116,7 @@ static bool merge_locations_into_dives(void) break; } else { /* ok, gpsfix is before, nextgpsfix is after */ - if (dive->when - gpsfix->when <= nextgpsfix->when - (dive->when + dive->duration.seconds)) { + if (dive->when - gpsfix->when <= nextgpsfix->when - dive_endtime(dive)) { if (verbose) qDebug() << "pick the one before as it's closer to the start"; copy_gps_location(gpsfix, dive); @@ -147,7 +148,7 @@ static bool merge_locations_into_dives(void) /* If position is out of SAME_GROUP range and in the future, mark position for * next dive iteration and end the gps_location loop */ - if (gpsfix->when >= dive->when + dive->duration.seconds + SAME_GROUP) { + if (gpsfix->when >= dive_endtime(dive) + SAME_GROUP) { tracer = j; break; } |