Skip to content

feat: honor client-requested plan parameters (maxResults, maxWalkDistance) - #4

Open
guss1215 wants to merge 2 commits into
trufi-association:mainfrom
guss1215:feat/honor-client-max-results
Open

feat: honor client-requested plan parameters (maxResults, maxWalkDistance)#4
guss1215 wants to merge 2 commits into
trufi-association:mainfrom
guss1215:feat/honor-client-max-results

Conversation

@guss1215

@guss1215 guss1215 commented Jul 20, 2026

Copy link
Copy Markdown

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/plan now reads maxResults from the request body (clamped 1–20, default 20) and forwards it to the routing service.
  • Also lifts the per-bucket caps (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.
  • Documents the new body field in the OpenAPI spec.

The bucket params require the trufi_core_planner v5.16.0 pin already in pubspec.yaml (pubspec.lock is untracked, so deployments resolve it fresh).

Verified against the bundled example GTFS

A dense Cochabamba pair (-17.3936,-66.1571 → -17.3735,-66.1590):

request paths returned
no maxResults (old clients) 20 (was 5)
maxResults: 5 5
maxResults: 50 20 (clamped)

Trufi-core's RemotePlannerClient starts sending maxResults in trufi-association/trufi-core#932; older clients simply get the new default of 20.

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.
…#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.
@guss1215 guss1215 changed the title feat: honor client-requested maxResults in /api/plan feat: honor client-requested plan parameters (maxResults, maxWalkDistance) Jul 21, 2026
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.

1 participant