osrm-backend icon indicating copy to clipboard operation
osrm-backend copied to clipboard

Area Routing

Open MarcelloPerathoner opened this issue 9 months ago • 14 comments

This PR provides routing over areas.

It builds a visibility graph of the area, then runs dijkstra from each entry point to reduce the number of edges, then adds the remaining edges as ways to the router.

  

From the OSM site, without area routing, following mapped-for-the-router ways:

Screenshot from 2025-05-22 10-56-47

With area routing, also note the better directions:

Screenshot from 2025-05-22 10-55-44

Documentation

Issue

Fixes #64 #2655 #7146

Tasklist

TODO

  • entrances to buildings along the perimeter of the area,
  • PT stations in the middle of the area,
  • alternate algorithms, eg. retraction.

MarcelloPerathoner avatar May 01 '25 16:05 MarcelloPerathoner

cool feature!

seems the linked screenshots don't show tho in the PR

DennisOSRM avatar May 02 '25 13:05 DennisOSRM

seems the linked screenshots don't show tho in the PR

I re-uploaded them. Do they show now?

MarcelloPerathoner avatar May 02 '25 15:05 MarcelloPerathoner

seems the linked screenshots don't show tho in the PR

I re-uploaded them. Do they show now?

They do. Thanks a lot

DennisOSRM avatar May 02 '25 15:05 DennisOSRM

Had a first look at the change. First of all, great feature! I think this has been on the todo list for more than 10 years 😀

The main question I have is that we should probably own the Dijkstra implementation that is used and not fall back to boost.

DennisOSRM avatar May 04 '25 14:05 DennisOSRM

Do we have a general dislike for boost? Just asking ...

MarcelloPerathoner avatar May 04 '25 15:05 MarcelloPerathoner

Do we have a general dislike for boost? Just asking ...

Perhaps 😉

Also, routing is our expertise and we should own all routing logic.

DennisOSRM avatar May 04 '25 16:05 DennisOSRM

Dijkstra in itself is trivial to implement. The hardest piece is the priority queue, if we don't want to take the one in boost. They use a 4-ary heap. A binary heap will do for our problem sizes. I will look into this.

MarcelloPerathoner avatar May 05 '25 10:05 MarcelloPerathoner

The good news is that heap implementations already exist in our code base:

  • include/util/binary_heap.hpp
  • include/util/d_ary_heap.hpp

DennisOSRM avatar May 05 '25 13:05 DennisOSRM

just tweaked the settings s.t. GitHub Actions should now run automatically on push.

DennisOSRM avatar May 06 '25 16:05 DennisOSRM

I have now implemented Dijkstra and a binary heap that works with it. The d-ary heap in include/util/d_ary_heap.hpp looks like it could be coaxed into service too, but it is completely undocumented.

Shouldn't we drop / update the macos-x64 build since it is based on apple-clang-14? All other builds use clang >= 16.

MarcelloPerathoner avatar May 06 '25 21:05 MarcelloPerathoner

Let me know when the change is ready for reviewing. 😉

DennisOSRM avatar May 14 '25 18:05 DennisOSRM

@DennisOSRM I think this is ready for review.

MarcelloPerathoner avatar May 24 '25 19:05 MarcelloPerathoner

It's great that “area routing” is getting some attention again. The algorithms and implementations are available (see, for example, this comment and the follow-up posts seven years(!) ago)...

I was recently made aware of this missing feature when I was testing my “vampire mode” - an OSRM profile for pedestrians that prefers shady streets...

sfkeller avatar Nov 01 '25 23:11 sfkeller

Taking full advantage of this may require new tags for areas where it's not clear whether they are traversable or not (for example a natural=forest). This discussion is relevant: https://community.openstreetmap.org/t/tagging-a-traversable-area/138357

safwat-halaby avatar Nov 28 '25 13:11 safwat-halaby