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
OpenHistoricalMap/ohm-deploy#352 exposed every valid name:*=* tag in the vector tiles. However, for performance reasons, we subsequently limited the tiles to only languages tagged on 50 or more elements: #948. Unfortunately, this excludes a number of indigenous and historical languages that we have relatively little coverage of, including some that are nonetheless quite notable. For example, we had been using Alexandria’s Coptic name to demonstrate the embed site’s language support, but the demo broke with the optimization: #1048. To support a wider range of languages, we need to materialize the name keys.
As I mentioned in #1048 (comment), querying tags using (hstore) tags -> 'name:xx' is expensive for the database, especially considering there are more than 150 languages available.
A potential solution would be to create materialized views that include language-specific columns for the tables in the existing materialized views. This approach would convert the name:* tags into individual columns. According to PostgreSQL documentation, materialized views support up to 1,600 columns, which should be sufficient to accommodate all language variants. This way, vtiles queries would only need to read the necessary columns directly from the materialized views, significantly reducing the cost of accessing hstore fields.
@1ec5 What would be the minimum number of languages we should support in the vtiles? Would 5 be reasonable? I think fewer than 5 might still result in a large number of attributes to handle when evaluating languages.
Five or even 10 would be fantastic. Note that the practical impact of this change for end users will be limited until we support fallback languages on the client side (#1068), since a lot of the remaining languages are related to languages with more coverage.
I’ve been working on a series of improvements to streamline how we manage multilingual data in the tiler setup. The main idea is to dynamically include languages that are actively used in the dataset.
Based on the analysis:
If we include languages present in at least 10 objects, we get 361 languages.
If we lower the threshold to 5 objects, that number increases to 380 languages.
Technically, we could include any language found in at least one object, but limiting the list to the most relevant ones (e.g., top 5 or those used more than 10 times) helps keep things manageable.
Updated Workflow
A function scans the main tables in the tiler database to detect all languages and their usage counts.
The detected languages are stored in a new table called languages, and a hash of the current language list is stored in a table called languages_hash.
We no longer rely on the Taginfo API, which updates only every two weeks and is too slow for detecting new additions.
All downstream processes (e.g., materialized view creation, Tegola configuration generation) now depend on this table.
Inside the Imposm Container
Materialized views will include language-specific columns such as name_en, name_es, etc., based on the entries in the languages table.
Each view will include a column for every detected language, which may result in over 350 columns per view, depending on the number of languages.
Views will be created or updated automatically for every relevant table.
These views will also be refreshed every 5 minutes to keep up with general changes. If a change is detected in the languages_hash table, the view will be regenerated to include new language columns.
Inside the Tiler-Server (Tegola) Container
Before the Tegola server starts, a Python script will read the languages table and generate the configuration file accordingly.
A script will run inside the tiler-server container, check if languages_hash has changed, and update the configuration if necessary. If changes are detected, the container will need to be restarted to apply them.
By relying on materialized views with language-specific columns, we eliminate the need for hstore in query logic, simplifying and optimizing Tegola’s performance.
What happens when a new language is added to the database?
This would trigger a restart of the tiler-server container. However, how frequently do users actually add a new language tag in OHM?, Perhaps this process can be run every 24 hours, but it’s something we can discuss.
Each view will include a column for every detected language, which may result in over 350 columns per view, depending on the number of languages.
Would adding this many columns to a view degrade imposm’s performance, or would the impact be negligible compared to the hstore queries in Tegola?
This would trigger a restart of the tiler-server container. However, how frequently do users actually add a new language tag in OHM?, Perhaps this process can be run every 24 hours, but it’s something we can discuss.
Throttling sounds like a good long-term security measure, especially if unused languages get purged as a part of the process. That said, it could be tail work; I don’t see stuff like edit wars or vandalism around obscure name:*=* keys being an immediate concern.
Would adding this many columns to a view degrade imposm’s performance, or would the impact be negligible compared to the hstore queries in Tegola?
This won’t affect the performance of the Imposm import—it will continue running as it does now. The only impact will be on refreshing more materialized views from the tables, but I think that’s acceptable since we have computing resource.
This PR OpenHistoricalMap/ohm-deploy#544 includes a large number of changes focused on improving the generation of vector tiles (vtiles), incorporating support for multiple languages.
Summary:
Materialized views are created for each layer, incorporating language columns and precomputing values like start_decdate, end_decdate, and others. This results in a much cleaner Tegola config file and faster execution of SELECT statements. e.g .
Workflow:
A languages table has been created along with a postgres function that scans the main tables in the vector tiles database. The function search for language tags that appear in at least five objects in the database—this threshold determines whether a language should be included in the vector tiles.
The regular expression that the function uses to filter la languages is the one provided by Minh: #948 (comment)
Because the views are created for almos al tables, we also take advantage of this step to precompute other values such as start_decdate, end_decdate, and normalize attributes like name and others, ensuring they are not empty. This approach significantly reduces load at runtime when serving tiles, resulting in faster query execution in Tegola.
For cases where table structures are similar, I’ve created a generic function that can be reused flexibly to simplify view creation.
Key Improvements:
Language columns (name_xx): Columns for each supported language are added in the name_xx format, replacing the use of hstore. While this adds many columns, it allows for faster and simpler queries, improving tile rendering performance.
Precomputed temporal fields: Fields like start_date, end_date, start_decdate, and end_decdate are now included directly, avoiding runtime calculation in Tegola.
Column normalization: Fields like name, area_m2, and height are cleaned and standardized using NULLIF() and other logic to ensure consistency and avoid invalid or empty values.
Tegola provider cleanup: The list of configured provider_names in Tegola has been cleaned up, removing unused or redundant layers.
Tegola layer configurations (provider_names) are now mapped directly from the materialized views, which helps prevent errors like missing name_* columns.
A script was created to generate a GeoJSON file from the languages table, to track which regions contain which languages.
Note on admin_lines (land_ohm_lines):
Language columns are not included in admin_lines, since this layer is mainly used for merged geometries using precalculated start_decdate/end_decdate.
However, the land_ohm_centroids layer does include language fields, so multilingual labeling is still visible on admin boundaries.
Excluded Layers
To simplify the system and avoid duplication, the following layers have been excluded from this version (staging):
place_points
transport_associated_streets
transport_points
route_lines
amenity_areas.centroids
amenity_points
buildings.centroids
buildings_points
landuse_areas.centroids
landuse_points
other_areas.centroids
other_points
These layers are either:
• Not currently used in map styles, or
• Already covered by more consolidated views (e.g., *_points_centroids)
@tim — could you confirm if the transition from *_points to *_points_centroids is complete, or should we still include some of these in staging?
How is a new language added to vector tiles (vtiles)?
To make a new language appear in the tiles, just add features in the map - production as usual using name:xx tags.
Once a language has 5 or more features, it is considered valid.
A script runs in the hetzner server every hour that:
1. Scans the vtiles-database for new languages
2. Adds any new valid ones to the languages table
3. Regenerates all materialized views with the new language included
(It takes about 15–20 minutes, excluding land_ohm_lines. No worries — the creation of the materialized views won’t affect the Tegola server, because of the way they’re generated: first, a temporary view is created, and once it’s complete, it is renamed to replace the actual materialized view. which takes few milliseconds).
4. Restarts the vtile-server container so the new configuration is loaded.
(restart takes ~10 seconds)
5. Clean tiler cache
This flow would be even smoother in a Kubernetes environment with rolling updates, but for now, we use Docker. Fortunately, the container restarts quickly and only happens when new languages are detected. If there are no new languages, no restart occurs.
Testing,
Here example of the openhistoricalmap-embed for languages , to show example of languages
Thanks for the detailed writeup! I’m excited to see so many language options, which will be much more accessible after we pull in openstreetmap/openstreetmap-website#5201.
I have created a script that creates a geojson file of the languages table when a tegola server starts.
Out of curiosity, are we currently using this GeoJSON file for anything in the pipeline?
Regenerates all materialized views with the new language included
Does this 15–20-minute process run every hour, or only if we’ve detected a change in the language table?
@tsinn I’ve been comparing the production and staging (now with multi-language support) vector tiles and map styles. Everything looks fine overall, but the only difference I noticed is that some place points sometimes show different names compared to production.
In some cases, names don’t appear until you zoom in further. In other cases, the name differs because there are multiple overlapping place point objects at the same location in place_points_centroids. For some reason, not that one that shows in production show in staging, but actually exist the points in the same location.
My hunch is that the stacking of the labels is different between the separate vector tiles, and since we are not setting dates in the tile-compare site you put together, then it is simply showing the name that is highest in that stack? Would it be possible to add a date filter to your tile-compare site? Or, would it be reasonable for me to compare staging.openhistoricalmap.org to openhistoricalmap.org and set specific dates?
Activity
Rub21 commentedon May 16, 2025
As I mentioned in #1048 (comment), querying tags using (hstore) tags -> 'name:xx' is expensive for the database, especially considering there are more than 150 languages available.
A potential solution would be to create materialized views that include language-specific columns for the tables in the existing materialized views. This approach would convert the name:* tags into individual columns. According to PostgreSQL documentation, materialized views support up to 1,600 columns, which should be sufficient to accommodate all language variants. This way, vtiles queries would only need to read the necessary columns directly from the materialized views, significantly reducing the cost of accessing hstore fields.
Rub21 commentedon May 29, 2025
@1ec5 What would be the minimum number of languages we should support in the vtiles? Would 5 be reasonable? I think fewer than 5 might still result in a large number of attributes to handle when evaluating languages.
1ec5 commentedon May 29, 2025
Five or even 10 would be fantastic. Note that the practical impact of this change for end users will be limited until we support fallback languages on the client side (#1068), since a lot of the remaining languages are related to languages with more coverage.
Rub21 commentedon Jun 3, 2025
I’ve been working on a series of improvements to streamline how we manage multilingual data in the tiler setup. The main idea is to dynamically include languages that are actively used in the dataset.
Based on the analysis:
Updated Workflow
Inside the Imposm Container
Inside the Tiler-Server (Tegola) Container
What happens when a new language is added to the database?
This would trigger a restart of the tiler-server container. However, how frequently do users actually add a new language tag in OHM?, Perhaps this process can be run every 24 hours, but it’s something we can discuss.
1ec5 commentedon Jun 3, 2025
Would adding this many columns to a view degrade imposm’s performance, or would the impact be negligible compared to the hstore queries in Tegola?
Throttling sounds like a good long-term security measure, especially if unused languages get purged as a part of the process. That said, it could be tail work; I don’t see stuff like edit wars or vandalism around obscure
name:*=*keys being an immediate concern.Rub21 commentedon Jun 3, 2025
This won’t affect the performance of the Imposm import—it will continue running as it does now. The only impact will be on refreshing more materialized views from the tables, but I think that’s acceptable since we have computing resource.
Rub21 commentedon Jun 16, 2025
Updates
This PR OpenHistoricalMap/ohm-deploy#544 includes a large number of changes focused on improving the generation of vector tiles (vtiles), incorporating support for multiple languages.
Summary:
Materialized views are created for each layer, incorporating language columns and precomputing values like start_decdate, end_decdate, and others. This results in a much cleaner Tegola config file and faster execution of SELECT statements. e.g .
Workflow:
A languages table has been created along with a postgres function that scans the main tables in the vector tiles database. The function search for language tags that appear in at least five objects in the database—this threshold determines whether a language should be included in the vector tiles.
The regular expression that the function uses to filter la languages is the one provided by Minh: #948 (comment)
^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 languages table is a core component. All materialized views are generated dynamically based on this table. It also includes a bbox column, which stores the bounding box of where the language tags are located, and I have created a script that creates a geojson file of the languages table when a tegola server starts. E.g staging https://s3.us-east-1.amazonaws.com/planet-staging.openhistoricalmap.org/vtiles_languages.geojson
Because the views are created for almos al tables, we also take advantage of this step to precompute other values such as start_decdate, end_decdate, and normalize attributes like name and others, ensuring they are not empty. This approach significantly reduces load at runtime when serving tiles, resulting in faster query execution in Tegola.
Materialized View Functions
Multiple SQL functions have been created https://github.com/OpenHistoricalMap/ohm-deploy/tree/vtiles_languages/images/tiler-imposm/queries/ohm_mviews to generate materialized views for specific layers, all supporting multiple languages. These functions are organized by category—buildings, landuse, admin_boundaries, amenity, etc.
For cases where table structures are similar, I’ve created a generic function that can be reused flexibly to simplify view creation.
Key Improvements:
Language columns (name_xx): Columns for each supported language are added in the name_xx format, replacing the use of hstore. While this adds many columns, it allows for faster and simpler queries, improving tile rendering performance.
Precomputed temporal fields: Fields like start_date, end_date, start_decdate, and end_decdate are now included directly, avoiding runtime calculation in Tegola.
Column normalization: Fields like name, area_m2, and height are cleaned and standardized using NULLIF() and other logic to ensure consistency and avoid invalid or empty values.
Tegola provider cleanup: The list of configured provider_names in Tegola has been cleaned up, removing unused or redundant layers.
Tegola layer configurations (provider_names) are now mapped directly from the materialized views, which helps prevent errors like missing name_* columns.
A script was created to generate a GeoJSON file from the languages table, to track which regions contain which languages.
Note on admin_lines (land_ohm_lines):
Language columns are not included in admin_lines, since this layer is mainly used for merged geometries using precalculated start_decdate/end_decdate.
However, the land_ohm_centroids layer does include language fields, so multilingual labeling is still visible on admin boundaries.
Excluded Layers
To simplify the system and avoid duplication, the following layers have been excluded from this version (staging):
These layers are either:
• Not currently used in map styles, or
• Already covered by more consolidated views (e.g., *_points_centroids)
@tim — could you confirm if the transition from *_points to *_points_centroids is complete, or should we still include some of these in staging?
How is a new language added to vector tiles (vtiles)?
To make a new language appear in the tiles, just add features in the map - production as usual using name:xx tags.
Once a language has 5 or more features, it is considered valid.
A script runs in the hetzner server every hour that:
1. Scans the vtiles-database for new languages
2. Adds any new valid ones to the languages table
3. Regenerates all materialized views with the new language included
(It takes about 15–20 minutes, excluding land_ohm_lines. No worries — the creation of the materialized views won’t affect the Tegola server, because of the way they’re generated: first, a temporary view is created, and once it’s complete, it is renamed to replace the actual materialized view. which takes few milliseconds).
4. Restarts the vtile-server container so the new configuration is loaded.
(restart takes ~10 seconds)
5. Clean tiler cache
This flow would be even smoother in a Kubernetes environment with rolling updates, but for now, we use Docker. Fortunately, the container restarts quickly and only happens when new languages are detected. If there are no new languages, no restart occurs.
Testing,
Here example of the openhistoricalmap-embed for languages , to show example of languages
: https://openhistoricalmap-embed-languages.surge.sh/#map=1.14/31.9/-39.1&layer=O_staging&language=ja
Here also some data that I uploaded to the tiler. https://www.openhistoricalmap.org/changeset/178558
1ec5 commentedon Jun 18, 2025
Thanks for the detailed writeup! I’m excited to see so many language options, which will be much more accessible after we pull in openstreetmap/openstreetmap-website#5201.
Out of curiosity, are we currently using this GeoJSON file for anything in the pipeline?
Does this 15–20-minute process run every hour, or only if we’ve detected a change in the language table?
Rub21 commentedon Jun 18, 2025
We are not using the GeoJSON at any step; it’s just to help visualize where the languages are located.
Yes, only when new languages are detected. If no new languages are found, there’s no need to re-create the materialized views
Rub21 commentedon Jun 18, 2025
@tsinn I’ve been comparing the production and staging (now with multi-language support) vector tiles and map styles. Everything looks fine overall, but the only difference I noticed is that some place points sometimes show different names compared to production.
In some cases, names don’t appear until you zoom in further. In other cases, the name differs because there are multiple overlapping place point objects at the same location in place_points_centroids. For some reason, not that one that shows in production show in staging, but actually exist the points in the same location.
https://tiler-compare.openhistoricalmap.org/vtiles_map_style/index.html#1.72/33.4/7.6

tsinn commentedon Jun 24, 2025
My hunch is that the stacking of the labels is different between the separate vector tiles, and since we are not setting dates in the
tile-comparesite you put together, then it is simply showing the name that is highest in that stack? Would it be possible to add a date filter to yourtile-comparesite? Or, would it be reasonable for me to compare staging.openhistoricalmap.org to openhistoricalmap.org and set specific dates?Rub21 commentedon Jun 25, 2025
nice, I have implement a small site under tiler-compare to compare embed by adding the date Production VS Staging, https://tiler-compare.openhistoricalmap.org/ohm_embed/index.html#2.98/39.6049/-4.2751&date=1500
I’ve been comparing all of them, and they seem fine—except for the airport that we’ve implemented. #1083
https://tiler-compare.openhistoricalmap.org/ohm_embed/index.html#10.86/50.8724/4.5773&date=2025
Rub21 commentedon Jun 26, 2025
I have also created A container called tiler-monitor. This container runs a script that checks for new languages in the database. By default, it only considers languages that have at least 5 objects. If the script detects new languages, it will update the materialized views in the database, restart the tiler-server container, and clear the cache files. Previously, this script was running directly on the node, but I decided to move it into a container to better monitor logs and restart the process in case of failure.
https://github.com/OpenHistoricalMap/ohm-deploy/tree/fef5b2114cd6e6daf233bad75ea92256e50e5dc8/images/tiler-monitor
Rub21 commentedon Jun 26, 2025
This is been completed and merged in production