OpenStreetMap

lonvia's diary

Recent diary entries

Sorting route relations

Posted by lonvia on 10 September 2017 in English (English)

waymarkedtrails.org, the site to show all things route related, has always taken care to try to put route relation members in a sensible order before displaying them. A couple of weeks ago this has changed. The site now assumes that the members of each relation are already in the correct order. The reason for that is simple: sorting route relations is hard.

Before explaining why sorting is hard, let me explain why order even matters. As long as you simply want to display the route on a map, the order is not important. Simply color each way in the relation to your liking and the route is nicely visible for a human reader. However, waymarkedtrails.org does a bit more than that. It displays an elevation profile and allows to download a GPX of the route, so you can put it onto your favourite mobile device. When the route is not sorted in the expected order, then the GPX is unusable for many applications, for example in Garmin Basecamp.

So why not sort the route automatically? On first sight, this seems to be a simple task. After all, a route should be a simple linear connection from A to B. Unfortunately, the real world is much more messy.

Even the most simple case of a linear route from A to B already has two solutions to the problem. The route may go from A to B or from B to A. In most cases the direction doesn't really matter but there are exceptions. Take a downhill mountain bike route, for example, or a nature trail with information panels that should be visited in the correct order.

Then there are loop routes which end at the point where they started. When sorting automatically there is no way to determine the starting point of the route. In both cases, we could add extra tagging to mark the start and end points. But why add the extra work when sorted route give the start and endpoints clearly at the beginning and end of the list?

Also, not all routes in OSM are strictly linear: there are routes with directional deviations. This can often be found in cycling routes which might go through oneway streets. Sometimes these deviations mapped with forward/backward roles but not always. Then there are routes that contain alternatives, side trips to lookout points and alternative access points.

waymarkedtrails could surely use some heuristics to get all these cases right most of the time but then there is no way to fix the decision if it gets it wrong. I think that is much better to leave the final decision about the order to the mapper.

Keeping your routes in the right order isn't too much work either. The JOSM relation editor is a very powerful tool when it comes to sorting relations. In the list of relations there is a column that immediately shows you the connectivity of your relation members. It can even handle directional deviations and roundabouts. Keeping an eye on the connectivity column is always a good idea while clicking your route together. It gives you immediate feedback when you've missed part of the route or created a small dangling end when you forgot to split a road. If you already have mapped your routes without sorting them, there is even a button to sort the members for you.

So, overall sorted routes are an advantage for everybody. They don't solve all problems with routes but they are a huge step forward in improving the quality.

Finally some numbers about the current state.

Hiking routes:

  • 74337 linear routes already sorted (65 %)
  • 14608 linear routes, not sorted (13 %)
  • 24992 non-linear routes (22 %)

Cycling routes:

  • 28020 linear routes already sorted (55 %)
  • 5164 linear routes, not sorted (10 %)
  • 17639 non-linear routes (35 %)

Waymarked Trails goes OpenTopoMap

Posted by lonvia on 7 June 2017 in English (English)

Waymarked Trails is the map for all things route - hiking, cycling, skating and horse riding. It has been a long standing wish of many users to have hillshading and contours on the map. So last week the site has received a new feature that allows you to choose a different base map. The first addition to the available base layers is OpenTopoMap, a beautiful map crafted in spirit of German topological maps. To try it out, go to the settings menu (the little cockwheel on the bottom of the page) and choose the new base map from the drop down menu.

Many thanks to the friendly folks from OpenTopoMap for all their work creating the map and for allowing Waymarked Trails to offer it as a base layer.