[JT] Jochen Topf's Blog
Sun 2012-07-01 16:30

Separating Styles for On-Demand-Labels

If we want to render multilingual maps by separating the “label layers” from the “base layers” as described in my last blog post, we have to make sure the rendering results don’t change. Or, at least, that they do not look too bad. Lets look into that.

The MapQuest style renders all sorts of things. The last layers that get rendered are (in that order) ‘text’ (various labels on places, parks, etc.), ‘streetnames’ (street names and highway shields), and ‘addressing’ (house numbers and interpolation lines). I moved the ‘text’ and ‘streetnames’ layers into their own style. The result looks almost the same, but sometimes where a house is labeled (for instance with the name of a restaurant in that house), you can see parts of the house number peeking through where they would normally not appear. I do not want to render the ‘addressing’ together with the other texts on demand, because it is rather slow. There are 15 Million house numbers in the OSM database, a third of them on ways, and I don’t want to burden the on-demand-style with them. But the result isn’t too problematic. I tried improving that by not rendering house numbers when the house has a name, too. This works in some cases, but not in others, for instance when long labels overlap neighboring houses.

I have tried this with the ‘master’ branch of the MapQuest style, but the ‘updates2’ branch seems to be newer. It contains another layer ‘arrows’ (with oneway arrows) rendered after the ‘text’ and ‘streetnames’ layers. This makes sense, because we don’t want street names overlapping oneway arrows. This is a similiar case to the one above, ie. we can probably live with suboptimal rendering in this case.

Now lets look at the standard OSM style. The situation here is similar: After the text layers there is only the addressing layer, one for national park boundaries and one for theme parks. The latter two seem to be in the wrong place here, somebody probably just added them to the end, because they didn’t know where else to put them. So we’ll ignore those.

So far this doesn’t look too bad, but there is a catch: The MapQuest style has almost no icons for amenities and such things. Restaurants, pubs, schools, cinemas etc. are only rendered with their name, there is no associated icon. Thats fine as it goes, but many maps want these kind of icons, including the standard OSM map.

But the way icons are rendered in the standard map is not perfect. Icons are rendered first in one layer and then much later the labels are rendered in a different layer. If the labels don’t fit, the icons are still there, just without the labels. The opposite can happen, too, a label without the icon. Thats why it is probably better to render icons and labels in one go. The ShieldSymbolizer can be used for that. But if the style is changed to do this, all these layers would have to be rendered on-the-fly to get the label in the language we want.

Basically it comes down to this: If we want beautiful maps, we will have to render more in the overlay layer, which makes rendering the overlay slower. At some point it is going to be too slow to allow rendering on-the-fly. It depends on the style whether this is a problem.

Comments can be directed to the Multilingual maps wiki page.

Tags: multilingual maps · openstreetmap · rendering