aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2021-08-15 00:09:00 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-08-15 09:31:17 -0700
commit75fdb8676bdc24a232351c207ea4cdd2e9caeb22 (patch)
tree38d8bb26484b7fca2df952845d07693374d9ace1
parent67769235e78e7963a093bcf84e3b27ad1a0b8d6c (diff)
downloadsubsurface-75fdb8676bdc24a232351c207ea4cdd2e9caeb22.tar.gz
core: add downloaded GPS to existing dive site
If we download a first dive computer and add a dive site to the dive (by setting a location name for example), and then download from another dive computer that provides us with GPS data, we should keep the existing dive site information, but add the GPS data from the freshly downloaded dive computer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--CHANGELOG.md1
-rw-r--r--core/dive.c6
2 files changed, 7 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fd08a144a..939dc2ea2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,4 @@
+- add GPS fix downloaded from a dive comuter to existing dive site
- fix broken curser left/right shortcut for showing multiple dive computers
- allow editing the profile for dives imported without samples (via CSV)
- fix potential crash (and other errors) importing DL7 dives
diff --git a/core/dive.c b/core/dive.c
index 571f244df..a7d202ba5 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -2639,6 +2639,12 @@ struct dive *merge_dives(const struct dive *a, const struct dive *b, int offset,
/* we take the first dive site, unless it's empty */
*site = a->dive_site && !dive_site_is_empty(a->dive_site) ? a->dive_site : b->dive_site;
+ if (!dive_site_has_gps_location(*site) && dive_site_has_gps_location(b->dive_site)) {
+ /* we picked the first dive site and that didn't have GPS data, but the new dive has
+ * GPS data (that could be a download from a GPS enabled dive computer).
+ * Keep the dive site, but add the GPS data */
+ (*site)->location = b->dive_site->location;
+ }
fixup_dive(res);
free(cylinders_map_a);
free(cylinders_map_b);