mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
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>
This commit is contained in:
parent
a0f88e4c9f
commit
bda482a30a
3 changed files with 21 additions and 3 deletions
|
@ -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 {
|
||||
|
|
|
@ -8,6 +8,7 @@ char *taxonomy_category_names[TC_NR_CATEGORIES] = {
|
|||
QT_TRANSLATE_NOOP("getTextFromC", "Country"),
|
||||
QT_TRANSLATE_NOOP("getTextFromC", "State"),
|
||||
QT_TRANSLATE_NOOP("getTextFromC", "County"),
|
||||
QT_TRANSLATE_NOOP("getTextFromC", "Town"),
|
||||
QT_TRANSLATE_NOOP("getTextFromC", "City")
|
||||
};
|
||||
|
||||
|
@ -18,7 +19,8 @@ char *taxonomy_api_names[TC_NR_CATEGORIES] = {
|
|||
"countryName",
|
||||
"adminName1",
|
||||
"adminName2",
|
||||
"toponymName"
|
||||
"toponymName",
|
||||
"adminName3"
|
||||
};
|
||||
|
||||
struct taxonomy *alloc_taxonomy()
|
||||
|
|
|
@ -12,6 +12,7 @@ enum taxonomy_category {
|
|||
TC_ADMIN_L1,
|
||||
TC_ADMIN_L2,
|
||||
TC_LOCALNAME,
|
||||
TC_ADMIN_L3,
|
||||
TC_NR_CATEGORIES
|
||||
};
|
||||
|
||||
|
@ -21,7 +22,7 @@ extern char *taxonomy_api_names[TC_NR_CATEGORIES];
|
|||
struct taxonomy {
|
||||
int category; /* the category for this tag: ocean, country, admin_l1, admin_l2, localname, etc */
|
||||
const char *value; /* the value returned, parsed, or manually entered for that category */
|
||||
enum { GEOCODED, PARSED, MANUAL } origin;
|
||||
enum { GEOCODED, PARSED, MANUAL, COPIED } origin;
|
||||
};
|
||||
|
||||
/* the data block contains 3 taxonomy structures - unused ones have a tag value of NONE */
|
||||
|
|
Loading…
Add table
Reference in a new issue