Skip to content

Focus vehicles on exact trip geometry and stops#1893

Merged
bmander merged 4 commits into
mainfrom
agent/trip-focus-geometry
Jul 16, 2026
Merged

Focus vehicles on exact trip geometry and stops#1893
bmander merged 4 commits into
mainfrom
agent/trip-focus-geometry

Conversation

@bmander

@bmander bmander commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • render a selected vehicle's exact ordered trip geometry instead of the heterogeneous route-direction union
  • narrow focused stops to the selected trip's schedule
  • retain the broader route-direction as a thin, non-directional underlay
  • keep sibling stop-focus routes beneath the exact trip and use the trip shape for route framing
  • resolve shape and schedule data on selection, including the fast-tap case before background prefetch completes

Why

A selected vehicle previously added its extrapolation and continuation overlays while leaving the route-direction geometry and stops in place. One direction can combine substantially different trip patterns, so the displayed line could diverge from the tracked trip and make a continuation appear to branch from the middle of the route.

Impact

Vehicle focus now follows the actual trip path and scheduled stops. Riders retain route and stop-focus context through thin underlays, while the selected trip remains visually dominant.

Validation

  • ./gradlew :onebusaway-android:testObaGoogleDebugUnitTest --tests 'org.onebusaway.android.map.*'
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Vehicle selections now display the exact trip path with clearer route highlighting.
    • Selected trips show stops in their scheduled order.
    • Map framing and route badges update to reflect the selected trip.
  • Bug Fixes

    • Improved stop placement and route geometry when viewing a selected vehicle trip.
    • Preserved surrounding route context while emphasizing the selected trip.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@bmander, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 seconds

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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 reviews.

How do review limits work?

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

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, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d59de4e8-0a7d-41b6-bcf9-5c56c24f3906

📥 Commits

Reviewing files that changed from the base of the PR and between a1be069 and 2a3b3a1.

📒 Files selected for processing (3)
  • onebusaway-android/src/main/java/org/onebusaway/android/map/RouteMapController.kt
  • onebusaway-android/src/main/java/org/onebusaway/android/map/RouteViewGeometry.kt
  • onebusaway-android/src/test/java/org/onebusaway/android/map/RouteViewGeometryTest.kt
📝 Walkthrough

Walkthrough

Selected vehicle trips now load exact trip geometry and scheduled stops, project stops onto that geometry, and render focused route polylines, badges, framing, and stop presentations.

Changes

Selected trip presentation

Layer / File(s) Summary
Trip data and stop projection
onebusaway-android/src/main/java/org/onebusaway/android/map/RouteMapController.kt, onebusaway-android/src/main/java/org/onebusaway/android/map/RouteMapRepository.kt, onebusaway-android/src/test/java/org/onebusaway/android/map/RouteDirectionFocusTest.kt
Adds selected-trip presentation data, schedule-ordered stop lookup, generalized polyline projection, and tests for schedule ordering and missing or duplicate stop IDs.
Selection loading and map rendering
onebusaway-android/src/main/java/org/onebusaway/android/map/RouteMapController.kt, onebusaway-android/src/main/java/org/onebusaway/android/map/RouteViewGeometry.kt
Loads selected-trip shape and schedule data, then renders exact trip geometry with route underlays, updated framing, badges, and selected-trip stops.
Focused geometry validation
onebusaway-android/src/test/java/org/onebusaway/android/map/RouteViewGeometryTest.kt
Verifies selected-direction shapes are replaced by the selected-trip polyline with the expected order, widths, directional flags, and object identity.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant VehicleSelection
  participant RouteMapController
  participant TripObservationRepository
  participant MapRenderState
  VehicleSelection->>RouteMapController: select trip ID
  RouteMapController->>TripObservationRepository: load exact shape and schedule
  TripObservationRepository-->>RouteMapController: return selected trip data
  RouteMapController->>MapRenderState: publish focused polylines and stops
Loading

Possibly related PRs

🚥 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 matches the PR’s main change: focusing selected vehicles on exact trip geometry and scheduled stops.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
  • Commit unit tests in branch agent/trip-focus-geometry

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.

@bmander
bmander marked this pull request as ready for review July 16, 2026 17:34

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@onebusaway-android/src/main/java/org/onebusaway/android/map/RouteMapController.kt`:
- Around line 613-615: Update the selectedRouteUnderlay branch in
RouteMapController to derive the underlay from
routeShape.shapeForDirection(selectedRoute.directionId) rather than
basePolylines, using the selected trip’s direction; preserve emptyList() when no
trip is selected and apply the existing deemphasized underlay transformation to
the direction-specific shape.
- Around line 678-680: Update selectedTripPresentation() so it returns null
unless both state?.polyline?.points and state?.schedule?.stopTimes are present;
only construct SelectedTripPresentation after both resources resolve, rather
than converting missing data with orEmpty(). Preserve the existing mapping for
non-null shape and schedule data so the base stop presentation remains visible
during loading or failed lookups.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f0e0d3d6-23ff-4139-843a-3ebeac361366

📥 Commits

Reviewing files that changed from the base of the PR and between ac63ec6 and a1be069.

📒 Files selected for processing (5)
  • onebusaway-android/src/main/java/org/onebusaway/android/map/RouteMapController.kt
  • onebusaway-android/src/main/java/org/onebusaway/android/map/RouteMapRepository.kt
  • onebusaway-android/src/main/java/org/onebusaway/android/map/RouteViewGeometry.kt
  • onebusaway-android/src/test/java/org/onebusaway/android/map/RouteDirectionFocusTest.kt
  • onebusaway-android/src/test/java/org/onebusaway/android/map/RouteViewGeometryTest.kt

Comment thread onebusaway-android/src/main/java/org/onebusaway/android/map/RouteMapController.kt Outdated
Comment thread onebusaway-android/src/main/java/org/onebusaway/android/map/RouteMapController.kt Outdated
bmander and others added 3 commits July 16, 2026 17:58
- Derive the selected-trip underlay from the trip's own direction shape
  rather than basePolylines, which in whole-route mode merges both
  directions and would surface the opposite direction beneath the trip.
- Return null from selectedTripPresentation() until both the exact shape
  and schedule resolve, so a half-loaded selection no longer blanks the
  base stops behind an empty selected-trip presentation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…etry

# Conflicts:
#	onebusaway-android/src/main/java/org/onebusaway/android/map/RouteMapController.kt
#	onebusaway-android/src/test/java/org/onebusaway/android/map/RouteViewGeometryTest.kt
- Unify the selected-vehicle presentation into a single guard clause instead
  of threading it piecemeal through both focus branches. When a trip is
  selected it is always active and (in whole-route mode) focusedGeometry is
  empty, so toTripFocusedRoutePolylines collapses to underlay + trip — the
  branches produced identical output. Hoist the shared badge computation.
- Extract directionPolylines(directionId), shared by showDirectionPolylines
  and selectedDirectionUnderlay, removing the duplicated shape→polyline block.
- Warm the selection's shape/schedule with launch instead of async/await
  (the results are discarded; only the cache side effect matters).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bmander
bmander merged commit 2049fdb into main Jul 16, 2026
3 checks passed
@bmander
bmander deleted the agent/trip-focus-geometry branch July 16, 2026 18:26
bmander added a commit that referenced this pull request Jul 16, 2026
…1899)

#1893 routed every vehicle selection through publishMapPresentation(), whose
new selected-trip branch always drew the exact trip in the route's GTFS color
(currentRouteColor()) over a generic direction underlay. Inside stop focus,
where the emphasized route is drawn in its adjacency color, tapping a vehicle
therefore reverted the route to its GTFS hue and layered the trip over the
generic route-direction geometry — reading as standalone route mode.

Resolve the selected trip's color from the adjacency palette
(routeColors[selected.routeDirection]) when the route is emphasized in stop
focus, falling back to the GTFS color only in whole-route mode where no
adjacency entry exists. In that emphasized case also drop the generic
direction underlay: the adjacency-colored trip already reads on its own, and
the underlay is what made it look like route mode. Whole-route standalone
selection is unchanged (GTFS trip + underlay).

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant