How to route inside a given country or 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
User avatar
Bernd Welter
Site Admin
Posts: 2695
Joined: Mon Apr 14, 2014 10:28 am
Contact:

How to route inside a given country or countries?

Post by Bernd Welter »

Hi there,

I've been asked whether it is possible to ensure a routing track stays within specific countries, for example "Germany only" or "Germany+Austria".
Yes we can: sample created with xServer2 (PTV cloud services):<br />Left map: Route takes direct way through the state of Virginia (418km)<br />Right map: Virginia is on the blacklist and therefore a large detour is taken (1'600km)
Yes we can: sample created with xServer2 (PTV cloud services):
Left map: Route takes direct way through the state of Virginia (418km)
Right map: Virginia is on the blacklist and therefore a large detour is taken (1'600km)
This is possible with the following approaches:
  • If you work with profile snippets check this snippet - this also works with xTour (please consider the complete process!):

    Code: Select all

    <?xml version="1.0" encoding="UTF-8"?>
    <Profile>
        <Routing majorVersion="2" minorVersion="0">
                <Algorithm>
                    <GeographicRestrictions>
                        <AllowedCountry countryCode="49"></AllowedCountry>
                    </GeographicRestrictions>
                </Algorithm>
            </Routing>
        </Profile>
  • xRoute1: use the RoutingOption.ROUTING_COUNTRIES : A list of countries to use exclusively in route calculation (*)
    The list has to be described as a string of comma separated values. Legal values are either PTV numbers (IU) or ISO2 or ISO3 codes: integration unit codes. Please note that ISO codes do not work for Russia, Australia, the United States and Canada.
    BENEFIT: easy to access - DISADVANTAGE: Doesn't work with xTour
  • xRoute2: com.ptvgroup.xserver.routing.GeographicRestrictions
Both routes connect the German cities Saarbrücken and Freiburg.<br />Left map: route invalid because it leaves the country<br />Right map: route limited to Germany, detour
Both routes connect the German cities Saarbrücken and Freiburg.
Left map: route invalid because it leaves the country
Right map: route limited to Germany, detour
Feel free to get back to me in case of questions,

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... :twisted:
Post Reply