itinero / routing

The routing core of itinero.
Apache License 2.0
222 stars 70 forks source link

Question: Calculate route where current road is preferred #313

Open ohjulstad opened 4 years ago

ohjulstad commented 4 years ago

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!

juliusfriedman commented 4 years ago

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);