Repository navigation
feat(area): route from any point inside a pedestrian area - #7684
Merged
Merged
Conversation
This was referenced Aug 11, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds end-to-end support for snapping coordinates inside meshed pedestrian/open areas, so routing can start/end from any interior point by connecting the request to visible mesh vertices and charging the walked approach distance.
Changes:
- Persist meshed-area polygons + ring metadata and an accompanying area R-tree in a new
.osrm.openareasdataset, and load it in the engine datafacades. - Implement engine-side inside-area visibility + snapping to visible vertices (
SnapInsideOpenArea), integrate into plugin candidate generation, and ensure waypoints reflect the candidate actually used by the route. - Fix/extend area meshing output (ring edges always emitted; optional whole visibility graph emission) and add unit + cucumber coverage plus debug visualization tooling.
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| unit_tests/extractor/area/open_areas_files.cpp | Tests round-trip serialization of .osrm.openareas including ring lengths. |
| unit_tests/extractor/area/area_mesher.cpp | Adds extractor unit tests for recording polygons for engine and whole-graph emission behavior. |
| unit_tests/extractor/area/area_data_collector.cpp | Adds unit tests for collector determinism, thread-safety, obstacle ring recording, and layout stability. |
| unit_tests/engine/area_visibility.cpp | Adds unit tests for inside/visibility predicates used by snapping. |
| src/storage/storage.cpp | Registers/loads .osrm.openareas data and open-area R-tree metadata into storage layouts. |
| src/extractor/scripting_environment_lua.cpp | Exposes profile properties controlling area walking speed and visibility-graph emission. |
| src/extractor/extractor.cpp | Finalizes deterministic area polygon ordering and writes .osrm.openareas + R-tree index. |
| src/extractor/area/area_mesher.cpp | Records polygons for engine, emits ring edges in all modes, and relaxes entry-point meshing threshold. |
| src/extractor/area/area_data_collector.cpp | Implements polygon record collection and deterministic finalize() ordering. |
| src/engine/routing_algorithms/routing_base.cpp | Ensures endpoints are matched only against enabled segment IDs. |
| src/engine/datafacade/process_memory_allocator.cpp | Includes open-area R-tree region in process allocator layout. |
| src/engine/datafacade/mmap_memory_allocator.cpp | Maps open-area R-tree leaf-file path region for mmap allocator. |
| src/engine/area_visibility.cpp | Implements geometric predicates for inside-area and line-of-sight checks. |
| src/engine/area_snapping.cpp | Implements snapping from interior points to visible vertices with approach cost. |
| scripts/debug/area_snapping_report.py | Adds measurement + SVG reporting tool for snapping accuracy/detours. |
| scripts/debug/area_mesh_stages.py | Adds visualization of meshing stages and ring-edge restoration. |
| include/storage/view_factory.hpp | Adds views/factory helpers for open-areas data and its R-tree. |
| include/storage/storage.hpp | Declares open-area R-tree layout population helper. |
| include/extractor/profile_properties.hpp | Adds area_walking_speed and area_emit_visibility_graph profile properties. |
| include/extractor/files.hpp | Adds .osrm.openareas read/write helpers; parameterizes ramIndex name for multiple RTrees. |
| include/extractor/extractor.hpp | Declares Extractor::WriteOpenAreas. |
| include/extractor/extractor_config.hpp | Registers open-areas files as optional extractor outputs. |
| include/extractor/area/area_mesher.hpp | Stores collector + profile-driven meshing parameters in AreaMesher. |
| include/extractor/area/area_data_collector.hpp | Declares AreaDataCollector and PolygonRecord. |
| include/extractor/area_routing_data.hpp | Defines on-disk/open-area R-tree leaf struct AreaPolygonSegment. |
| include/engine/plugins/plugin_base.hpp | Integrates inside-area snapping into candidate generation (with role handling). |
| include/engine/datafacade/mmap_memory_allocator.hpp | Stores open-area R-tree leaf-file path region name. |
| include/engine/datafacade/datafacade_base.hpp | Adds facade APIs for querying open areas and retrieving their rings. |
| include/engine/datafacade/contiguous_internalmem_datafacade.hpp | Loads open-areas views + R-tree and exposes them via BaseDataFacade overrides. |
| include/engine/area_visibility.hpp | Declares visibility/containment APIs and the projected Point type. |
| include/engine/area_snapping.hpp | Declares SnapInsideOpenArea and ApproachRole. |
| include/engine/api/route_api.hpp | Reports waypoints as routed by reordering candidates based on the used phantom. |
| features/foot/area_snapping.feature | Adds cucumber coverage for inside-area snapping across multiple plaza/obstacle shapes. |
| features/foot/area_mesh.feature | Adds scenarios ensuring meshing occurs with only two entrances (and not with one). |
| docs/areas.md | Updates documentation to describe whole-graph emission and ring-edge behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+225
to
+232
| if (isIndexed(index, "/common/open_areas/areas")) | ||
| { | ||
| std::tie(m_open_areas, | ||
| m_open_area_bbox_corners, | ||
| m_open_area_vertices, | ||
| m_open_area_ring_lengths) = make_open_areas_view(index, "/common/open_areas"); | ||
| m_open_area_rtree = make_open_area_tree_view(index, "/common/open_areas/rtree"); | ||
| } |
Comment on lines
+25
to
+41
| // Order by the node ids of the outer ring. The ring is a rotation-stable list of | ||
| // ids for a given area, so this is a property of the input rather than of the run. | ||
| const auto key = [](const PolygonRecord &r) | ||
| { | ||
| std::vector<osmium::object_id_type> ids; | ||
| ids.reserve(r.boundary_vertices.size()); | ||
| std::transform(r.boundary_vertices.begin(), | ||
| r.boundary_vertices.end(), | ||
| std::back_inserter(ids), | ||
| [](const osmium::NodeRef &n) { return n.ref(); }); | ||
| return ids; | ||
| }; | ||
|
|
||
| std::sort(m_polygons.begin(), | ||
| m_polygons.end(), | ||
| [&key](const PolygonRecord &a, const PolygonRecord &b) { return key(a) < key(b); }); | ||
| } |
Comment on lines
+240
to
+244
| if (!std::filesystem::exists(std::filesystem::path{path})) | ||
| { | ||
| throw util::exception("Could not load " + std::string(path) + "Does the leaf file exist?" + | ||
| SOURCE_REF); | ||
| } |
DennisOSRM
force-pushed
the
area-inside
branch
2 times, most recently
from
August 11, 2026 11:24
a55fabb to
722ab49
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #7684 +/- ##
==========================================
+ Coverage 94.36% 94.46% +0.10%
==========================================
Files 503 512 +9
Lines 39155 39823 +668
==========================================
+ Hits 36947 37620 +673
+ Misses 2208 2203 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
A coordinate that falls inside a meshed area used to snap to the nearest
meshed line, and the route then set off towards wherever that line went,
however little sense it made from where the request actually was.
It now snaps to the vertex of the area that makes the whole journey
shortest, walking there in a straight line -- the route the visibility
graph would have given if that coordinate had been part of it when the
graph was built. Measured over interior grids of seven fixtures, the
excess over that a-priori optimum falls from 479.8 m to 0.1 m, with
medians at zero throughout.
Extraction writes the polygons and an r-tree over their bounding boxes
to .osrm.openareas{,.ramIndex,.fileIndex}. The engine finds the area a
coordinate lies in, computes the vertices it can see, and offers one
phantom candidate per vertex with the walk charged to the search. Three
things had to change to carry that:
* An area candidate keeps only the direction that leaves its vertex.
endpointsFromCandidates matches a finished path back to its candidate
by segment id, and the two ends of one meshed way carry the same pair,
so without this the phantom reported back need not be the one the
search used -- which showed up as a zero duration and a negative
weight. It now also ignores a disabled direction, which says nothing
about where a path began.
* The waypoint reports the candidate the route actually set off from
rather than the first in the list. That was equivalent while every
candidate for a coordinate shared a location; area candidates are
spread across the plaza.
* The heap seeds a source with the negation of the phantom's offset and
a target with the value itself, so the walk is subtracted in one case
and added in the other. The plugin knows which end of the journey a
coordinate is and says so.
Two defects in the meshing itself surfaced along the way and are fixed
here:
* A plaza entered twice from the same side was not meshed at all.
get_entry_points required three incident ways where its own comment
said two, so the two entrances were left unconnected.
* The ring edges were not emitted reliably. The rotational sweep never
reports a vertex's own neighbours, and the entry-point pruning keeps a
ring edge only if some entry-to-entry path ran along it -- on a plaza
with a central obstacle none of the obstacle's four edges survives and
two of its corners carry no edges at all. So the perimeter of a plaza
and the sides of an obstacle were unwalkable. Both meshing modes now
emit them, which also halves what the pruning gets wrong.
The mesher's two modes are selected by area_emit_visibility_graph, which
defaults to the whole graph. The pruning remains available and preserves
every entry-to-entry route exactly, for a mesh up to an order of
magnitude smaller.
Also fixes a crash in MMapMemoryAllocator, which registers the string
returned by PopulateLayoutWithRTree as an entire memory region with its
single block at offset zero; the area r-tree's leaf path needs a region
and a string of its own.
scripts/debug/area_snapping_report.py measures and draws the fixtures;
scripts/debug/area_mesh_stages.py draws what each meshing stage adds and
removes.
DennisOSRM
force-pushed
the
area-inside
branch
from
August 11, 2026 13:09
722ab49 to
cb9fb70
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of three PRs building on #7161, which taught the extractor to mesh a pedestrian area.
That mesh was only reachable from the entry points where a footway meets the perimeter. This
one lets a coordinate that falls inside an area be routed from and to.
3071 lines, but only 1191 of them are engine and extractor code. The rest:
src+includescripts/debug/, 2 Python scripts)The tooling draws what the mesher and the snapper did as SVG, and is what substantiates the
numbers below. It is worth having in the tree, but it is not engine code and does not need to
be read as such.
What it does
Today a coordinate in the middle of a plaza snaps to whatever way happens to be nearest,
which may be on the far side of a building. After this it snaps to the mesh vertex from which
the rest of the journey is cheapest, and the walk from the coordinate to that vertex is
charged to the route.
Four parts:
Write the areas at extraction. A new
.osrm.openareasholds the polygon of every meshedarea with its rings, plus an r-tree over their bounding boxes so the engine can ask which
areas contain a point. Nothing else about extraction changes.
Always emit the ring edges. A bug in its own right, independent of the rest: the perimeter
of an area is not routable by itself, because the profile hands the closed way to the area
code and returns. Without the ring edges in the mesh you cannot walk along the edge of a plaza
or round a fountain. Both the full and the pruned mesh now get them.
Snap inside an area.
SnapInsideOpenAreabuilds a candidate per mesh vertex visible fromthe coordinate, charging the straight-line walk. A candidate keeps only the direction that
leaves its vertex, since arriving at a vertex and then having to leave the way you came is
not a journey anyone wants.
Report the waypoint the route used.
endpointsFromCandidatesmatched a path back to itscandidate by segment id alone and could pick a disabled one; it now requires the candidate to
be enabled, and
waypointsAsRoutedreports the location the route actually started from.Numbers
On a 400x400 m plaza with four entrances and two obstacles, 390 interior points against all
four exits, the snapped route is within 0.1 m of the true shortest path through the
polygon, worst case over all 1560 pairs.
What it does not do
A journey with both ends inside one area is not handled here; it is the subject of the
next PR. Known defects and deferred review points are tracked in #7683.
Tests
10 cucumber scenarios in
features/foot/area_snapping.feature, asserting encoded geometryrather than node lists, so they do not depend on which algorithm answered. Unit tests cover
the visibility computation, the serialisation round trip, and the mesher's ring edges.
Written with AI assistance: Claude Code, Claude Opus 5 🤖
Two corrections since this was opened
CI's
clang-20-debug-covjob builds with assertions on and caught both.A via point cannot be charged. The walk is folded into the phantom's weight offset, and the search seeds a source with the negation of that offset and a target with the offset itself. A coordinate in the middle of a route is both, so charging it as a departure makes the leg arriving there seed a negative key, which CH asserts against. A via point is now charged nothing.
An arrival stands at the end of an edge-based node, not the start. A departure candidate has to begin at the vertex, so that travelling it leaves the vertex. An arrival is the mirror image and was getting the departure treatment, which made a leg contained in one segment report
"weight": -36on a 50 m walk. One phantom answers both, since sitting at a segment's first node means carrying a weight of zero forwards and the whole of the segment in reverse.The second changes which candidate a route matches back to, so two scenarios now report their terminal node ids in travel order (
earather thanae, which is the correct order) and a third asserts geometry instead, because the node list at the ends of a leg is not stable (#7683).