summaryrefslogtreecommitdiffstats
path: root/core/divesitehelpers.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-09-06 13:48:52 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-09-06 12:59:54 -0700
commitee2f4664705e139e90b28351f4d76a3e5fbab12d (patch)
treed2c35484cba4578c6d9d34af6f3c87e4a1b69116 /core/divesitehelpers.cpp
parent1f1fd78f785e68d2dad8f9de8e9d313c8e91d485 (diff)
downloadsubsurface-ee2f4664705e139e90b28351f4d76a3e5fbab12d.tar.gz
cleanup: use taxonomy_get_value() instead of taxonomy_get_index()
Instead of getting the index and using that to access values, use the taxonomy_get_value() helper function. Two places are affected: 1) reverse geo-lookup 2) location filter delegate The behavior of reverse geo-lookup is changed slightly: now an empty string is likewise recognized as missing "TC_ADMIN_L3". Before, only a missing category was interpreted as such. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/divesitehelpers.cpp')
-rw-r--r--core/divesitehelpers.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/divesitehelpers.cpp b/core/divesitehelpers.cpp
index cdc4bcdc3..bb4764274 100644
--- a/core/divesitehelpers.cpp
+++ b/core/divesitehelpers.cpp
@@ -114,13 +114,13 @@ taxonomy_data reverseGeoLookup(degrees_t latitude, degrees_t longitude)
taxonomy_set_category(&taxonomy, (taxonomy_category)idx, qPrintable(value), taxonomy_origin::GEOCODED);
}
}
- int l3 = taxonomy_index_for_category(&taxonomy, TC_ADMIN_L3);
- int lt = taxonomy_index_for_category(&taxonomy, TC_LOCALNAME);
- if (l3 == -1 && lt != -1) {
+ const char *l3 = taxonomy_get_value(&taxonomy, TC_ADMIN_L3);
+ const char *lt = taxonomy_get_value(&taxonomy, TC_LOCALNAME);
+ if (empty_string(l3) && !empty_string(lt)) {
// 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
- taxonomy_set_category(&taxonomy, TC_ADMIN_L3, taxonomy.category[lt].value, taxonomy_origin::GEOCOPIED);
+ taxonomy_set_category(&taxonomy, TC_ADMIN_L3, lt, taxonomy_origin::GEOCOPIED);
}
} else {
report_error("geonames.org did not provide reverse lookup information");