Trailforks Routing Along Roads

May 19, 2016
by Trevor May  
trailforks trail routing along roads

Last year Trailforks added its trail routing feature which was limited to routing along trails in our database. Many routes include connections along city roads between trail networks or along logging roads. Now the Trailforks routing will work along a large number of OpenStreetMap roads along with the Trailforks trails.

We have filtered our raw OSM database that is over 1 terabyte down to a routable road database of 56 GB. Because there are A LOT of roads on the entire planet, I only allow routing along roads nearby riding area trails. The image below illustrates the road network around North Vancouver and the trails in green. Adding roads to the routing greatly increases the complexity of the routing network, going from 338 trails to 338 trails plus 38,934 road segments.

Vancouver area road network amp trails

The next image shows the dynamic 'routing areas' around trail networks where OSM road data is loaded. You can route anywhere within a yellow box, but not between them. Typically mountain bike routes do not go large distances, so there is no reason to calculate routes between Vancouver and New York for example, that would never happen on a mountain bike.

Routing area boxes

When these routing areas are generated the trails are snapped to the roads to make connections and duplicate roads that match existing trails are discarded. This image shows the purple roads connecting to the trails. Each region has a special routing admin page to visually check the connections. (Example:

road network links on trail map

routing along roads
Many race routes or even your weekend ride plan might include sections along city roads, this is now possible.

snap trails to road
When editing trail points, you can now snap to nearby roads.

When a new trail is added or existing trail edited in a region, the routing network for this region is queued to be updated automatically. Your change will not happen instantly for routing, depending on the complexity of the area and number of roads, it can take anywhere from a few seconds to an hour to update.

Server backend re-generating the routing network for an area

Admin log for routing area network generation
Here is our admin log of routing networks being updated on the background server.

This new functionality has only been live on the website for a couple weeks, so many areas might require some manual tweaking of the trail data. To make sure the trails are properly snapping to the roads. But this is easier than ever with the routing admin page and the ability to snap trail points to the roads when editing.

MENTIONS: @trailforks

Author Info:
canadaka avatar

Member since Jun 8, 2010
28 articles