Imagico.de

blog

Improved road ant tunnel rendering by taking connectivity context into account
Improved road ant tunnel rendering by taking connectivity context into account

Crossing the bridge as we get to it

| 0 comments

In the previous post i mentioned casually that the drawing of roads with round line caps at inner junctions of the road network works also with layered display of roads, i.e. with bridges and tunnels. While that is true in principle, there are a number of limitations, which can be bothering in practical map design.

First i want to re-capitulate how layered road rendering with the traditional round line cap connections works.

The traditional method of displaying layered road networks (link goes to double resolution version)

The traditional method of displaying layered road networks (link goes to double resolution version)

The layered road rendering in OSM-Carto and other OpenStreetMap data based maps works just like the normal road layering by drawing all the road lines individually and without taking their geometric context (i.e. how they connect to other road elements) into account. There are two thing which are key to this working:

  • The tunnels are rendered before the normal roads and the bridges are rendered after them.
  • The bridge casing (in black) is rendered with flat line caps while the colored fill is rendered with round line caps. For tunnels likewise – though for those the flat line caps of the casing are not essential, they are mostly chosen so the dashing of the casing works (since in Mapnik the line caps of the dashing cannot be selected independently from the line caps of the line as a whole).

As you can see in the illustration, these drawing principles lead to the well known appearance in OpenStreetMap based maps – and, as said, all without any context dependent styling.

The bridge/tunnel problem

But you can already see from the interrupted center-line on the secondary road (which indicates a two-lane road) that things are not quite that perfect. Problems occur with this design approach in particular in two situations:

  • When there are tram lines on the road (or – in case of the AC-Style – a center-line is drawn for lane visualization or exceptions from implicit access restrictions).
  • When two bridge features (lines or, in case of the AC-Style, also polygons) connect at an angle.

These situations are shown in the following example (where the non-bridge road segments are tagged as unpaved to better show what is going on):

Test setup for problem cases with bridges/tunnels connecting at an angle and tram lines on roads with bridges or tunnels.

Test setup for problem cases with bridges/tunnels connecting at an angle and tram lines on roads with bridges or tunnels.

The cause of the first problem is the round line caps of the bridge fill. The tram lines are rendered above roads of the same layer (since they have a higher z_order value than the road classes). But, of course, a bridge road is drawn above a non-bridge tram line since, otherwise, you could not have tram lines under road bridges. So, the round line caps of the bridge road cover the tram line on the road connecting to the bridge – leading to a discontinuous display of the tram line. This problem has been known for a long time.

The cause of the second problem is the use of flat line ends on the bridge casing – leading to gaps whenever bridge roads connect at an angle.

For tunnels the situation is similar, the main difference here is that the second problem is less noticeable because the casing is dashed anyway, so gaps are less noticeable.

Different approaches in terms of drawing procedure can be followed to address these problems. But no method that does not take into account the geometric context and makes the drawing dependent on road connectivity – similar to what i do for the flat road ends discussed in the previous post – is going to address this fully.

Solutions

The method i devised for the AC-Style consists of three components:

  1. modified fill line caps for the bridge fill
  2. rendering surface roads connecting to tunnels like open ends – with a flat line cap
  3. rendering additional end point casings and fills for junctions between bridge road features of the same layer. These are rendered before the corresponding bridge lines (for casing and fill respectively) and ensure connectivity, which would otherwise, as a result of the first point, be worse than with the standard OSM-Carto rendering procedure.

The second and third point are probably quite clear in connection with the following examples. The first requires some more explanation. You might ask: Why not use a flat line cap on the fill? That would work, except it would cause a thin line across the road at the ends of bridges because the casing and fill end at exactly the same location so the AGG based rendering will always mix in a fraction of the casing color on pixels partly covered by the bridge. You need at least one pixel of overhang of the fill over the casing. So essentially you need a line end in between a flat and a round line cap. This is produced in PostGIS using two subsequent ST_Buffer() operations. There is a small residual gap in the tram line of about a pixel in size as a result of this approach, which can, however, further be mitigated by rendering the tram line with round line caps – which should be done anyway.

I have decided to not also implement the third point for tunnels because it would only affect the casing, where it is – as mentioned – less severe since it is dashed. And the dashing pattern would not be synchronized with the lines anyway.

What also remains unchanged is connections between bridges of different layers – like seen on the very left in the following picture. These are subject to the existing constraint as before (discussed more in depth here) – the two lines need to be co-linear where they meet for this to be rendered correctly.

The improved rendering of bridges and tunnels with the discussed change.

The improved rendering of bridges and tunnels with the discussed change.


Comparison for road bridges – double resolution: old, new


Comparison for road tunnels – double resolution: old, new


Comparison for other highway types – double resolution: old, new

Conclusion

I showed here a number of relatively subtle limitations of the common way of drawing layered road networks in rule based digital maps and how these can be solved by taking the geometric context and the connectivity between individual road features into account. Methods used for doing that are:

  • Custom line cap styles produced with PostGIS using two subsequent ST_Buffer() operations.
  • Use connectivity dependent line caps (as introduced in the previous post) also for tunnel entrances.
  • Classifying bridge roads by connectivity and using that to draw dedicated junction elements for connections between bridge segments as backdrop to the road lines.

You can find all these changes in my experimental map style.

Practical application of the changes discussed here in Freiburg, Germany

Practical application of the changes discussed here in Freiburg, Germany

Leave a Reply

Required fields are marked *.



By submitting your comment you agree to the privacy policy and agree to the information you provide (except for the email address) to be published on this blog.