summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2020-09-29 11:36:26 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-09-29 14:35:57 -0700
commita7ca27d0712d1e73893c541aabcaaf68aac7afc7 (patch)
treece1abc15f55527ee4e2296ede6163ef2e43de04f
parenteb22c0205ef52bf2fb7d400fa97cd5cb330608ee (diff)
downloadsubsurface-a7ca27d0712d1e73893c541aabcaaf68aac7afc7.tar.gz
Prefer "GPS1" for divecomputer download dive site resolution
I think we only have one dive computer that supports GPS data right now: the Garmin Descent Mk1. It reports the dive coordinates as "GPS1" and "GPS2" for the entry point and exit point respectively. Often GPS1 is missing, because the dive computer may not have gotten a GPS lock before the diver jumped into the water, so when that happens we'll use GPS2 for the dive site location. But when GPS1 exists, we should prefer that. And that's what we already did in logic in dc_get_gps_location(), but for the initial dive site created at download time, we just picked any divecomputer reported string that started with "GPS". And since GPS2 is reported after GPS1 by the Garmin Descent, it would end up overwriting the entry point that we _should_ have preferred. Add the same kind of "explicitly prefer GPS1" logic to the initial dive download case as we already had elsewhere. Reported-by: @brysconsulting Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--core/libdivecomputer.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c
index a35c0f908..b56daeb81 100644
--- a/core/libdivecomputer.c
+++ b/core/libdivecomputer.c
@@ -607,6 +607,15 @@ static void parse_string_field(device_data_t *devdata, struct dive *dive, dc_fie
char *line = (char *) str->value;
location_t location;
+ /* Do we already have a divesite? */
+ if (dive->dive_site) {
+ /*
+ * "GPS1" always takes precedence, anything else
+ * we'll just pick the first "GPS*" that matches.
+ */
+ if (strcmp(str->desc, "GPS1") != 0)
+ return;
+ }
parse_location(line, &location);
if (location.lat.udeg && location.lon.udeg) {