Show HN: Trail Router – generate running routes that prefer greenery and nature
trailrouter.com
trailrouter.com
I've written a detailed blog post about how Trail Router works here: https://trailrouter.com/blog/how-trail-router-works/
I developed this because I am (or was...) a frequent traveller for work, and I like to run wherever I visit. But I don't enjoy running on busy main roads, and I found that without careful and time consuming route planning that is often what would end up happening if I didn't know the area. Trail Router is my solution to this problem.
After a previous discussion (https://news.ycombinator.com/item?id=23177351) received quite a lot of attention, dang reached out to suggest I post a Show HN to reach a wider audience. I've addressed some of the original feedback too - for example, you can now prefer hills in your routes, as well as avoid them.
This is awesome!
EDIT: In addition to optimizing for green routes, optimizing for low speed car zones would be a killer feature.
The routing algorithm does already prefer roads with low speed limits, but there is definitely more that could be done in this space (e.g. a slider to set a preference to avoid higher speed roads). It also depends on the availability of speed limit data (I use the OpenStreetMap database).
Thus, a lot of route creation is dependent on hyperlocal knowledge. Strava Route Builder, with the heatmap, goes fairly far on this, but it too isn't the best.
This is a really hard problem to solve.
I tested it with your app and the route is near identical to what I've figured (over the course of several thousand km's of trial an error).
I'm amazed!
Edit: I'm usually on a mountain bike.
I’d like to do a dirt/gravel profile. Main reason I haven’t so far is that it’s very hardware-intensive (as in tipping over into renting another Hetzner box).
I usually tend to export routes and navigate with komoot. Komoot for long distance planning is terribly slow as soon as you hit ~200km+.
btw: in general Komoot is a nicely polished app. I can only recommend it :)
Besides large response data and a slaggish planning interface @ komoot: try routing from northern Italy to Sicily: Komoot doesn't seem to know the ferry departing in Villa s. Giovanni to Messina. Komoot will always - no matter how may vias you place - route you back north and send you on a ferry in Salerno. Yes, I know, I could split my route and such. Yet, I love the idea of my planning tool to show me the complete route - including official transportation ;-)
And thanks for building on top of it and making a useful app :)
Do you plan to support area routing?
And you write: "However, the good news ended there: Openrouteservice does not publish the code for calculating this green index". Is your code publicly available and allows "the news to end good" ;) and maybe even integrated elsewhere?
Good point RE the green index calculation. The very least I could do would be to upstream a reference implementation and documentation back to Openrouteservice. I will take care of that.
Very neat app.
For years I've contributed trail data to OpenStreetMap, mostly to support mountain biking, but this is the exact kind of other project it benefits. It was really neat being able to try this on local trails and see just what happens.
One question: What tags does it give priority to?
I ask because I tried it on a local trail system, and it seemed to prefer the wide paved and dirt path as opposed to the mountain bike trail. It was weird in that sometimes it'd use the single track, but in others it'd do sort of an awkward thing through the parking lot / service road (highway=service, service=parking_aisle) then use some of the single track (eg markers 1-2) before jumping on the paved path and pretty much ignoring the single track. The single track is really popular with trail runners in this park, so it got me wondering.
An example of that is here:
https://trailrouter.com/#wps=42.65195,-83.05484%7C42.65088,-...
foot=designated route=root, hiking highway=footway, path, track, bridleway, pedestrian, living_street, residential, service, unclassified maxspeed < 20km/h
Looking at your area (https://www.openstreetmap.org/way/191828180#map=15/42.6423/-...), all of the trails are given equal preference. As a result, it then falls back to whichever gives the shortest path. It's choosing the asphalt one (linked above) just because it's the shortest path. In the future, I may add a surface preference option - so you could give additional preference to non-paved paths.
(Making it worse, someone naively editing a mountain bike trail in iD will end up inadvertently flagging it as highway=cycleway. And then people using OSM for cycling directions get routed down an MTB trail... Yay.)
I know for a fact that the second one is about right, because I ran it already. The first one however is somehow showing "shorter" kilometers, by the end it should be about 2.5km. Did I do something wrong?
Also the first kilometer seems way too short in comparison to the second
Edit: Wait, the numbers are not every kilometer, right?
And yes, the numbers do not represent km, they represent the numbered waypoints listed in the top left box. Any usability suggestions are very much welcome!
And then you can toggle distance measurements.
And for the direction problem, maybe a change of color every kilometer or a gradient? Although that might also be confusing.
Love that your algorithm tries to exclude out-and-backs, I think that goes a long way to make the routes feel organic and appeal to runners. This is really polished and I wish you the best!
One feature suggestion: I wonder if you could have a flag to generate routes starting in parking lots/park entrances in a radius around the starting location. This could go a long way to recommend some common long-run routes where you need to travel a brief distance via car or public transportation but then can get 10-20 miles entirely in the woods.
Your suggestion is a nice one. Here in the UK, where it's common to have trains connecting most towns and larger areas, I have thought about adding the ability to say "I want to run 20 miles, and finish at a train station that can get me home in under an hour". Assuming the user is using a car makes it more easily achievable though. Consider it on the todo list!
More specifically, when 'avoid repetition' is enabled (it is by default), then the routing algorithm has a very significant penalty weight applied to any existing path already taken.
Since people were interested, we invited Sam to repost it.
In that same 6 mile distance, in addition to running past the farms, it could have run me up to the base of the mountains, down the nice bike trail that goes through groves of trees and open field, then back home.
This is one reason I love testing apps like this - my town almost always messes them up.
Especially check out the east side of town, it seems like it wants to go into town for anything short of a 15 mile loop, whereas going east is far more natural.
Thanks for the kind words!
Some thoughts: - Create a community out of it so that people can rate the routes, and therefore provide feedback for the algo? - Use some google streetview or alternative for landmarks along the way so people remember what they should be seeing and don't get lost?
Your suggestion RE landmarks tallies with an issue I've been grappling with: how does a user actually run with the route that they've just planned? Yes, you can export the route to a GPX file, and some users will use that on watches/apps to guide them, but it's a bit clunky and isn't the kind of thing you'd necessarily do for a short 5km run in a new area.
I'd rather avoid building full run tracking functionality, as it'd just be repeating what so many other apps do (and often very well). Perhaps the answer is to enable easy syncing of the route to your other apps. Strangely, Strava (the most popular) don't allow importing of routes via their API.
My preference would be to use Apple Map directions. But it isn’t possible to specify waypoints.
But the official Google Maps URL spec supports specifying waypoints. It would be awesome to click on a link to open the route in Google Maps for turn-by-turn directions.
https://developers.google.com/maps/documentation/urls/guide#...
btw: are you using CH, LM or plain A* for your setup?
I'm using plain A* currently. I understood from the Openrouteservice documentation & code that any time dynamic weights were being used, everything fell back to A* anyway. And I'm using dynamic weights heavily! My understanding could be flawed though, and I appreciate I am going to be a few GraphHopper releases behind now. The speed is okay for now - there's certainly bigger items on my todo list first.
I'm excited to try out GH 1.0 properly. Now that I've got much more familiarity with what I'm doing, I'm keen to switch to using GH directly and somehow try to avoid patching it (or try to get any patches merged back into the open source version).
I was staying near the Colosseum and for one of my runs, thought I’d run on the Appia Antica, because oldest road in the world, into Parco della Caffarella because it looked like a really nice park with lots of trails.
Well, next thing I know I’m running down a one-way cobblestone road with cars coming toward me and there’s no entrance into the park because there’s a huge wall between the road and the park. The road had walls on both sides in fact. I didn't want to turn around because I’d have the cars to my back. So I hugged that wall as close as I could and trusted the shit out of Roman drivers. Eventually I found a way into the park.
Here’s the route Trail Router gave me:
Here's the run I did that day:
The road starts out looking great:
• https://ibb.co/998GQk3 (my picture)
• https://ibb.co/DYXkBt5 (google maps)
But very soon you're on this:
• https://ibb.co/vJcCSXr (google maps)
Well, it was all worth it because eventually I got into the park and I'm still alive:
I know you're at the mercy of map data. I don't know how unique this situation is. I always appreciate a new route planning tool. I usually use a combination of Footpath Route Planner, the heat maps from Strava, and Google Maps street view and satellite view. It's definitely a pain to do that for every trip. Maps are definitely not optimized for pedestrian safety, and things like sidewalks and shoulder-width are often inaccurate or just not there on the maps short of bringing up street view.
One item for consideration in the future is allowing users to flag unsafe portions of a route and then having that visible to other users (and also influence the algorithm).
FWIW, I'm looking at the routes it's planning from my home and they aren't safe. It's sending me down heavily trafficked country roads with little to no shoulder. I'll email you some screenshots.
Thanks for the new app regardless!
This isn't on by default because in some countries/regions, such roads are very reasonable to run on.
Clearly there's a better middle ground though, which might involve highlighting potentially problematic parts of the route in the UI.
Thanks again js2 for your email and all your feedback!
One improvement I might suggest, it’s not clear if this is being done already, is to not just bias towards greenery, but also boa against main roads. The routes generated for me spent a long time on roads that are quite major, where there are nicer alternatives available.
An example: my neighborhood is surrounded by a free laying cycling and walking path. Perhaps diametrically only 30m-100m from houses, but 100% green and rustic. Then the mapper plots a route on sidewalks in urban areas. It did recognize the no. 1 park around though. But I'd hope it would get the woods as well.
I did see a problem with stairs — not sure if algorithm does not take into consideration or if data is not properly marked up in OpenStreetMap, but locally, it recommended a route goong over two long sets of stairs: one of them being practically a goat trail I would recommend against running on, but careful trodding is ok. The other stairs are long and wide, so probably not perfect for running (hard to figure out your stride), but ok. I wonder if elevation rate could be taken into account, which would probably exclude the goat trail one.
I really love running in new places as a way to explore my area as well as when I travel. I find there is something profoundly good about connecting with my surroundings that way. I use Strava Route Planner with the heatmap extensively, and now I think I'll be consulting this a lot.
My only suggestion is to show an elevation profile. There is already a hill preference slider in the settings, but the elevation profile would really make it great to look at.
For viewing the elevation profile, click on the little up arrow on the miles/km distance box at the bottom of the screen.
You can configure a hills preference (either to prefer them or to avoid them) in the settings screen. Click on the cog icon to get there. More details are available at https://trailrouter.com/blog/greenery-and-hills-sliders/
I tend to get great advice and the benefit is that I often meet people to follow on Strava, where I build up a library of potential runs.
I’m not looking forward to a future where every conceivable off-road trail is available, instantly, in an app. I doubt anyone who appreciates nature really is.
Not a complaint, if I ran these are the sort of routes I'd love to explore.
One suggestion: Have changes to the route push state to the history. That way you can use the back button on the browser if you make a mistake. Right now it'll totally take you off of the page.
I tried to solve this in Trail Router by putting an undo button on the screen (bottom right).
Mapping costs would be by far the biggest one. However, I'm very lucky that after the last big spike in traffic, Mapbox very generously admitted me to their community programme. You can read more about that here: https://trailrouter.com/blog/mapbox-community-programme/
The server costs are quite modest at the moment (under $200/mo), which I'm lucky enough to be able to self-fund through my other work. If usage were to massively increase then maybe I'd need to find a way recoup costs. But even all of the hits from HN have barely put a dent in the server utilisation, so there's plenty of headroom for the foreseeable future.
feature request: an option to not cross country borders would be nice.