Helium
Helium

Reputation: 368

How to route avoiding a cerntain zone in OSRM

I want to find routes using OSRM (Open Source Routing Machine) avoiding a certain area of the city, specified by a polygon, as an option. One approach is to make two profiles: car and car_avoid_no_drive_zone. The latter profile looks up each way segment and sets the length to infinity if it is inside the no drive zone.

But this approach technically duplicates the pre-processing, disk usage and RAM usage. Is there any better solution to this problem?

Upvotes: 2

Views: 3099

Answers (1)

Michael Krasnyk
Michael Krasnyk

Reputation: 134

it is possible to block some area via a "traffic update" by setting 0 speed on all OSM segments on the border of the restricted area and doing only CH contraction or MLD customization. This approach will still generate two graphs. More information here https://github.com/Project-OSRM/osrm-backend/wiki/Traffic

Another way is to use a coming soon "avoid" feature https://github.com/Project-OSRM/osrm-backend/pull/4315 by defining a "restricted area" class in a profile and using a query parameter like avoid=restricted at runtime.

Upvotes: 5

Related Questions