Skip to content

Search stop numbers across the full region (#1432) - #1437

Merged
aaronbrethorst merged 1 commit into
OneBusAway:mainfrom
Borisserz:fix/1432-stop-number-disambiguation
Sep 20, 2026
Merged

aaronbrethorst merged 1 commit into
OneBusAway:mainfrom
Borisserz:fix/1432-stop-number-disambiguation

Conversation

@Borisserz

@Borisserz Borisserz commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Closes No disambiguation step for duplicated stop numbers #1432: iOS skipped the disambiguation sheet when two agencies share a stop code.
  • Root cause: stop-number search used getStops(circularRegion:query:), which caps radius at 15 km, so remote same-code stops never appeared (Android / span queries return both).
  • Stop-number lookup now uses getStops(region:query:) with latSpan/lonSpan over the region's serviceRect. Existing disambiguation UI already handles results.count > 1.

Test plan

  • NetworkHelperTests — span+query URL has no radius=
  • SearchManagerTests — stop-number search sends latSpan/lonSpan + query
  • Manual (Puget Sound): search stop code 1000 → disambiguation list with both agencies (not auto-open the downtown hit)

Summary by CodeRabbit

  • Bug Fixes

    • Stop-number searches now cover the full service area instead of being limited to a 15 km radius.
    • Searches can find stops across wider agency regions, improving results when the requested stop is far from the map’s center.
  • Tests

    • Added coverage to verify regional stop searches use the complete service span and return the expected search parameters.

The circular stops-for-location path capped radius at 15 km, so same-code
stops at distant agencies never reached disambiguation (OneBusAway#1432).
@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 2c476db1-fc5d-4dda-964a-efbb56c17797

📥 Commits

Reviewing files that changed from the base of the PR and between 3fa4b01 and 15d5fbd.

📒 Files selected for processing (5)
  • OBAKit/Search/SearchRequest.swift
  • OBAKitCore/Network/RESTAPIService/RESTAPIService+Get.swift
  • OBAKitCore/Network/RESTAPIURLBuilder.swift
  • OBAKitTests/Networking/Helper Tests/NetworkHelperTests.swift
  • OBAKitTests/Search/SearchManagerTests.swift

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

Stop-number searches now use the full service rectangle instead of a circular 15 km radius. The API service and URL builder support region-based stop lookup. Tests verify span-based requests and duplicated stop-number coverage.

Changes

Stop-number search

Layer / File(s) Summary
Region-based stop lookup
OBAKitCore/Network/RESTAPIURLBuilder.swift, OBAKitCore/Network/RESTAPIService/RESTAPIService+Get.swift, OBAKitTests/Networking/Helper Tests/NetworkHelperTests.swift
Adds region-based stop URL construction and REST API retrieval with latSpan and lonSpan parameters. Tests verify that the request does not use radius.
Stop-number search integration
OBAKit/Search/SearchRequest.swift, OBAKitTests/Search/SearchManagerTests.swift
Updates fetchStopNumber to query the full service rectangle. Regression tests verify the stop code, span parameters, and absence of radius.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: aaronbrethorst, mosliem

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: stop-number searches now cover the full region.
Linked Issues check ✅ Passed The change satisfies #1432. SearchManager.fetchStopNumber now queries MKCoordinateRegion(serviceRect) instead of the 15 km circular region. The new URL builder sends latSpan and lonSpan with t…
Out of Scope Changes check ✅ Passed The pull request changes only stop-number search, the supporting REST API and URL-builder methods, and regression tests for #1432. The comments and documentation explain the required regional search b…
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 5 files.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@aaronbrethorst

Copy link
Copy Markdown
Member

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@aaronbrethorst aaronbrethorst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a well-diagnosed fix. The root cause is exactly right — the circular overload clamps radius to 15 km, so a same-code stop at a distant agency in the same region could never reach the disambiguation sheet — and switching to latSpan/lonSpan over the region's service rect is the correct answer rather than just raising the cap.

I checked the parts that matter: both result consumers already branch on results.count > 1 (MapRegionManager.searchResponse and SearchSheetViewModel.SearchOutcome), so the fix lands on the UIKit and SwiftUI paths alike, and the new SearchManagerTests case asserts radius == nil alongside a non-nil latSpan, which means it genuinely fails against the old code instead of just documenting the new. The inline comments pointing at #1432 are the right amount of explanation.

One small thing if you're back in this file: getStops(region:query:) is a byte-for-byte copy of getStops(region:) plus one parameter, and a single method with query: String? = nil would collapse the duplication in both the builder and RESTAPIService+Get. The new doc comment also drops the - important: subset/zoom-in caveat its two siblings carry, which arguably matters more now that the span can cover an entire region.

Merging.

@aaronbrethorst
aaronbrethorst merged commit d5b09f5 into OneBusAway:main Sep 20, 2026
4 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.

No disambiguation step for duplicated stop numbers

2 participants