Stories posted under Pinkbike Community blogs are not edited, vetted, or approved by the Pinkbike editorial team. These are stories from Pinkbike users. If a blog post is offensive or violates the Terms of Services, please report the blog to Community moderators.

Announcing The New Trailforks Route Planner

Jun 7, 2021 at 14:37
by Trevor May  
route planner example


We are excited to announce the beta of the Trailforks Route Planner v2. I first created our route planner that allowed automatic A to B routing along trails back in 2015. It was updated along the way to include OSM roads nearby trails, a "selecting" method and last year a freehand drawing option with snapping to trails. But the original auto-routing was aging and needed to be updated to something faster and more flexible. Since we created the trail route planner in 2015 other websites created their own route planners, so I wanted to create the best and most flexible route planner for biking, hiking and other outdoor sports.

Our backend routing system and data pipeline has been totally re-worked using a new tile based routing server called Valhalla. I'll get more into the technical details near the bottom of the article. What this means to the end user is automatic routing is MUCH faster, supports more OSM roads and larger geographic scope. But that is just the start of the changes. I also re-made the front-end interface of the route planner and allow creating a route with a mixture of auto-routing, freehand drawing, uploading a GPX and manually editing GPS points. The old route planner you had to choose and stick to one. The new route planner also allows you to create an entire custom map for your route with POIs, polygons, lines and colored sections. I also generate much better turn-by-turn directions, surface type breakdown, snapping of messy GPS traces to the trails and more!

The Trailforks route planner is unique compared to other route creation tools in that it's not solely based on OSM data and allows you to create a route anywhere on the map quickly.

Here is a quick video demo of some of the new functionality.

Views: 9,412    Faves: 14    Comments: 14



More Feature Details

Different ways to create your route


Create your perfect route with a combination of clicking points to route between them, dragging the last blue routing point to free-hand draw anywhere, or edit the raw GPS points for complete fine control.


preview routing
Hover your mouse over trails and roads to preview what the auto-routing will create visualized by a dashed line.


snap to trails while drawing
While dragging a blue routing point to freehand draw, the line will snap to the nearby trail or road. Power users can use hotkeys to either force snapping to the current trail, or ignore any snapping.


edit route points
Edit, delete and add the raw GPS points for complete control.


add colored route sections
Add colored sections to the route, perfect for showing race stages or sections of a large multi-day hike.


add pois
Add POIs to your route with custom title.


add polygons
Add polygons to the route, with custom color, opacity and title.


add lines
Add other lines to the route, showing optional routes.


directions and surface type
Detailed turn-by-turn directions and surface types are generated for the route.


Isochrone
An isochrone visualizes all the places you could ride within blocks of time or distance from a point.


Hold ALT to ignore auto-routing and draw a straight line between points.
Hold ALT to ignore auto-routing and draw a straight line between points.


Disable auto-routing enforcement of trail direction to route any direction you want.
Disable auto-routing enforcement of trail direction, to route any direction you want.


Views: 415    Faves: 0    Comments: 0

Snap messy GPS tracks (GPX,KML) to the Trailforks map. Option to simplify line.


Views: 191    Faves: 0    Comments: 0

Example of mixing auto-routing and freehand-drawing where a trail is not connected in the routing network.


Views: 347    Faves: 2    Comments: 0

When in selecting mode the trail & road segments that are selectable have a pink glow. The glow increases when you mouse over showing the extend of that segment.

Segments should align in the correct orientation, if the 2 segments are perfectly connected it should know which way to "flip" them. For segments farther away it will flip to use the orientation closest to the end point of the route. But like before there is a flip button to flip the direction of the last selected segment.



Why The Change?

"I liked the old route planner, why did you change it!?" While the new route planner has A LOT of new functionality. The old route planner was often broken in various regions around the world, and the route planner would be a blank map. It also used an old Leaflet map missing many mapping features of the other newer maps on Trailforks. We don't want to maintain the old Leaflet based map or the old routing network system that was prone to break and be outdated. The new system uses the same Mapbox powered map used elsewhere on Trailforks with all the same features. The old planner was very limited because you could not mix or change types of routing, you had to stick to one, which was a very frustrating experience if there was some missing routing data or connection. The new system also includes MUCH more OSM roads that are routable and is a much faster at calculating auto-routing.



Nerd Talk, Tech Details

Routing areas

The old routing backend used pgRouting and was complex and slow to update. The routable areas were small, no larger than half a state, or sometimes only a single riding area. One could not route between them and it was kind of slow. Updating these routing areas was very slow, often taking several hours for a single large routing area. I've scrapped all that and moved to using a tile based routing server called Valhalla. It is MUCH faster at creating the route and allowed me to create a much better backend data pipeline that is faster to update and allows larger routable areas.

Similar to the old pgRouting I first need to turn the Trailforks data into connected "edges". Which means snapping all the trail intersections together and separating trails at intersections into separate tracks. I also need to snap the trails to OpenStreetMap roads we will include in the routing. This process can take a long time, so I've moved some of this to happen each time a trail is added or edited to Trailforks. Trails snap together and snap to OSM roads all the time now, which also makes a cleaner looking map and reduces the work needed for updating the routing data.

The old system had many issues with updating the routing data for an area, when a trail was added or edited, the area would be put in a queue to be updated, but often would take days or would fail and never update, or could break and no routing in that area would work. The new system no longer has a queue and the entire world will be updated at once every 2 days (might increase to daily). So when a new trail is added, it could take up to 2 days before it can be auto-routable, but you can always free-hand draw along it! Additionally if for some reason the routing server is offline, you can still see the trails on the route planner and create a route by free-hand drawing and snapping to the trails.

This world-wide update process involves separating the world into 27 routing areas, much larger than the previous routing areas, which there were many thousands. I do this to reduce the time it takes to generate the routing data and keep memory usage under control. I first make sure all the trails are snapped and segmented into edges for a routing area, then the data is combined with OSM roads and written to .OSM files. Since we are having to update our routing often, we are not including ALL OSM data everywhere, only roads within 10km of a trail are included. If we including ALL OSM roads, it could easily take 24 hours to update and could run into memory bottlenecks. These 27 generated OSM files are then merged into a single PBF file which Valhalla converts into routing tiles. What was particularly tricky was the OSM data needed to have all unique ids in sequential order, so this took a lot of memory to have all the nodes in memory to reference each other and sort. I spent a lot of time trying to speed up this process and have it use less memory. Currently the whole process to update the entire worlds routing takes around 5 hours, takes 242 GB of total memory and creates over 42 million routable edges with 236 million nodes. We have some serious server power behind this to make it fast and offer redundancy.

This page https://www.trailforks.com/routing_status/ lists all the routing areas, their data and the last time they were updated.



Issues

While we try to maintain good trail data quality through our local admins, mods and ambassadors. There are tens of thousands of trails being added and edited each month and some lower quality data slips through, or trails are added that are not connected to other trails and roads. We have automated checks to try forcing the data to "snap" to nearby trails and roads, but sometimes the data is outside the tolerance. We also have checks that flag trail data with quality issues, for admins to cleanup and improve over time. But there can still be missing or broken trail connections in the routing network that breaks the "auto-routing". Over time users and admins will fix and improve the trail data making a better connected routing network. But the big advantage of the new route planner is you can bypass any routing issue but freehand drawing a section of the route, or holding ALT and drawing a straight line over the missing connection.

Admins have debug options to view the routing network data (in pink).
Visualize routing network


The new route planner is still being developed and improved. There are some quirks currently, like not being able to remove auto-routing points after you mix in freehand drawing. This also limits us from allowing editing auto-routing points after being placed, this is something we'd like to improve.

Try out the Trailforks Route Planner.

Author Info:
canadaka avatar

Member since Jun 8, 2010
29 articles

7 Comments
  • 4 0
 Wow! - great job Trevor... the best just keeps getting better and is another reason why going Pro is absolutely worth the small cost to access all these great features - keep up the good work!
  • 2 0
 Nice to see a decent how to video with voice over on how to use the new trail planner system. I have been struggling with the new planner and the video explanation should help.The three videos at the bottom of this email without an voice over are completely useless please redo each one of them . Maybe get some of your local admins or ambassadors to make a few demos on how they use the system. What might be obvious to the developer is a stumbling block for the rest of us mere rookies. Still think there needs to be a free basic limited trail forks version out there to draw people to the platform. Just sayen
  • 1 0
 New users get free unrestricted usage of the app for 7 days of riding. They can also use all features within their free local region. The website is also free. There is also a free old mobile site. So there are lots of options for new users to discover the functionality of Trailforks. Comment about voice overs taken, will do more.
  • 2 0
 I still miss an effective way to delete a bunch of points without having to Click+Delete them one by one!
Is there a faster way?
  • 1 0
 Same question: how do we batch delete points? I'd love to be able to draw a shape then delete all the points in it.

With current functionality I have to rebuild my route from scratch, which takes about 20 minutes Frown
  • 1 0
 I added a batch delete recently to the route planner actually. On the map in the top right is a polygon icon, looks like a square. This lets you draw a polygon shape on the map and all the points within it will be deleted.
  • 1 0
 Very happy with the update. Great work - thank you!







Copyright © 2000 - 2024. Pinkbike.com. All rights reserved.
dv42 0.024049
Mobile Version of Website