summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-14 18:00:35 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-14 18:00:35 -0800
commit57d5a40e95135958c60f376b69e6c48ef4060706 (patch)
tree55ce0f8c236e7d9d00fad0a91c6b83a1c65e9cff /parse-xml.c
parent06bbf9f4c8a0f99a44363d7ebadc978cf0072cfc (diff)
downloadsubsurface-57d5a40e95135958c60f376b69e6c48ef4060706.tar.gz
Keep conflicting information around when converting v2 to v3 on the fly
When reading a v2 XML or git divelog it can happen that we get multiple names for the same GPS fix or multiple GPS fixes for the same name. We'll still consolidate them to one entry, but we should not throw away the conflicting information - instead we should just add this to the notes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/parse-xml.c b/parse-xml.c
index 97d0c090f..4675dad01 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1160,6 +1160,9 @@ static void gps_location(char *buffer, struct dive_site *ds)
ds->longitude = parse_degrees(end, &end);
}
+/* this is in qthelper.cpp, so including the .h file is a pain */
+extern const char *printGPSCoords(int lat, int lon);
+
static void gps_in_dive(char *buffer, struct dive *dive)
{
char *end;
@@ -1187,13 +1190,8 @@ static void gps_in_dive(char *buffer, struct dive *dive)
fprintf(stderr, "dive site uuid in dive, but gps location (%10.6f/%10.6f) different from dive location (%10.6f/%10.6f)\n",
ds->latitude.udeg / 1000000.0, ds->longitude.udeg / 1000000.0,
latitude.udeg / 1000000.0, longitude.udeg / 1000000.0);
- int len = ds->notes ? strlen(ds->notes) : 0;
- len += sizeof("\nalternative coordinates") + 24;
- char *notes = malloc(len);
- snprintf(notes, len, "%s\nalternative coordinates %11.6f/%11.6f",
- ds->notes ?: "", latitude.udeg / 1000000.0, longitude.udeg / 1000000.0);
- free(ds->notes);
- ds->notes = notes;
+ ds->notes = add_to_string(ds->notes, translate("gettextFromC", "multiple gps locations for this dive site; also %s\n"),
+ printGPSCoords(latitude.udeg, longitude.udeg));
} else {
fprintf(stderr, "let's add the gps coordinates to divesite with uuid %8x and name %s\n", ds->uuid, ds->name ?: "(none)");
ds->latitude = latitude;
@@ -1224,8 +1222,9 @@ static void add_dive_site(char *buffer, struct dive *dive)
fprintf(stderr, "so now add name {%s}\n", buffer);
ds->name = copy_string(buffer);
} else if (!same_string(ds->name, buffer)) {
- // coin toss, let's just keep the first name we found
+ // coin toss, let's just keep the first name we found and add the new one to the notes
fprintf(stderr, "which means the dive already links to dive site of different name {%s} / {%s}\n", ds->name, buffer);
+ ds->notes = add_to_string(ds->notes, translate("gettextFromC", "additional name for site: %s\n"), buffer);
} else {
// add the existing dive site to the current dive
fprintf(stderr, "we have an existing location, using {%s}\n", ds->name);