Rendering non-default language in OSM-Carto standard map
OpenStreetMap's standard map rendered in OSMCarto style use only the
name tag, for good reasons but what happens when you want to create raster maps in a language of your choice? How do we use the
India's map is in English but it officially recognizes 22 languages for its culturally and lingually diverse states including English, Tamil, Malayalam etc.
How do I render OSM Standard map in my mother tongue - Tamil?
Apparently it is just an if statement of three lines in the right place.
The only hack AFAIK is to change the
name tag before data is dumped into postgresql, to do that we need to sideload a lua script to osm2pgsql during the dump using the
--tag-transform-script parameters, documentation for it is available here.
The documentation states that the following three methods should be implemented in the tag transformation lua script to filter out specific information from the source .pbf or .osm.xml
These are the three functions
osm2pgsql calls on every tag it adds to the Postgresql database, therefore we would have to implement the same functions in our script.
function filter_tags_node(tags, num_tags) if tags["name:ta"] then tags["name"] = tags["name:ta"] end return 1, tags end
So we are checking if the current node has the tag
name:ta and if it does, we are replacing its
name tag with the Tamil name.
We have to repeat this with the other two functions to change everything into Tamil or language of your choice.
This makes sure that the default name for all data in the rendering database is in Tamil if available.
Making it actually work
This alone isn't enough to render the OSM standard tiles in Tamil. As mentioned in switch2osm we already use openstreetmap-carto's lua script to filter out tags.
osm2pgsql -d gis --create --slim -G --hstore --tag-transform-script ~/src/openstreetmap-carto/openstreetmap-carto.lua -C 2500 --number-processes 1 -S ~/src/openstreetmap-carto/openstreetmap-carto.style ~/data/tamil_nadu-latest.osm.pbf
Therefore, it would be better at add our code to openstreetmap-carto.lua, something like
function filter_tags_node (keyvalues, numberofkeys) if keyvalues["name:ta"] then keyvalues["name"] = keyvalues["name:ta"] end return filter_tags_generic(keyvalues) end
Remember to repeat for all three methods mentioned in the earlier section.
Following the steps on switch2osm was enough to create a rendering setup.
I found state wise .pbf extracts for India on OSM-fr
mod_tile renders new tiles only when it is requested, therefore if you want to prerender all tiles, this can be helpful, though selective rendering has been a hit or miss for me.
More images can be found here https://imgur.com/gallery/MZmiKsP