routing icon indicating copy to clipboard operation
routing copied to clipboard

Question: Calculate route where current road is preferred

Open ohjulstad opened this issue 4 years ago • 1 comments

Hi, I am new to Itinero and route planners, and in my project I try to get the route planner to prefer the current road number. So I want to add a “penalty” to turning off the current road number. We have already used the road classifications in the lua file to get the route planner to prefer some types of roads, however I am unable to see if it is possible in the lua profile to calculate the factor based on current road number and increase the cost of turning off the road. I have investigated creating a CustomWeightHandler for this? But I am unsure if this is the right approach or even possible.

We have genereated our own routerdb file with road number and road category as some of the edge attributes

Any pointers would be helpful! Thanks!

ohjulstad avatar May 15 '20 10:05 ohjulstad

See turnPenalty in the source code and example is @ https://github.com/itinero/routing/issues/307 I think

//Indicate no turns are preferred
                const float?[] NoPreferredTurns = null;
//Try to calculate a route without any u turns
                var route = Router.TryCalculate(profile, routerPoints, float.MaxValue, NoPreferredTurns, cancellationToken);

juliusfriedman avatar May 15 '20 22:05 juliusfriedman