# Problems with adopting steepness for hiking profile

For my usecase I use the hike and mountainbike profiles but the included ones don’t consider steepness.
So now I was having a look at the bike2 profile and try to adopt it for the hiking profile. Now I made good progress, so that steep section require more time (by decreasing the speed).

So what I now don’t understand is the following:
I made speed go down it there is a lot of ascent and made it slightly go up if descending. But still, when I reverse a route, the duration is the same.

So what I figured out is that the bike profile has part of the code that asks `isForward` / `isBackward`. Can anybody tell my how that works? What is it?

I assume the following:

I have an edge with a starting point A at 100m altitude and an endpoint B at let’s say 200m altitude.
if `isForward` is true I would have an ascent of 100m but if `isBackward` is true than I’d have a descent of 100m?!? right?
So A is still index 0 in the point-list and B is at the last index, but the system want’s to know… how fast would i be if I went the opposite direction?!?

At least when I do so, I get wrong results… So I guess that my assumption is wrong?

EDIT: ok… a little playing revealed that `isForward` is not the opposite of `isBackward`… So i guess my assumption is wrong?!?

Hi Georg,

you should work with the bike2 profile. This allows you to set two different speeds, one into one direction, one in the opposite direction. For example a road that goes uphill into one direction goes downhill into the other direction. So maybe you increased and decreased the speed for the edges?

Essentially the trick is to have two speed encoders, one for backwards and one for forwards. It’s just the direction of travelling on the edge.

Also check the speed factor, for bike it is 2, meaning differences of 1 km/h cannot be represented. You should set limites in 2 km/h steps.

Hope this helps.

Best,
Robin

Hey Robin,
Ok… so indeed the bike2 encoder has a seperate `reverseSpeedEncoder`.
So now I went ahead and in my modified Hike Profile I added it as well.
I basically copied over most of the bike2 flag encoder, except for the `handleSpeed(...)` method as it’s not part of any superclass of the Hike Profile.
So now everything except that missing function is basically the same, but still I don’t get any routes any more at all. So I guess it does something important?

From the code I don’t really see what it’s doing so I am a bit stuck here
It would be awesome if you could shed some light on what those functions actually do?

So what would be needed to get the `two different speeds` feature for my hiking profile?

Cheers,
Georg

Hi Georg,

well it’s hard without seeing code. I have two ideas:

1. Your speed writing process is faulty, check the speed of a certain edge. I would use IDE debugging for this.
2. You did not change the getSpeed method and always return one speed.

I think your issue is 1. But could go wrong in so many places, sorry ;).

Best,
Robin

Hey Robin,
thanks, I already found my problem. It indeed was the speed writing process.

Now I am debugging a problem with my updated mountainbike profile where routing is always done using a very steep section rather than going around a bit more and use a nice road…

Now while debugging, for the way-id I am looking I found that the `applyWayTags(...)` is only called for `isBackward` but never for `isForward`. An on the other hand, the part of the road that is used is only called once for `isBackward`.
Could you explain to me why this isBackward/Forward problems happens?

Also… could you explain to me why routing is done using the steep part and not the flatter one? To force the router to use the flatter one I (for debugging) set the speed on that part very high and the speed on the other very low… still if prefers the steep/bad one?!? So I guess it’s not speed only… but for the road type f.e. the “good” one is track and the bad one is path. Both are in the `preferHighwayTags`. So there should be no difference there…

Is there a way to get a verbose output while routing? So that I can see why the router took road A vs road B?

Cheers,
Georg

Hi Georg,

Well, this is only called once, I would assume that you have to do the two-way handling there. Interesting that this does not happen for Bike2, do you know why @karussell?

This depends on the weighting. If you use fastest, the speed has an influence. Also check the maxSpeed, maybe the road you want to favor is 10x longer, so the other would have to be 10x slower, maybe this is not possible (haven’t checked any code, don’t work much with the bike profile).

You can check the MiniUI, which might help you. You can change the visualization quite easily to match your needs.

What do you mean here? We have the code in Bike2WeightFlagEncoder.applyWayTags and there is one branch for isForward and one for isBackward.

Ah you are right sorry .

@boldtrn thank you for all your help! I now figured out how to apply the steepness the it drastically improved the results of my hiking profile!!! great! thanks!!!