[OSM-dev] parameterization of mapnik style-sheets in mod_tile / renderd and multi-lingual maps
kakrueger at gmail.com
Mon Oct 14 16:40:19 UTC 2013
I would like to mention that I have committed a new feature to mod_tile
/ renderd and would appreciate any feedback or comments.
Mod_tile and renderd are now prepared for the possibility to
parameterize the mapnik style-sheet on the fly on a (meta)tile by
For this purpose, the URL schema for tileservers was extended. It now
takes the form:
parameters is an arbitrary string that gets passed on to renderd and can
be used to parameterize the style-sheet for that rendering request.
The first use for this functionality is to make it easy to offer
multi-lingual maps. I.e. to be able to specify (parameterize) the
language in which the names should appear on the map. E.g. one can
specify that English names (name:en) should be used instead of the plain
This is heavily based upon Jochen Topf's work on the multi-lingual
project for wikimedia [1,2], that has shown the feasibility of this
concept. By integrating it into mod_tile / renderd and making it trivial
to enable, it will hopefully see wider adoption and prove useful to a
You can specify an ordering of name tags to be used when trying to
render any labels. E.g. de,en,_ will use name:de if available, otherwise
try name:en and finally use name if neither name:de or name:en is
available. Technically, renderd will take the stylesheet it loads and
replace name in the sql queries with coalesce(tags->'name:de',
tags->'name:en', tags->'name') as name.
Everything should be backwards compatible and one can activate this
feature on a style-by-style basis. If not activated, the old URL schema
continues to be used.
So e.g. a server can support https://my.tile.server/osm/0/0/0.png and
To make this possible, the protocol between mod_tile and renderd was
extended to include the parameterization string (as well as pass through
mime information for future purposes, e.g. to be able to render both png
and jpg). However, again, everything (both mod_tile and renderd) should
be backwards compatible. I.e. renderd can receive rendering requests
with the previous version of the protocol, in case you only want to
update renderd and still have an older version of mod_tile (or indeed
another server software or utility for issuing render requests).
Likewise, mod_tile can still send the requests in the previous protocol,
and indeed will do so by default unless the parameterization feature is
explicitly activated for the given style. This should ensure
compatibility with tirex, that has not yet been updated to the change in
Although its first use is for the multi-lingual maps, hopefully this
feature can be used for other purposes as well. You still need to write
code to interpret the parameterization string and apply the
transformation to the mapnik stylesheet object, but given that is all
encapsulated in a separate file, this will hopefully be relatively easy
if one needs it.
More information about the dev