Local ORS server ignores avoid_borders – isochrone crosses country border

Hello,

I’m running a local OpenRouteService instance and I can’t get the avoid_borders option to work.

Setup

  • ORS version: 9.1.2 (Docker)
  • Input data: very small .osm.pbf (≈20 × 20 km) covering the Poland–Ukraine border.
    • Roads were filtered and clipped to this bounding box.
    • I manually created and placed
      borders.geojson, ids.csv, and openborders.geojson
      in /home/ors/files/

Issue

  • The isochrone is generated successfully (no errors),
    but it extends across the international border between Poland and Ukraine.

What I checked

  • ORS log shows normal startup with no warnings about missing borders.
  • Without “avoid_borders” the isochrone is identical.

Question

Does ORS require the original OSM admin_level=2 relations to be present in the PBF for avoid_borders to work, even if I provide my own borders.geojson/ids.csv?
Is it possible to use a very small road extract with custom border files and still have the avoid_borders option respected?

Thanks in advance for any hints.

ORS does not read the borders from OSM but from a separate file. It should work with your own files. You have to rebuild the graphs in order to have the new border files respected. AFAIK it is only supported for driving profiles.

You could check whether avoiding borders works with regular routing.

I executed two requests on the local server:

  1. {“coordinates”:[[23.13863,49.95441],[23.09670,49.95978]],“options”:{‘avoid_borders’:“all”}}
  2. {“coordinates”:[[23.13863,49.95441],[23.09670,49.95978]]}
    Both requests returned the same route.
    Although I also ran the first query ( {“coordinates”:[[23.13863,49.95441],[23.09670,49.95978]],“options”:{‘avoid_borders’:“all”}}) on a cloud server, and it returned the message

“message”
:
“Route could not be found - Unable to find a route between points 1 (23.1386300 49.9544100) and 2 (23.0967000 49.9597800).”

Previously, I created separate border files borders.geojson, ids.csv, and openborders.geojson in accordance with this specification openrouteservice/ors-api/src/test/files/borders/openborders.csv at main · GIScience/openrouteservice · GitHub. I placed the created files in the directory: /home/ors/files/. And I used this configuration:

ors:
  engine:
    init_threads: 4
    profile_default:
      build:
        source_file: /home/ors/files/ua_pl_ext.osm.pbf
    profiles:
      driving-car:
        enabled: true
        build:
          ext_storages:
            Borders:
              preprocessed: false
              boundaries: /home/ors/files/borders.geojson
              ids: /home/ors/files/ids.csv
              openborders: /home/ors/files/openborders.csv
      public-transport:
        enabled: false
        encoder_name: public-transport
        build:
          encoder_options:
            block_fords: false
            enable_custom_models: false
          elevation: true
        service:
          maximum_visited_nodes: 1000000
  endpoints:
    isochrones:
      enabled: true
      attribution: openrouteservice.org, OpenStreetMap contributors
      maximum_locations: 5
      maximum_intervals: 5
      allow_compute_area: true
      maximum_range_distance_default: 50000
      maximum_range_distance:
        - profiles: driving-car, driving-hgv
          value: 300000
      maximum_range_time_default: 18000
      maximum_range_time:
        - profiles: driving-car, driving-hgv
          value: 3600
      fastisochrones:
        maximum_range_distance_default: 50000
        maximum_range_distance:
          - profiles: driving-car, driving-hgv
            value: 500000
        maximum_range_time_default: 18000
        maximum_range_time:
          - profiles: driving-car, driving-hgv
            value: 10800

In the graphs-folder you can also check graph_build_info.yml which contains the actual configuration with which the graph was build, so you can see whther your configuration was used.

Have you tried deleting and rebuilding the graphs?

I found the reason. The graph was constructed without taking borders into account for two reasons:

  1. In the borders.geojson file, I had a column called “name_en” as specified in the specification (openrouteservice/ors-api/src/test/files/borders/borders.csv at main · GIScience/openrouteservice · GitHub). I checked the log and saw that ORC was looking for a column called “name,” so I changed the column name.

  2. In the ids.csv file, in the “name” column, I wrote the names of countries in the local language, i.e. ‘Polska’ and ‘ Україна’, and in the “name:en” column, I wrote the names in English (as specified in the specification), but most likely ORC does not read Cyrillic. I updated the “name” column with English names, and everything worked.

I would like to ask the developers to update or create a correct specification for the borders.geojson and ids.csv files.

2 Likes

Thanks for providing feedback. I’ve opened an issue: Document how to use own border files · Issue #2133 · GIScience/openrouteservice · GitHub

1 Like