summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-12 21:26:43 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-12 21:30:57 -0800
commit9ca600e114cd5f12a17c6a2d39d445f76eb67b0a (patch)
treed123ae7d369b82e22a9ecb5d9dd4d616da899bed /parse-xml.c
parentc109b98f198eb3ea98190d720dfd3fc26c571b69 (diff)
downloadsubsurface-9ca600e114cd5f12a17c6a2d39d445f76eb67b0a.tar.gz
Fix remaining gps references when parsing XML files
Clearly I didn't run into these before in my testing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/parse-xml.c b/parse-xml.c
index 54e74b953..c93d25453 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1127,15 +1127,30 @@ degrees_t parse_degrees(char *buf, char **end)
static void gps_lat(char *buffer, struct dive *dive)
{
char *end;
-
- dive->latitude = parse_degrees(buffer, &end);
+ degrees_t latitude = parse_degrees(buffer, &end);
+ struct dive_site *ds = get_dive_site_for_dive(dive);
+ if (!ds) {
+ dive->dive_site_uuid = create_dive_site_with_gps(NULL, latitude, (degrees_t){0});
+ } else {
+ if (ds->latitude.udeg && ds->latitude.udeg != latitude.udeg)
+ fprintf(stderr, "Oops, changing the latitude of existing dive site id %8x name %s; not good\n", ds->uuid, ds->name ?: "(unknown)");
+ ds->latitude = latitude;
+ }
}
static void gps_long(char *buffer, struct dive *dive)
{
char *end;
+ degrees_t longitude = parse_degrees(buffer, &end);
+ struct dive_site *ds = get_dive_site_for_dive(dive);
+ if (!ds) {
+ dive->dive_site_uuid = create_dive_site_with_gps(NULL, (degrees_t){0}, longitude);
+ } else {
+ if (ds->longitude.udeg && ds->longitude.udeg != longitude.udeg)
+ fprintf(stderr, "Oops, changing the longitude of existing dive site id %8x name %s; not good\n", ds->uuid, ds->name ?: "(unknown)");
+ ds->longitude = longitude;
+ }
- dive->longitude = parse_degrees(buffer, &end);
}
static void gps_location(char *buffer, struct dive_site *ds)