Hello,
I need help with counting and displaying several alternative routes together on one map.
This feature is available?
What should I set to work properly?
It is a simple model of how to do it?
Thank you.
Vladimir Plachy
Alternative routes together on one map
- Bernd Welter
- Site Admin
- Posts: 2695
- Joined: Mon Apr 14, 2014 10:28 am
- Contact:
Re: Alternative routes together on one map
Hello Vladimir,
basically the computation of alternative routes is based on the following principles:
So whenever you want to compute the alternative #N you have to compute the VERSION[0], VERSION[1], ... VERSION[N-1] and provide it in the call of VERSION[N].
There is also a shortcut available:
There is a special RoutingOption avalable for that scenario. So if you want to compute the VERSION[2] with just one single call you may use it:
Be aware that the proper ExceptionPath mechanisms offers both an absolute malus and a relative malus..
Here are some example screenshots: So quite often especially start and final part of a route do not change that much.
Best regards
Bernd
PS: my description is based on calcRoute but also works with calcExtendedRoute and the other, more complex variants.
basically the computation of alternative routes is based on the following principles:
- in a first step a regular route is calculated, let's call it the VERSION_0.
Code: Select all
Route route = svcRoute.calculateRoute(arrWPD, arrRoutingOptions, null, resultListOptions, callerContext);
- The output of the call is a route object including a so-called binaryPathDescription.
- Based on the binaryPath you create an ExceptionPath together with a malus that suits your requirements, e.g. 500 if you want to avoid each VERSION_0 segment with a malus of 500%.
- in a second call you use the same routing parametrization (profile/snippet encapsulated in the CallerCOntext, routing options as explicit parameters if necessary) but you add the ExceptionPath as an additional input information.
Code: Select all
Route route = svcRoute.calculateRoute(arrWPD, arrRoutingOption, null, rlo, cc);
ExceptionPath[] arrExPath = new ExceptionPath[] {
new ExceptionPath() {
binaryPathDesc = route.binaryPathDesc,
relMalus = 500
}
};
Route alternativeRoute = svcRoute.calculateRoute(arrWPD, arrRoutingOption, arrExPath, rlo, cc);
There is also a shortcut available:
There is a special RoutingOption avalable for that scenario. So if you want to compute the VERSION[2] with just one single call you may use it:
Code: Select all
int malus = 500;
int indexALT = 2;
RoutingOption alt = new RoutingOption() {
parameter = RoutingParameter.EXPERT_OPTIONS,
value = "ALT|" + malus + "|" + indexALT
};
Here are some example screenshots: So quite often especially start and final part of a route do not change that much.
Best regards
Bernd
PS: my description is based on calcRoute but also works with calcExtendedRoute and the other, more complex variants.
Re: Alternative routes together on one map
Hello Bernd,
Thank you for your help.
Vladimir
Thank you for your help.
Vladimir
Re: Alternative routes together on one map
Hi, I've tryed to use a similar method, but I do not like the given results becouse if I assign a malus to a route the system creates a completely different alternative without taking into account that a better choice could be have a part of route in common.Bernd Welter wrote:Hello Vladimir,
basically the computation of alternative routes is based on the following principles:
- in a first step a regular route is calculated, let's call it the VERSION_0.
Code: Select all
Route route = svcRoute.calculateRoute(arrWPD, arrRoutingOptions, null, resultListOptions, callerContext);
- The output of the call is a route object including a so-called binaryPathDescription.
- Based on the binaryPath you create an ExceptionPath together with a malus that suits your requirements, e.g. 500 if you want to avoid each VERSION_0 segment with a malus of 500%.
- in a second call you use the same routing parametrization (profile/snippet encapsulated in the CallerCOntext, routing options as explicit parameters if necessary) but you add the ExceptionPath as an additional input information.
As you can see in the image xroute gives me a route totally different from the first one. Maybe I've to change the relMalus value but I'm not able to understand the meaning of the different values. Change the relMalus value from 2501 to 2000 doesn't make any difference.
Thank you
- Bernd Welter
- Site Admin
- Posts: 2695
- Joined: Mon Apr 14, 2014 10:28 am
- Contact:
Re: Alternative routes together on one map
Routing means (in rough terms):
determine the sequence of segments that successfully connects waypoint A(x0,y0) to waypoint B(x1,y1) and produces the minimum aggregated "cost".
The costs of a single segment are influenced by various factors, e.g.
Regards Bernd
determine the sequence of segments that successfully connects waypoint A(x0,y0) to waypoint B(x1,y1) and produces the minimum aggregated "cost".
The costs of a single segment are influenced by various factors, e.g.
- length of a segment
- driving time (derived by network class via speed values)
- percentage malus due to road category (AVOID_TOLLROADS, AVOID_...)
- other malus values (e.g. based on ExceptionPath)
Regards Bernd
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany
Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning...
Technical Partner Manager Developer Components
PTV Logistics - Germany
Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning...
Re: Alternative routes together on one map
Thank you very much. With your help my routes are improving.Bernd Welter wrote:Routing means (in rough terms):
determine the sequence of segments that successfully connects waypoint A(x0,y0) to waypoint B(x1,y1) and produces the minimum aggregated "cost".
The costs of a single segment are influenced by various factors, e.g.Now setting the ALTERNATIVE ROUTE MALUS means that all the succeeding alternatives will "malify" the segments used in previous ALTERNATIVES. I attached some screenshots, maybe they can help you to understand the approaches, If not let me know!
- length of a segment
- driving time (derived by network class via speed values)
- percentage malus due to road category (AVOID_TOLLROADS, AVOID_...)
- other malus values (e.g. based on ExceptionPath)
Regards Bernd