Skip to content

Load bus stops in chunks so long routes stop timing out#4

Merged
dizzafizza merged 1 commit into
mainfrom
claude/fork-code-review-33fkom
Jul 14, 2026
Merged

Load bus stops in chunks so long routes stop timing out#4
dizzafizza merged 1 commit into
mainfrom
claude/fork-code-review-33fkom

Conversation

@dizzafizza

Copy link
Copy Markdown
Owner

Summary

Bus stops weren't loading (or took too long) on longer routes. The corridor was sent to Overpass as one all-or-nothing query that embedded the coordinate string four times (roads + three separate bus-stop tag clauses). On long routes that regularly exceeded the 25s server timeout, and because the failure was swallowed, every bus stop and speed limit was silently lost. The 700-point corridor cap also widened point spacing past the 90m search radius on very long routes, cutting corners past stops even when the query did succeed.

Changes

  • Split the route corridor into independent chunks (~12km each, two in flight at a time) instead of one mega-query — each chunk is small and fast enough to finish well inside its own timeout.
  • Bus stops now stream onto the map progressively as each chunk lands (onPartialBusStops callback), instead of only appearing after the whole route finishes processing.
  • A failed chunk only loses its own stretch of road/stops instead of the entire route; failures are logged instead of silently swallowed.
  • Collapsed the three separate bus-stop tag clauses (highway=bus_stop, public_transport=platform, public_transport=stop_position) into a single regex clause — one corridor pass server-side instead of three, with exact filtering kept client-side in tagsDescribeBusStop.
  • Deduplicated results across chunk seams by OSM element id, and merged bus stops that are mapped twice a few meters apart (platform + stop_position nodes) so markers and dwell stops aren't doubled.
  • Corridor spacing now stays within the search radius up to ~285km of route (24 chunks × 160 points) instead of degrading past ~50km.

Testing

  • Verified the exact generated query shape against the live Overpass API: HTTP 200 in ~2s, response fields (element ids, way geometry, node lat/lon) match the Swift decoder's assumptions, and the collapsed regex clause correctly returns both legacy (highway=bus_stop) and modern (public_transport schema) stops.
  • Confirmed the change compiles and archives successfully via the Build Debug IPA CI workflow on this branch.
  • Tested on device
  • Tested with fresh pairing file

Screenshots

N/A — backend data-fetching change, no UI changes.


Generated by Claude Code

The route corridor was sent to Overpass as one all-or-nothing query that
embedded the coordinate string four times (roads + three bus-stop tag
clauses). On long routes that regularly exceeded the 25s server timeout,
and because the caller swallowed errors, every bus stop and speed limit
was silently lost — exactly the 'stops never load' failure. The 700-point
corridor cap also widened point spacing far beyond the 90m search radius
on very long routes, cutting corners past stops even when the query
succeeded.

Rework the fetch into independent corridor chunks (~12km each, two in
flight, per-chunk timeouts):

- Each chunk is a small, fast request; a failed chunk only loses its own
  stretch instead of the whole route, and failures are logged.
- Bus stops stream onto the map as chunks arrive via an
  onPartialBusStops callback instead of appearing only at the end.
- The three bus-stop tag clauses are collapsed into one regex clause
  (a single corridor pass server-side); exact filtering stays client-side
  in tagsDescribeBusStop.
- Results are deduplicated across chunk seams by OSM element id, and
  stops mapped twice (platform + stop_position a few meters apart) are
  merged spatially so markers and dwells aren't doubled.
- Corridor spacing now stays within the search radius up to ~285km of
  route (24 chunks x 160 points) instead of degrading past ~50km.

Verified the exact generated query shape against the live Overpass API:
HTTP 200 in ~2s, element ids/geometry/lat-lon match the decoder, and the
regex clause returns both legacy and public_transport-schema stops.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013DNqCsHShA4yNqgZ6ZZQy3
@dizzafizza
dizzafizza merged commit f81e666 into main Jul 14, 2026
2 checks passed
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