From 9ca600e114cd5f12a17c6a2d39d445f76eb67b0a Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Feb 2015 21:26:43 -0800 Subject: Fix remaining gps references when parsing XML files Clearly I didn't run into these before in my testing. Signed-off-by: Dirk Hohndel --- parse-xml.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'parse-xml.c') 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) -- cgit v1.2.3-70-g09d2