Skip to content

feat(area): answer tables and trips across a plaza the same way as routes - #7686

Merged
DennisOSRM merged 1 commit into
masterfrom
area-services
Aug 11, 2026
Merged

DennisOSRM merged 1 commit into
masterfrom
area-services

Conversation

@DennisOSRM

@DennisOSRM DennisOSRM commented Aug 11, 2026 •

Copy link
Copy Markdown
Collaborator

#7684 and #7685 have merged, so this now targets master and is its own single commit.

#7685 made /route work out the real path when both ends of a leg lie on one plaza. /table
and /trip did not, so the three services disagreed about the same journey. 243 lines,
including the tests.

Table. Any cell whose two coordinates lie in one area is rewritten, in both the duration
and the distance matrix. There is nothing to draw here, a table is numbers, so that is the
whole of it. One area lookup per row short-cuts the common case of a table nowhere near an
area.

Trip. Two places, because a trip does two things: the duration matrix it picks its tour
from, so the tour is chosen from the real costs, and the route it draws afterwards, through
the same path /route takes. TripPlugin::ComputeRoute now takes its candidates by
non-const reference, since the legs run in tour order and the waypoints they answer to are the
original candidates picked out in that order.

On a plaza with a central obstacle and one pair of interior points either side of it, the
three now agree:

distance duration
/route 386.5 m 276.1 s
/table 386.5 m 276.0 s
/trip, roundtrip 773.0 m

773.0 being twice 386.5, and the trip reporting the coordinates that were asked for rather
than the vertices they snapped to.

Two faults this exposes without fixing

Both predate this change and are in #7683. They are described here because wiring the table is
what made them visible.

A coordinate in a table is a source and a destination. The walk into an area is charged to
the phantom's weight offset, and the sign depends on which end of the journey the coordinate
is. That works for a route. In a table, coordinate 0 is the source of row 0 and the
destination of column 0, so one of the two is charged the wrong way round. The fix is to carry
the approach cost on the phantom instead, which grows PhantomNode from 80 to 84 bytes and
the public hint string from 112 to 120 characters, so it wants its own PR.

A trip whose coordinates all snap to one vertex reports 0 m. On an empty plaza several
coordinates can share a cheapest way out. The search over identical candidate sets returns a
result with no legs, and there is then nothing for the geodesic pass to correct.

Tests

features/foot/area_table_trip.feature, three scenarios: a distance and a time table across a
plain plaza, a distance table either side of an obstacle (311.8 m, the way round, not the
300 m straight line), and a trip round three points. Nothing asserts a pair with one end off
the plaza, or a trip whose points all snap together; pinning either would bless the wrong
answer.

Written with AI assistance: Claude Code, Claude Opus 5 🤖

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the open-area “geodesic override” (used to make /route agree with the true within-plaza path) to /table and /trip, so all three services return consistent distance/duration results when both endpoints of a leg/cell lie inside the same open area.

Changes:

  • Add area::useGeodesicInTable(...) and invoke it from /table and /trip to rewrite within-area matrix cells.
  • Refactor area::useGeodesicWhereShorter(...) to work from route leg endpoint phantoms and to optionally adjust reported waypoints via pointers.
  • Add cucumber coverage for foot tables and trips across open areas.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/engine/plugins/viaroute.cpp Updates /route to pass waypoint-candidate pointers into the geodesic override helper.
src/engine/plugins/trip.cpp Applies geodesic correction both to the duration matrix used for tour selection and to the drawn route legs.
src/engine/plugins/table.cpp Applies geodesic correction to duration/distance tables for within-area coordinate pairs.
src/engine/area_route.cpp Refactors useGeodesicWhereShorter waypoint reporting and adds useGeodesicInTable implementation.
include/engine/plugins/trip.hpp Updates ComputeRoute signature to allow waypoint candidate mutation for correct reporting.
include/engine/area_route.hpp Updates useGeodesicWhereShorter signature and declares useGeodesicInTable.
features/foot/area_table_trip.feature Adds cucumber scenarios validating corrected tables and trips across plazas/obstacles.
Suppressed comments (2)

src/engine/area_route.cpp:353

  • useGeodesicInTable does an GetOpenAreasAt(from) lookup per row, but then calls commonArea(facade, from, to) per cell, which repeats GetOpenAreasAt(from) (and sorts) for every column. This negates the intended row-level short-circuit and can become expensive for larger tables. Consider reusing the row’s from areas and only looking up areas for to inside the inner loop.
        const auto from = coordinates[sources.empty() ? row : sources[row]];
        // one lookup for the whole row: a table over one plaza asks about the same area
        // again and again
        if (facade.GetOpenAreasAt(from).empty())
        {

src/engine/area_route.cpp:344

  • useGeodesicInTable validates durations.size() but, when distances is non-empty, it writes distances[cell] without verifying that distances.size() matches rows*columns. If a caller passes a non-empty but mismatched distances vector, this can go out of bounds. Consider adding a symmetric size check for distances (when present).
    const auto rows = sources.empty() ? coordinates.size() : sources.size();
    const auto columns = destinations.empty() ? coordinates.size() : destinations.size();
    if (durations.size() != rows * columns)
    {
        return;

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/engine/area_route.cpp
return std::nullopt;
}

/** Say that a waypoint is where it was asked for, when the caller is tracking waypoints. */
# same answer as /route or the three services contradict each other.
#
# Only pairs with *both* ends on the plaza are asserted here. A pair with one end on
# it is a separate matter and is not yet right -- see plans/area-table-trip.md.
@DennisOSRM
DennisOSRM force-pushed the area-geodesic branch 2 times, most recently from 1b93bc2 to 758d0d2 Compare August 11, 2026 13:54
Base automatically changed from area-geodesic to master August 11, 2026 14:55
…utes

/route works out the geodesic when both ends of a leg lie on one plaza,
because the mesh holds shortest paths *out* of an area and such a journey
never leaves. /table and /trip did not, so the three services disagreed
about the same journey.

Table needs only the numbers put right: useGeodesicInTable rewrites any
cell whose two coordinates lie in one area, in both matrices. There is no
route to synthesise. One area lookup per row short-cuts the ordinary case
of a table over coordinates nowhere near a plaza.

Trip needs both halves of what it does: the duration matrix it picks its
tour from, so the tour is chosen from real costs, and the route it draws
afterwards, through the same code /route uses. Its legs run in tour
order, so the waypoints they answer to are the original candidates picked
out in that order.

On a plaza with a central obstacle, two interior points either side of
it: /route 386.5 m and 276.1 s, /table 386.5 m and 276.0 s, /trip 773.0 m
there and back.

useGeodesicWhereShorter now takes the coordinates from the phantoms it
was given rather than a parallel vector, since trip's legs are not in
parameter order, and takes its waypoints as pointers so a caller that has
none can say so.

Two faults this made visible are described in plans/area-table-trip.md
and are not addressed here:

* a coordinate in a table is a source *and* a destination, while the walk
  across an area is charged to the phantom with a sign that depends on
  which it is. The row comes out right and the column wrong. It predates
  this change -- the same numbers come out with it stashed -- and fixing
  it means carrying the approach cost on the phantom rather than folding
  it into an offset, which changes the length of the public hint string.

* three coordinates on a plain plaza can all snap to one vertex, and the
  search over identical candidates returns a route with no legs at all,
  which leaves nothing to rewrite and a tour of 0 m.

features/foot/area_table_trip.feature accordingly asserts only pairs with
both ends on one plaza, and a trip fixture shaped to avoid the degenerate
case; pinning the others would bless a wrong answer.
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.46%. Comparing base (e96fe52) to head (f96a813).

Files with missing lines Patch % Lines
src/engine/area_route.cpp 88.57% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7686      +/-   ##
==========================================
- Coverage   94.47%   94.46%   -0.01%     
==========================================
  Files         516      516              
  Lines       40336    40379      +43     
==========================================
+ Hits        38106    38146      +40     
- Misses       2230     2233       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DennisOSRM
DennisOSRM merged commit b04fc7b into master Aug 11, 2026
23 of 24 checks passed
@DennisOSRM
DennisOSRM deleted the area-services branch August 11, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants