summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-24 22:38:44 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-24 22:38:44 -0700
commite5f4697f91550d80b1587fe38fcab8f9a27f7950 (patch)
treec5489be92060d0c5f1cd9264111d6db391bc36f6 /dive.c
parente49355dc455fbb750504778bfd77720178842797 (diff)
downloadsubsurface-e5f4697f91550d80b1587fe38fcab8f9a27f7950.tar.gz
Rewrite GPS fix matching code for imports from our webservice
The longer I stared at the existing code the less it made sense. So instead I rewrote it in a way that seems logical to me. And added a boatload of debugging output (which needs to be removed, of course). I tested this against more than a hundred dives and it seemed to always pick the right fix. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/dive.c b/dive.c
index 02c1090d9..aadddfd14 100644
--- a/dive.c
+++ b/dive.c
@@ -2807,6 +2807,11 @@ struct dive *find_dive_including(timestamp_t when)
return NULL;
}
+bool time_during_dive_with_offset(struct dive *dive, timestamp_t when, timestamp_t offset)
+{
+ return dive->when - offset <= when && when <= dive->when + dive->duration.seconds + offset;
+}
+
bool dive_within_time_range(struct dive *dive, timestamp_t when, timestamp_t offset)
{
return when - offset <= dive->when && dive->when + dive->duration.seconds <= when + offset;