mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
156e053050
commit
f59679320a
1 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue