abrensch / brouter

configurable OSM offline router with elevation awareness, Java + Android
MIT License
473 stars 113 forks source link

More fine-grained penalization of ascents and descents #617

Open sjakobi opened 10 months ago

sjakobi commented 10 months ago

Two examples with penalties on a scale of 1–10. The bike should be assumed to be a moderately loaded trekking bike.

Example 1: highway=secondary with surface=asphalt and smoothness=good:

Incline Penalty Note
-∞ – -25% 10 Very Dangerous: Brakes may be insufficient or overheat
-25% – -20% 7 Still dangerous
-20% – 12% 5 Somewhat dangerous, danger of overheating brakes on longer stretches
-12% – -2% 2 Good: The descent helps reduce the difference in speed between my bike and the car traffic
-2% – +2% 4 Uncomfortable difference in speed with the car traffic
+2% – +10% 6 Very uncomfortable
+10% – +15% 8 Dangerous: The swaying bike may get too close to the overtaking cars
+15% – +∞ 10 I'd rather not push my bike on a highway=secondary

Example 2: highway=track with tracktype=grade2, surface=compacted and smoothness=bad:

Incline Penalty Note
-∞ – -15% 10 Very Dangerous: Tires may lose traction; potholes could throw me off the bike
-15% – -7% 8 Still dangerous
-7% – -3% 4 Somewhat dangerous
-3% – 0% 3 Need to reduce speed due to potholes / large gravel
0% – +3% 2 Comfortable
+3% – +10% 5 Somewhat exhausting
+10% – +15% 7 Rear tire may lose traction
+15% – +20% 9 Pushing
+20% - +∞ 10 Shoes may lose traction during pushing

Current state of BRouter

AFAIK it's currently impossible to express cost functions of this shape in BRouter. downhillcost, downhillcutoff, uphillcost and uphillcutoff are all constants. Therefore downhillcostfactor and uphillcostfactor can't vary for different inclines.

Motivation

I think that fine-grained penalization of inclines would help cyclists to use the road network more effectively and safely. Someone with narrow road tires may prefer taking a moderate ascent on a grade2 track rather than on a primary highway. Most cyclists would probably prefer to avoid steep descents (say -15% and steeper) entirely.

I don't know how this feature should be designed or implemented, but I think it would be a great improvement! :)

(Related / background: https://github.com/poutnikl/Brouter-profiles/issues/29, related earlier issue: https://github.com/abrensch/brouter/issues/22)

quaelnix commented 10 months ago

AFAIK it's currently impossible to express cost functions of this shape in BRouter.

Yes, there is currently no way to directly relate the cost factor to the (internally calculated) slope of a way segment.

Therefore downhillcostfactor and uphillcostfactor can't vary for different inclines.

Correct, but they can at least vary for different types of ways, see: Allow hill cost and hill cutoff in way context

lukasmericle commented 7 months ago

there is currently no way to directly relate the cost factor to the (internally calculated) slope of a way segment

It would be very useful to simply expose the slope in a named variable for use in scripts. For instance, the energy spent when walking/hiking is nonlinear vs the slope, so calculating energy-based costs is impossible. Maybe there is some hack or workaround I am missing?

Should I make a new issue on this repo to request this specifically so it can be labeled and tracked?

quaelnix commented 7 months ago

@lukasmericle, I don't think there is an easy way to achieve this, as the slope along the way segments (up to several kilometers long) on which the profile script operates is generally not constant.

lukasmericle commented 7 months ago

Is it possible to infer the slope of a way segment from the two nodes at its endpoints? Do we have access to lat/lon/elevation of those nodes?

If not, are there other routing engines you're aware of that do expose this kind of information? Thanks

quaelnix commented 7 months ago

Is it possible to infer the slope of a way segment from the two nodes at its endpoints?

Yes, but then you get the "plain ascend" of this segment and neither the maximum nor the minimum slope.

are there other routing engines you're aware of that do expose this kind of information?

I don't know, sorry. But you can already soft limit the max slope in BRouter like this: https://github.com/abrensch/brouter/blob/93b13be1d45bcda20c8bc886ed24adb566bcf748/misc/profiles2/gravel.brf#L35-L38