Skip to content

fix(stops-for-location): send the longitude span as lonSpan - #612

Open
omlahore wants to merge 1 commit into
OneBusAway:developfrom
omlahore:fix/stops-for-location-lonspan
Open

fix(stops-for-location): send the longitude span as lonSpan#612
omlahore wants to merge 1 commit into
OneBusAway:developfrom
omlahore:fix/stops-for-location-lonspan

Conversation

@omlahore

@omlahore omlahore commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

What this fixes

/api/oba/stops-for-location forwards the client's lngSpan straight through to the SDK (+server.js#L8-L18):

const lngSpan = +url.searchParams.get('lngSpan');
const queryParams = { lat, lon: lng, latSpan, lngSpan, radius };

The SDK's parameter is lonSpan, declared in onebusaway-sdk/resources/stops-for-location.d.ts:

latSpan?: number;
...
lonSpan?: number;

lngSpan is not a parameter it knows, so the longitude span was dropped and the request fell back to the default window.

How it shows up

MapView sends a real span computed from the visible bounding box (MapView.svelte#L192):

`/api/oba/stops-for-location?lat=${lat}&lng=${lng}&latSpan=${boundingBox.north - boundingBox.south}&lngSpan=${boundingBox.east - boundingBox.west}&radius=1500`

So on a wide viewport the east-west extent the user can see is wider than the window actually queried, and stops near the left and right edges are missing from the map.

The rest of the codebase already uses lonSpan (serverCache.test.js, mathUtils.test.js), which is what makes this one the outlier.

Change

One line, keeping the existing lng to lon mapping style in the same object:

lonSpan: lngSpan,

The client keeps sending lngSpan; only the name handed to the SDK changes.

Test

New src/tests/api/stops-for-location.test.js asserts the SDK receives lonSpan. On unmodified develop:

× forwards the client lngSpan as the SDK lonSpan
  → expected undefined to be 0.05

Passes with the change. Prettier clean.

Unrelated note: src/tests/lib/dateTimeFormat.test.js fails locally for me on develop too, expecting 9:15 AM where an en-IN locale renders 9:15 am. Not touched here.

Summary by CodeRabbit

  • Bug Fixes

    • Corrected location-based transit stop searches so longitude span parameters are properly handled, improving result accuracy.
  • Tests

    • Added coverage to verify that longitude span requests are forwarded correctly to the transit service.

MapView requests stops for the visible bounding box with lngSpan, and the
endpoint forwarded that name straight to the SDK. The SDK parameter is
lonSpan, so the longitude span was dropped and the query fell back to the
default window.
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: e6bc1f76-3234-4807-94cd-148e41b8b160

📥 Commits

Reviewing files that changed from the base of the PR and between 6c5adb0 and 23d02b8.

📒 Files selected for processing (2)
  • src/routes/api/oba/stops-for-location/+server.js
  • src/tests/api/stops-for-location.test.js

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The stops-for-location OBA route now sends the parsed lngSpan query value as lonSpan. A new test verifies the mapping and confirms that lngSpan is not forwarded to the SDK.

Changes

OBA stops-for-location query

Layer / File(s) Summary
Longitude span mapping and validation
src/routes/api/oba/stops-for-location/+server.js, src/tests/api/stops-for-location.test.js
The route uses the OBA SDK's lonSpan parameter. The test mocks route dependencies and verifies the forwarded parameters.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 23d02

Stops-for-location requests now preserve the map’s longitude span when calling OBA, preventing edge stops from being omitted in wide map views. The corrected parameter mapping is covered by a focused regression test.

🚥 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: mapping the longitude span to the SDK's expected lonSpan parameter.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage is 93.534%omlahore:fix/stops-for-location-lonspan into OneBusAway:develop. No base build found for OneBusAway:develop.

@aaronbrethorst

Copy link
Copy Markdown
Member

Code review

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

🤖 Generated with Claude Code

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.

3 participants