mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-12 12:56:16 +00:00
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>
This commit is contained in:
parent
1f1fd78f78
commit
ee2f466470
2 changed files with 7 additions and 7 deletions
|
@ -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);
|
taxonomy_set_category(&taxonomy, (taxonomy_category)idx, qPrintable(value), taxonomy_origin::GEOCODED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int l3 = taxonomy_index_for_category(&taxonomy, TC_ADMIN_L3);
|
const char *l3 = taxonomy_get_value(&taxonomy, TC_ADMIN_L3);
|
||||||
int lt = taxonomy_index_for_category(&taxonomy, TC_LOCALNAME);
|
const char *lt = taxonomy_get_value(&taxonomy, TC_LOCALNAME);
|
||||||
if (l3 == -1 && lt != -1) {
|
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
|
// 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,
|
// 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
|
// 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 {
|
} else {
|
||||||
report_error("geonames.org did not provide reverse lookup information");
|
report_error("geonames.org did not provide reverse lookup information");
|
||||||
|
|
|
@ -404,12 +404,12 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (prefs.geocoding.category[i] == TC_NONE)
|
if (prefs.geocoding.category[i] == TC_NONE)
|
||||||
continue;
|
continue;
|
||||||
int idx = taxonomy_index_for_category(&ds->taxonomy, prefs.geocoding.category[i]);
|
const char *value = taxonomy_get_value(&ds->taxonomy, prefs.geocoding.category[i]);
|
||||||
if (idx == -1)
|
if (empty_string(value))
|
||||||
continue;
|
continue;
|
||||||
if(!bottomText.isEmpty())
|
if(!bottomText.isEmpty())
|
||||||
bottomText += " / ";
|
bottomText += " / ";
|
||||||
bottomText += QString(ds->taxonomy.category[idx].value);
|
bottomText += QString(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bottomText.isEmpty())
|
if (bottomText.isEmpty())
|
||||||
|
|
Loading…
Add table
Reference in a new issue