feat: honor client-requested plan parameters (maxResults, maxWalkDistance) - #4
Open
guss1215 wants to merge 2 commits into
Open
feat: honor client-requested plan parameters (maxResults, maxWalkDistance)#4guss1215 wants to merge 2 commits into
guss1215 wants to merge 2 commits into
Conversation
The handler hardcoded maxResults: 5, so clients could never receive more route alternatives. Read maxResults from the request body (clamped 1-20, default 20) and forward it to the routing service, also lifting the per-bucket caps (maxDirects/maxTransferPaths) to the same value so the requested count is actually reachable. The bucket params need the trufi_core_planner v5.16.0 pin already in pubspec.yaml (pubspec.lock is untracked, so deploys resolve it fresh). Documented the new body field in the OpenAPI spec. Verified against the example GTFS: a dense Cochabamba pair now returns 20 paths by default (was 5), explicit values are honored, and out-of-range values clamp.
guss1215
force-pushed
the
feat/honor-client-max-results
branch
from
July 20, 2026 03:31
a908c80 to
026564c
Compare
This was referenced Jul 20, 2026
…#926) The walk radius was hardcoded to 500 m, hiding direct lines boardable a few blocks away and forcing transfer-heavy results. Read maxWalkDistance from the request body (clamped 100-2000 m, default 800) and forward it. Verified against the example GTFS: an origin/destination pair that returned 0 paths at 500 m returns a route at the 800 m default; explicit values are honored and out-of-range values clamp. trufi-core's RemotePlannerClient sends the field as of trufi-association/trufi-core#934. The stop-candidate widening from that PR (maxStopCandidates) reaches this server automatically once the trufi_core_planner pin advances past v5.16.0.
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.
Server side of trufi-association/trufi-core#923 (raise displayed routes; client PR: trufi-association/trufi-core#932) — the handler hardcoded
maxResults: 5, so web clients could never receive more route alternatives regardless of what they asked for.What
POST /api/plannow readsmaxResultsfrom the request body (clamped 1–20, default 20) and forwards it to the routing service.maxDirects/maxTransferPaths) to the same value so the requested count is actually reachable — with the old caps at 5, asking for more still returned at most 5 because direct routes suppress transfers.The bucket params require the
trufi_core_plannerv5.16.0 pin already inpubspec.yaml(pubspec.lockis untracked, so deployments resolve it fresh).Verified against the bundled example GTFS
A dense Cochabamba pair (
-17.3936,-66.1571 → -17.3735,-66.1590):maxResults(old clients)maxResults: 5maxResults: 50Trufi-core's
RemotePlannerClientstarts sendingmaxResultsin trufi-association/trufi-core#932; older clients simply get the new default of 20.