Hello,
I’m working on a running route builder that favours greenery & nature over distance, and can also automatically generate routes for you of a target distance. An early version is available on trailrouter.com.
It uses Openrouteservice at its core (which is fantastic!), and I use the green routing feature quite heavily. I believe this means I rely entirely on dynamic weights.
A common use case is creating a “round-trip route”, whereby you start at X, run 20km, and finish back at X. Often, these round-trip routes are automatically plotted along a hiking trail or coastline, which are generally very long lines. So the algorithm often ends up giving you a 10km out-and-back approach. This is technically fine, but some people (including me) prefer to avoid the repetition and would rather have a different route back even if it’s slightly less optimal.
My idea for doing this would be to do something like the following:
- Calculate the 10km route from the start point X out to the turnaround point (as I currently do).
- Add all edges traversed in step 1 to a penalty list, such that if they are used again then they will get a penalty weight
- Calculate the route back to the start point X, utilising the additional weights produced in step 2
Does this seem a reasonable approach? Any pointers to where I should look in the code to achieve this?
Thanks,
Sam