How to avoid transit routing through certain countries

This forum deals with any kind of routing computation whether it is simple A:B-routing, calculation of isochrones, simple matrix computation or nearest search.
Post Reply
metin.kahraman
Posts: 11
Joined: Tue May 13, 2014 12:32 pm

How to avoid transit routing through certain countries

Post by metin.kahraman »

Dear forum users,

I need to perform an A-B route calculation which excludes Switzerland as a transit country.
I.e. unless A or B are located in Switzerland no Swiss segments should be part of the route.

I am looking for an approach other than simply checking whether A or B are located in Switzerland and then set EXCLUDE_COUNTRIES appropriately in the request.

In case there is no such option, how about introducing a parameter AVOID_COUNTRIES which takes the following value “41=2500;49=100” (as for AVOID_NATIONALNAMEDTOLL_ROADS).

Any recommendations ?

Regards

Metin Kahraman
User avatar
Bernd Welter
Site Admin
Posts: 2695
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: How to avoid transit routing through certain countries

Post by Bernd Welter »

Hello Metin,

I'm not sure what you'd like to achieve - But how about an iterative approach:

Perform a standard routing. The response contains a Waypoint-Array that contains the given input stations extended by several properties such as "the country code" (e.g. 41 for Switzerland).
If the output countries (part of the toll info) contains 41-elements though none of the Waypoints is a 41-waypoint then you have to add the additional AVOID_COUNTRIES=49 to perform a detour.

Of course you should make sure not to request more information via the ResultListOptions than necessary.

By the way:
- 2500 doesn't prevent you from using country 41 - it raises a very strong antipathy and if you can save costs by using these segments (instead of thousand kilometers of detour) you will find them in the response
- 49=100 is not "treat it neutral" but a "slight antipathy" to german segments... If you want to treat them neutral your malus value should be "0"

Regards from Karlsruhe

Bernd
Post Reply