fix: stops-for-agency spec: 404, stop direction parity, code fallback, parent station#1078
fix: stops-for-agency spec: 404, stop direction parity, code fallback, parent station#1078Ahmedhossamdev wants to merge 1 commit into
Conversation
… parent station references, fix direction calculations bugs
|
Caution Review failedAn error occurred during the review process. Please try again later. 📝 WalkthroughWalkthroughTwo independent fixes: (1) ChangesStop Orientation Algorithm Refactor
Stops-for-Agency Handler Fixes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Performance Smoke Test ResultsStatus: PASSED
Smoke test config: 5 VUs x 30s. Thresholds: p(95) < 300ms, error rate < 1%. Full results uploaded as workflow artifact: k6-smoke-summary. |
|
@coderabbitai review |
✅ Action performedReview finished.
|



Fixes: #986, #1077
Description
Fixes four spec gaps in
/api/where/stops-for-agency, verified against the live Java reference server (unitrans).stop-ids-for-agencywas already compliant.1. Unknown agency → 404
Was returning HTTP 200 +
null. The spec's Implementation Decisions mandate 404 (correcting the legacy Java defect), andstop-ids-for-agencyalready did this. Fixed + updated the test that asserted 200.2. Stop
directionparity (112 → 3 mismatches)Direction is computed from shape geometry. maglev diverged from Java on 41% of stops because it measured the bearing over a wide ±5-point chord; Java uses the single shape segment the stop lies on. Also dropped a
cos(latitude)longitude correction that Java doesn't apply. Now matches Java on 272/275 stops; the remaining 3 are threshold/compass-boundary edge cases (Java projects via synthesizedshape_dist_traveled, which the feed lacks). This fix improves every stop-direction-bearing endpoint, not just this one.3.
codefallbackNow falls back to the entity ID when the feed defines no stop code (matching the single-stop handler and spec).
4.
parent+ parent-station referencesparentis now populated, and parent stations are resolved intoreferences.stops(spec Extension 3a).All tests + lint pass.
Note: directions are precomputed at GTFS load — rebuild the DB (delete
gtfs.db) and restart to see the direction fix live.Summary by CodeRabbit
Bug Fixes
/stops-for-agencyendpoint now returns proper 404 error for invalid agencies.New Features
/stops-for-agencyendpoint now includes parent station information in responses.