Page 1 of 1

How to route inside a given country or countries?

Posted: Tue Mar 17, 2020 10:48 am
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