summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-14 20:01:33 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-14 20:26:09 -0800
commit5bf86f6042215780247b972547f8675ef180e158 (patch)
tree1cb4706caf7b03313aa90334fd5728b2acd40bd6 /parse-xml.c
parenta081fb34e001e321308e75f9eb2edc422ba61f8c (diff)
downloadsubsurface-5bf86f6042215780247b972547f8675ef180e158.tar.gz
Proof of concept for reverse geo location
When reading a pre-v3 XML file, we now do reverse geo lookups on the GPS coordinates and add the country to the dive site notes. Eventually this wants to be a tag (once we implement tags for dive sites). This is going to add quite a bit of delay when people open a V2 XML file - depending on how many distinct GPS fixes they have. In my case with 127 GPS fixes it took about 20 seconds to open the file... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/parse-xml.c b/parse-xml.c
index 4675dad01..ecef235ef 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1162,6 +1162,7 @@ static void gps_location(char *buffer, struct dive_site *ds)
/* this is in qthelper.cpp, so including the .h file is a pain */
extern const char *printGPSCoords(int lat, int lon);
+extern void reverseGeoLookup(degrees_t, degrees_t, uint32_t);
static void gps_in_dive(char *buffer, struct dive *dive)
{
@@ -1179,10 +1180,11 @@ static void gps_in_dive(char *buffer, struct dive *dive)
} else {
fprintf(stderr, "found no uuid in dive, no existing dive site with these coordinates, creating a new divesite without name and above GPS\n");
dive->dive_site_uuid = create_dive_site_with_gps("", latitude, longitude);
+ ds = get_dive_site_by_uuid(dive->dive_site_uuid);
}
} else {
fprintf(stderr, "found uuid in dive, checking to see if we should add GPS\n");
- struct dive_site *ds = get_dive_site_by_uuid(uuid);
+ ds = get_dive_site_by_uuid(uuid);
if (dive_site_has_gps_location(ds) &&
(latitude.udeg != 0 || longitude.udeg != 0) &&
(ds->latitude.udeg != latitude.udeg || ds->longitude.udeg != longitude.udeg)) {
@@ -1198,6 +1200,8 @@ static void gps_in_dive(char *buffer, struct dive *dive)
ds->longitude = longitude;
}
}
+ if (ds && (!ds->notes || strstr(ds->notes, "countrytag:") == NULL))
+ reverseGeoLookup(latitude, longitude, dive->dive_site_uuid);
}
static void add_dive_site(char *buffer, struct dive *dive)