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.

How to route inside a given country or countries?

Postby Bernd Welter » Tue Mar 17, 2020 10:48 am

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".
GeographicRestrictions-US.PNG
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!):
    xml code
    <?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: https://xserver2-europe-eu-test.cloud.p ... uting.html#com.ptvgroup.xserver.routing.GeographicRestrictions

ROUTING_COUNTRIES.PNG
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
Senior Technical Consultant Developer Components
PTV GROUP - Germany

Bernd at Youtube
User avatar
Bernd Welter
Site Admin
 
Posts: 1545
Joined: Mon Apr 14, 2014 10:28 am

Return to PTV xRouteServer

cron