Render forward/backward highway attributes with Mapnik

I have created map tiles for an overlay that highlights cycling restrictions, such as bicycle=no, bicycle=use_sidepath, motorroad=yes and so on in different colours.

In my region, it is quite common for cycling to be forbidden only in one direction of a road. This is commonly mapped as bicycle:forward=* and bicycle:backward=*. I am thinking of a way to display this on my map tiles.

My thought is that if the forward and backward restrictions differ, I would render the road as two lines, where one side would be coloured to represent the forward restrictions and the other to represent the backward restrictions. I have a vague idea how to achieve this with CartoCSS: Using attachments or instances, I can render the feature as two lines instead of one, and using line-offset, I can move one of those lines to the left and the other to the right.

The big challenge that I don’t know how to solve is the driving side. The side of the road where you would actually cycle should represent the restrictions in that direction, so the handling of the forward/backward attributes would be flipped depending on whether the road uses left-hand or right-hand traffic. I imagine I would have to determine the driving side in the osm2pgsql flex output Lua script and store it for each way.

It seems like the driving side is stored as the driving_side tag on the country/region boundary relation where it applies. Only in exceptional cases where the driving side differs from the one used in the region is this tag applied to a way itself. So what approaches are there to determine the driving side when processing a way in osm2pgsql?

Are there alternative approaches how directional attributes can be rendered?

For example arrows. OpenStreetMap

This is interesting. Could you explain what the arrows mean in this example image? It seems like the streets have a teal background, and some streets have grey arrows in one direction, while other streets have grey arrows in one direction as well as blue arrows in the other direction. What exactly does all of this mean?

There is some explanation about the CyclOSM style here on the wiki, e.g. “A grey arrow for a one way street and a blue arrow in the other direction if bicycles can go counterflow.”:

Also a Legend on CyclOSM’s own site
https://www.cyclosm.org/#map=15/53.3486/-6.2695/cyclosm

1 Like