diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-29 18:51:51 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-29 21:40:19 -0700 |
commit | f59679320a5cf42280e2877b7a314fd75116d08a (patch) | |
tree | a43168dd1a176d7ab3d57e8391e2842aa154a572 /core/libdivecomputer.c | |
parent | 156e0530500ff8e21a0ae2245aabbd3057fbe1d6 (diff) | |
download | subsurface-f59679320a5cf42280e2877b7a314fd75116d08a.tar.gz |
parse "GPS" string fields and turn them into dive sites when downloading
Dive computers that do GPS can report their GPS data as one or more
string fields, and if the first tree letters of the description is
"GPS", then we'll take the string and turn it into a dive site for that
dive.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/libdivecomputer.c')
-rw-r--r-- | core/libdivecomputer.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c index 51fc6f8b8..44bf78b80 100644 --- a/core/libdivecomputer.c +++ b/core/libdivecomputer.c @@ -581,6 +581,8 @@ static void set_dc_serial(struct divecomputer *dc, const char *serial) dc->deviceid = calculate_string_hash(serial); } +extern degrees_t parse_degrees(char *buf, char **end); + static void parse_string_field(struct dive *dive, dc_field_string_t *str) { // Our dive ID is the string hash of the "Dive ID" string @@ -598,6 +600,18 @@ static void parse_string_field(struct dive *dive, dc_field_string_t *str) dive->dc.fw_version = strdup(str->value); return; } + /* GPS data? */ + if (!strncmp(str->desc, "GPS", 3)) { + char *line = (char *) str->value; + degrees_t latitude, longitude; + + latitude = parse_degrees(line, &line); + if (*line == ',') line++; + longitude = parse_degrees(line, &line); + + if (latitude.udeg && longitude.udeg) + dive->dive_site_uuid = create_dive_site_with_gps(str->value, latitude, longitude, dive->when); + } } #endif |