Avoid_countries

in my ORS instance i have europe-latest.osm.pbf my verison API is 7.1.0, my curl request:

curl -X POST
http://127.0.0.1:8082/ors/v2/directions/driving-hgv/gpx
-H ‘Content-Type: application/json; charset=utf-8’
-H ‘Accept: application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8’
-d ‘{
“radiuses”:[1000,1000],
“coordinates”: [
[18.01434, 53.122091],
[-3.69063, 40.42526]
],
“options”:{
“avoid_borders”: “controlled”,“avoid_countries”: [74]
}
}’

this is route from poland (bydgoszcz) to mediolan spain avoid DE.
avoid_countries not working(route works, through Germany unfortunately), my graphs is ok (no error at generate).
in my logs no errors… how to debug this problem? or fix?
the rest of the parameters like avoid_features etc. work ok (tested GPX at http://gpx.studio)

Hello,
I’m facing the same problem and wanted to ask if you’ve found a solution. I can’t get avoid_countries to be taken into account when calculating the route. I use the following query to avoid Switzerland and Austria, for example:

{“coordinates”:[[10.077703475952148,48.44784927368164],[8.052016258239746,45.5595817565918]],“preference”:“recommended”,“options”:{“avoid_features”:[“ferries”],“avoid_countries”:[193,11],“vehicle_type”:“goods”},“maximum_speed”:80}

Nevertheless, the result of the route calculation takes me right through these countries (in the above case, through Switzerland, see screenshot).

I have tried a lot of things without getting the desired result. I use the profile hgv with

    preparation:
      min_network_size: 200
      methods:
        ch:
          enabled: true
          threads: 2
          weightings: recommended,fastest,shortest
        core:
          enabled: true
          threads: 2
          weightings: recommended,fastest,shortest
          landmarks: 64
          lmsets: highways;allow_all

It might be interesting to note that I couldn’t get ORS to work with the settings from the documentation:
lmsets: highways,tollways;highways;tollways;country_193;allow_all

I used the Europe map from geofabrik: europe-latest.osm.pbf

If further information is needed, please ask :slight_smile:

Hey,

both problems are probably to do with the fact that the border storage is not activated.
The border storage, also documented in our backend docs, is necessary for both avoid_countries to work and for the lmsets-config to work.

Documentation is a bit lacking, but have a look at the test file structure - your border geometry files should have a name attribute that corresponds to a name in the ids.csv-file.

If building takes too long, have a look at this issue describing a process for border geometry preparation to speed up parsing times of border geometry.

Be aware that changes might be coming to this process, as we are currently reworking how and when borders are read.

Best regards

Hello,

Thank you for your answer. That of course explains why I haven’t had any success so far.

Did I understand correctly that I have to prepare every country that I potentially want to avoid by hand according to these instructions? In my example, once for Switzerland and once for Austria?

Do you know if there are countries available for download on the Internet? I have found this at geofabrik:


Is it possible to use the .poly file?

Best regards

No, this process is only necessary if building takes too long.

As I understand it, the openrouteservice expects a geojson-file here. Have a look at OSM-Boundaries for this.

Best regards

2 Likes