This can be done by identifying tagged barrier=border_control nodes.
However, not all borders have these, and you may want to do routing other kinds of administrative boundaries, like counties, cities, etc.
We have support for the --location-dependent-data feature, which allows you to add GeoJSON properties to ways before they're handed to process_way. To support adding penalties at area boundaries, we could expose those same tags as something like turn.source_location_tags and turn.target_location_tags in process_turn, which would allow you to identify when a turn crosses a boundary defined in a GeoJSON you supply.
Over in https://github.com/Project-OSRM/osrm-backend/issues/2322#issuecomment-404802575, it was asked how to add penalties for border crossings so that routes tended to stay within countries.
This can be done by identifying tagged
barrier=border_control
nodes.However, not all borders have these, and you may want to do routing other kinds of administrative boundaries, like counties, cities, etc.
We have support for the
--location-dependent-data
feature, which allows you to add GeoJSON properties to ways before they're handed toprocess_way
. To support adding penalties at area boundaries, we could expose those same tags as something liketurn.source_location_tags
andturn.target_location_tags
inprocess_turn
, which would allow you to identify when a turn crosses a boundary defined in a GeoJSON you supply.