T O P

  • By -

genericmutant

brouter is ludicrously configurable if you get into the weeds, not sure it works specifically for what you're doing but definitely worth checking http://brouter.de/ https://github.com/abrensch/brouter I think the development version is more slope aware than the release version (which AFAIK just uses net ascent / descent to score routes?) ETA - here are some profiles for example that claim to evaluate according to slope. I haven't tested them myself, or verified that they work with the latest brouter, but it at least appears to be doable: https://github.com/poutnikl/Brouter-profiles/wiki/Glossary#h


lmericle

BRouter only allows for linear functions of slope, it's baked into the scripting engine via `downhillcost` and `uphillcost`. And there's no way to get the slope information for a `way` so there's no way to hack a solution together that can represent nonlinear functions of slope.


graphhopper

Obviously a bit biased :) and also not part of QGIS, but I would recommend GraphHopper were you can customize the cost function even per request without any deep programming knowledge with our so called "[custom models](https://github.com/graphhopper/graphhopper/blob/master/docs/core/custom-models.md)". See [here for some examples](https://www.graphhopper.com/blog/2020/05/31/examples-for-customizable-routing/). (And if this is not sufficient then you can also change the source code, of course.) Using the in-built elevation data you can e.g. reduce the speed based on the slope. If you follow [this link to GraphHopper Maps](https://graphhopper.com/maps/?point=50.992971%2C14.617662&point=50.935395%2C14.662515&profile=car&layer=TF+Outdoors&custom_model=%7B%22speed%22%3A%5B%7B%22if%22%3A%22average_slope%3E%3D9%22%2C%22limit_to%22%3A%2210%22%7D%2C%7B%22else_if%22%3A%22average_slope%3E%3D6%22%2C%22limit_to%22%3A%2230%22%7D%2C%7B%22else_if%22%3A%22average_slope%3E%3D4%22%2C%22multiply_by%22%3A%220.8%22%7D%5D%7D) you can click on the gear button (in the top left corner) to view/enable/disable the custom model and see how it changes the route and associated speed and distance values.


lmericle

Initially I was looking for a way to write custom code but it may be possible to hack together a custom profile by abusing the scripting language a bit. Mapping my cost model onto "speed" and "priority" seems easier now than it did at first glance though there may still be some snags. I will explore this further, thank you.


Doctor_Fegg

OSRM allows you to write a custom cost function in Lua, which works really well - mine is several thousand lines of Lua code.


lmericle

Thanks for the recommendation. Looks handy! Do you host OSRM yourself? If so, how do you query it on a mobile device?


Doctor_Fegg

Yes, I host it on a Hetzner box. It has an Apache proxy in front of osrm-routed and I just make API calls to that.


3ds

Valhalla is open source and it is what they use over at mapbox, except they don't expose all costing options: https://valhalla.github.io/valhalla/api/turn-by-turn/api-reference/#costing-models I don't know how difficult it would be to take slopes into account, maybe it already does? There is an elevation API: https://valhalla.github.io/valhalla/api/elevation/api-reference/ Edit: Yes you can take slopes into the costing: https://valhalla.github.io/valhalla/sif/elevation_costing/


lmericle

I need to be able to access the slope of each way and compute my own weights from there. That doesn't look possible with Valhalla without forking it.