Skip to content

fix: stop direction parity with Java reference#1092

Merged
burma-shave merged 2 commits into
mainfrom
fix/stop-direction-parity
Jun 29, 2026
Merged

fix: stop direction parity with Java reference#1092
burma-shave merged 2 commits into
mainfrom
fix/stop-direction-parity

Conversation

@Ahmedhossamdev

Copy link
Copy Markdown
Member

Fixes: #1091

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 synthesized shape_dist_traveled, which the feed lacks). This fix improves every stop-direction-bearing endpoint, not just this one.

Compute the bearing over the single shape segment the stop lies on (matching
Java's DistanceTraveledShapePointIndex) instead of a wide ±5-point chord, and
drop the cos(latitude) longitude scaling Java does not apply. This brings stop
directions to 272/275 parity with the Java reference on unitrans (was 160/275).

Affects every endpoint that returns a stop direction, not just stops-for-agency.
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Ahmedhossamdev, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 19 minutes and 17 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ba69c0b3-319b-49f8-ba4d-c03b1d20799d

📥 Commits

Reviewing files that changed from the base of the PR and between 99e138d and 7ce20c2.

📒 Files selected for processing (1)
  • internal/gtfs/advanced_direction_calculator.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/stop-direction-parity

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 and usage tips.

@github-actions

Copy link
Copy Markdown

Performance Smoke Test Results

Status: PASSED

Metric Value
p(95) latency 1.8 ms
Error rate 0.00%
Total requests 336
Req/sec 11.0

Smoke test config: 5 VUs x 30s. Thresholds: p(95) < 300ms, error rate < 1%.

Full results uploaded as workflow artifact: k6-smoke-summary.

@burma-shave burma-shave left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just needs some tests

@Ahmedhossamdev

Copy link
Copy Markdown
Member Author

Done @burma-shave

@github-actions

Copy link
Copy Markdown

Performance Smoke Test Results

Status: PASSED

Metric Value
p(95) latency 2.1 ms
Error rate 0.00%
Total requests 326
Req/sec 10.8

Smoke test config: 5 VUs x 30s. Thresholds: p(95) < 300ms, error rate < 1%.

Full results uploaded as workflow artifact: k6-smoke-summary.

@burma-shave burma-shave merged commit 7db6201 into main Jun 29, 2026
7 checks passed
@burma-shave burma-shave deleted the fix/stop-direction-parity branch June 29, 2026 22:53
@sonarqubecloud

Copy link
Copy Markdown

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.

spec-gap: stop direction diverges from Java reference (~41% of stops)

2 participants