summaryrefslogtreecommitdiffstats
path: root/divesitehelpers.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-10 09:51:50 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-10 09:51:50 -0700
commitbda482a30a7ee526cb381bb3583f87fe86b7845f (patch)
tree985b9adfa376f605e0bb03421c83107414733763 /divesitehelpers.cpp
parenta0f88e4c9fe5a7881dffb15d8ec4878a81d563b1 (diff)
downloadsubsurface-bda482a30a7ee526cb381bb3583f87fe86b7845f.tar.gz
Geo taxonomy: add higher level notion of city
This renames the local name for the location as town and adds the concept of a city as the level 3 admin category. In some regions (e.g. at times in Italy) the local hamlet name is shown as toponymName but the name of the actual city is given as adminName3. With this change "city" will always reflect our best guess: adminName3 if it exists, otherwise the toponymName. Whereas "town" is always the toponymName. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divesitehelpers.cpp')
-rw-r--r--divesitehelpers.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/divesitehelpers.cpp b/divesitehelpers.cpp
index 1f323a537..775951855 100644
--- a/divesitehelpers.cpp
+++ b/divesitehelpers.cpp
@@ -85,7 +85,7 @@ void ReverseGeoLookupThread::run() {
QVariantList geoNames = geoNamesObject.toList();
if (geoNames.count() > 0) {
QVariantMap firstData = geoNames.at(0).toMap();
- int ri = 0;
+ int ri = 0, l3 = -1, lt = -1;
if (ds->taxonomy.category == NULL)
ds->taxonomy.category = alloc_taxonomy();
// get all the data - OCEAN is special, so start at COUNTRY
@@ -98,6 +98,21 @@ void ReverseGeoLookupThread::run() {
ri++;
}
}
+ for (int j = ri - 1; j >= 0; j--) {
+ if (ds->taxonomy.category[j].category == TC_ADMIN_L3)
+ l3 = j;
+ else if (ds->taxonomy.category[j].category == TC_LOCALNAME)
+ lt = j;
+ }
+ if (l3 == -1 && lt != -1) {
+ // basically this means we did get a local name (what we call town), but just like most places
+ // we didn't get an adminName_3 - which in some regions is the actual city that town belongs to,
+ // then we copy the town into the city
+ ds->taxonomy.category[ri].value = copy_string(ds->taxonomy.category[lt].value);
+ ds->taxonomy.category[ri].origin = taxonomy::COPIED;
+ ds->taxonomy.category[ri].category = TC_ADMIN_L3;
+ ri++;
+ }
ds->taxonomy.nr = ri;
mark_divelist_changed(true);
} else {