OpenStreetMap

Linear barriers

Posted by SomeoneElse on 18 December 2017 in English (English)

I've finally got a reasonable rendering of linear barriers working - like the cattle grid in this picture:

Bardney

That's here in OSM and you can see a zoomable map here.

The key to getting it working was to ensure that the width of lines used at high zooms mostly matched the real width of the feature on the map (see here for cattle grids), except for gates and stiles which are designed to stand out slightly. Walls and fences are slightly different, allowing you to tell them apart.

Location: 53.221, -0.336

Comment from Warin61 on 19 December 2017 at 00:36

The 'real width' would be similar to the 'real width' of the road ... Some are single lane width, some on main roads are two lane... three might be wider ones but I do't recall them.

As the road width is not rendered it does not matter so much.

Comment from imagico on 19 December 2017 at 10:50

The key to getting it working was to ensure that the width of lines used at high zooms mostly matched the real width of the feature on the map

The problem with that is that in Mercator it works reasonably well for a small area map like of Britain but it does not on a global map over a wider range of latitudes. There this kind of thing is much more complicated - see

https://github.com/gravitystorm/openstreetmap-carto/pull/1853

Design wise i am not sure if a crossable barrier like a cattle grid being rendered much stronger than a non-crossable barrier like a fence or hedge is very intuitive. You can certainly get used to it but it still looks kind of strange.

Comment from SomeoneElse on 19 December 2017 at 16:58

@imagico the latitude problem is one I hadn't thought about - as I understand it you're going to get about a factor of 2 between the north of Scotland and the equator. That's a problem for runways, but not so much for hedges (an individual hedge anywhere in the world can vary by more than that anyway).

The "crossable things being stronger than non-crossable things" issue I did think about, but realistically fences are a really common long barrier, and having them dominate the map because they're stronger than gates and stiles would look pretty horrible. The idea of doing it this way was to have a bit that looked "obviously different" in a fence line. See partial map key here.

@warin by "width" I mean perpendicular to the cattle grid way, i.e. parallel to the road (so north-south in the example). The length of the cattle grid way is the "width" of the cattle grid as viewed by a road user, and is as long as it was drawn in OSM.

Comment from imagico on 19 December 2017 at 17:25

Your description of the latitude problem is correct - if you design your styling to appear 4m wide in Scotland (because the typical hedge is 4m wide) it will be rendered 8m wide at the equator.

You might not consider this to be a problem but you will always optimize for a certain latitude and in a way discriminate other latitudes with that by being less optimized there.

I see your point about the visual weight.

Comment from LivingWithDragons on 27 December 2017 at 13:07

Why has the cattle grid been mapped as a way?

The wiki says it should be used on nodes(as it crosses the highway) and not used on ways. https://wiki.openstreetmap.org/wiki/Tag:barrier=cattle%20grid?uselang=en-GB

Width tag could be added to it, or it might be more appropriate to add maxwidth, and routing systems can use this to avoid that route if it's below the allowance (depends on a setting, or the use-case of a specialised router). https://wiki.openstreetmap.org/wiki/Key:maxwidth

Comment from SomeoneElse on 27 December 2017 at 13:29

@LivingWithDragons Personally, I don't tend to map cattle grids (or gates for that matter) as ways, but some people do, so it made sense to me to try and render them.

The wiki has a bit of a dual personality - to "describe how people map" and to "tell people how to map" . I tend to think that the former is what it should be doing more of, but there are certainly people who think it should be for the latter. In this particular case I don't really understand why the wiki thinks that a cattle grid is never a linear feature whereas for example a gate can be. They're often right next to each other and exactly the same width!

Login to leave a comment