You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Optimize vector tiles by selecting the most common languages #948
Currently, vector tiles are configured to display all the languages listed in the languages.sql file, which includes approximately 411 languages. During a tile request, the SELECT query, adds these language parameters to search the hstore column in the database tables.
While this setup works, but querying such a large number of languages can sometimes slow down the tiler . I propose selecting only the most commonly used languages from the database to include in the vector tiles.
To achieve this, we can analyze data from Taginfo to identify the most frequently used languages or, at the very least, obtain recommendations for the most relevant languages.
Until we finish exposing localized labels to end users (#481), mappers have little incentive to add localized names, so we can’t place too much stock in usage figures yet. Roughly speaking, the top 100 name:*=* keys are heavily skewed toward European languages that have official language status.
name:alq (Algonquin) was implemented in #679 (comment) because it’s documented on the wiki. Someone went through a long time ago documenting all the valid language codes that were being used in OSM, no matter how rare. Taginfo shows that OHM has a somewhat different language coverage distribution. Essentially, our focus on history means we have more coverage of classical and extinct languages than OSM, and we should expect to have more indigenous language coverage as time goes on. We want to support indigenous languages especially because of their rarity as minority languages.
I think it would be OK to prune unused keys as a temporary performance optimization. However, long-term, we’ll need to figure out a more scalable solution for processing these language keys.
I wrote a small script to filter languages that exist in TagInfo. From the entire list in the file languages.sql, which contains 411 languages, I found 93 languages with names. However, I don’t think this is the best approach because I discovered other languages in TagInfo with a large number of objects that are not reflected in our current list. For example:
So, I think the best approach is to list the languages from TagInfo to display the names in the vtiles. However, in some cases, the keys are a bit messy (with messy i men that names include dates, sone random string in some cases).e.g 👇 , but i think those can be filtered.
name:zh_pinyin=* was deprecated several years ago in favor of name:zh-Latn-CN-pinyin=*, per the ISO standard. OSM has performed this cleanup but OHM hasn’t yet. iD only supports the standard code, not the deprecated one.
OSM has performed this cleanup but OHM hasn’t yet.
With cleaning , Do you mean change all the objects that has name:zh_pinyin=* to name:zh-Latn-CN-pinyin=*` , cleaning that should posible and easy. do you think that should be done by the team or someone from the community?
cleaning that should posible and easy. do you think that should be done by the team or someone from the community?
Doesn’t matter, feel free to make the change, or one of us can post in the forum to ask for help.
a regex for selecting valid language labels, and we can use that to select valid name keys
The regular expression implemented in Planetiler should be valid in PostgresQL, though it might need some modifications if you put it in a shell script, depending on the tool you use. Note that this regular expression is case-sensitive.
@1ec5 The Regex "^name:[a-z]{2,3}(-[A-Z][a-z]{3})?([-_](x-)?[a-z]{2,})?(-([A-Z]{2}|\\d{3}))?$" works very well, I was eable to filter the followinf number of languages:
431 languages were filtered for the vector-tiler, each having at least 1 object (node, way, or relation).
264 languages were filtered for the vector-tiler, each having at least 5 object (node, way, or relation).
214 languages were filtered for the vector-tiler, each having at least 10 object (node, way, or relation).
120 languages were filtered for the vector-tiler, each having at least 50 object (node, way, or relation).
94 languages were filtered for the vector-tiler, each having at least 100 object (node, way, or relation).
I think we can consider the 120 languages where the minimum number of objects required to appear is more than 50. Even 10 might work, but 1 seems too detailed.
For now, a threshold of 50 may be necessary, but I think we would indeed want to eventually support languages with fewer features, if only because some regionally significant indigenous languages don’t have many features in the native name. I’d also expect ancient languages such as Sumerian and Phoenician to be represented by very few but very significant features. However, we can defer that consideration until we find an alternative solution that doesn’t incur a performance penalty per language. Once we implement bilingual labeling in #799, this will become somewhat less of an issue, because we’d once again expose many of these names via name=* anyways.
Yes, that looks fine to me. Besides, these are all codes for romanizations and transliterations, which are more appropriate for geocoding than for rendering.
According to this the languages is requesting from taginfo , we may need to run updates in the tiler query every month to retrieve the languages. Since we are currently evaluating the number of objects that have a name:* tag, we might also need to implement a mechanism to automatically request new languages. For now, I am going to close this ticket.
Activity
danrademacher commentedon Jan 9, 2025
Certainly we should eliminate any language for which there are 0 objects. Is there a quick way to at least test for that?
1ec5 commentedon Jan 12, 2025
Until we finish exposing localized labels to end users (#481), mappers have little incentive to add localized names, so we can’t place too much stock in usage figures yet. Roughly speaking, the top 100
name:*=*keys are heavily skewed toward European languages that have official language status.name:alq(Algonquin) was implemented in #679 (comment) because it’s documented on the wiki. Someone went through a long time ago documenting all the valid language codes that were being used in OSM, no matter how rare. Taginfo shows that OHM has a somewhat different language coverage distribution. Essentially, our focus on history means we have more coverage of classical and extinct languages than OSM, and we should expect to have more indigenous language coverage as time goes on. We want to support indigenous languages especially because of their rarity as minority languages.I think it would be OK to prune unused keys as a temporary performance optimization. However, long-term, we’ll need to figure out a more scalable solution for processing these language keys.
Rub21 commentedon Jan 13, 2025
I wrote a small script to filter languages that exist in TagInfo. From the entire list in the file languages.sql, which contains 411 languages, I found 93 languages with names. However, I don’t think this is the best approach because I discovered other languages in TagInfo with a large number of objects that are not reflected in our current list. For example:
name:zh_pinyinhave 5220 objects: https://taginfo.openhistoricalmap.org/keys/name%3Azh_pinyin#overview, This language is not currently included in the list of languages we have in the vtiles, but it seems it needs to be added because of the large number of objects.So, I think the best approach is to list the languages from TagInfo to display the names in the vtiles. However, in some cases, the keys are a bit messy (with messy i men that names include dates, sone random string in some cases).e.g 👇 , but i think those can be filtered.
1ec5 commentedon Jan 13, 2025
name:zh_pinyin=*was deprecated several years ago in favor ofname:zh-Latn-CN-pinyin=*, per the ISO standard. OSM has performed this cleanup but OHM hasn’t yet. iD only supports the standard code, not the deprecated one.Rub21 commentedon Jan 14, 2025
With cleaning , Do you mean change all the objects that has
name:zh_pinyin=* toname:zh-Latn-CN-pinyin=*` , cleaning that should posible and easy. do you think that should be done by the team or someone from the community?danrademacher commentedon Jan 14, 2025
@1ec5 to provide a regex for selecting valid language labels, and we can use that to select valid name keys.
But what about the long tail of languages that happen once in the whole world.
1ec5 commentedon Jan 14, 2025
Doesn’t matter, feel free to make the change, or one of us can post in the forum to ask for help.
The regular expression implemented in Planetiler should be valid in PostgresQL, though it might need some modifications if you put it in a shell script, depending on the tool you use. Note that this regular expression is case-sensitive.
/ref onthegomap/planetiler#147 onthegomap/planetiler#1115 onthegomap/planetiler#1117
Rub21 commentedon Jan 15, 2025
@1ec5 The Regex
"^name:[a-z]{2,3}(-[A-Z][a-z]{3})?([-_](x-)?[a-z]{2,})?(-([A-Z]{2}|\\d{3}))?$"works very well, I was eable to filter the followinf number of languages:I think we can consider the 120 languages where the minimum number of objects required to appear is more than 50. Even 10 might work, but 1 seems too detailed.
1ec5 commentedon Jan 15, 2025
For now, a threshold of 50 may be necessary, but I think we would indeed want to eventually support languages with fewer features, if only because some regionally significant indigenous languages don’t have many features in the native name. I’d also expect ancient languages such as Sumerian and Phoenician to be represented by very few but very significant features. However, we can defer that consideration until we find an alternative solution that doesn’t incur a performance penalty per language. Once we implement bilingual labeling in #799, this will become somewhat less of an issue, because we’d once again expose many of these names via
name=*anyways.Rub21 commentedon Jan 15, 2025
Nice, I have filtered with a threshold of 50 objects min to consider to display the language in the vtiles.
1ec5 commentedon Jan 15, 2025
Did you apply the regular expression above? I still see the deprecated keys
name:zh_pinyin,name:ja_rm, andname:ja_kanain https://github.com/OpenHistoricalMap/ohm-deploy/blob/5f04f959ce57be98f6075c9ca0e7f7b06dc426b0/images/tiler-server/config/languages.sql#L11.Edit: Oh, I see that’s technically allowed due to the
_in the regular expression. That was probably overlooked in Planetiler.Rub21 commentedon Jan 16, 2025
If the issue is with the underscore in names, since those are not considered valid, we can update the regex to something like:
^name:[a-z]{2,3}(-[A-Z][a-z]{3})?((-[a-z]{2,}|x-[a-z]{2,})(-[a-z]{2,})?)?(-([A-Z]{2}|\d{3}))?$the result looks like 👉 https://gist.github.com/Rub21/6b955c7cc67e8aedbb11ab01e5a609d71ec5 commentedon Jan 16, 2025
Yes, that looks fine to me. Besides, these are all codes for romanizations and transliterations, which are more appropriate for geocoding than for rendering.
Rub21 commentedon Jan 23, 2025
According to this the languages is requesting from taginfo , we may need to run updates in the tiler query every month to retrieve the languages. Since we are currently evaluating the number of objects that have a name:* tag, we might also need to implement a mechanism to automatically request new languages. For now, I am going to close this ticket.
Rub21 commentedon Apr 23, 2025
Currently, the fetcher for languages from Taginfo is running inside the tiler-server container. It executes every time before the Tegola server starts and pushes a file with the current languages used in vector tiles to the S3 Planet bucket: https://s3.amazonaws.com/planet.openhistoricalmap.org/vtiles_languages.json. This way, we can publicly access the current languages that we are considering in the vtiles.