Commit 00cdfd1
* RouteMapController: extract pure presentation assembly (#1907)
The controller's publishMapPresentation() merged three presentation modes
(selected-vehicle exact trip, plain base route, stop-focus adjacency) via
early returns, and the #1899 regression was exactly a missed interaction
between two of them (adjacency colour vs. the generic direction underlay) —
yet none of that policy had a JVM test.
Extract the merge into a pure assembleRouteMapPresentation() in the new
RouteMapPresentationPlan.kt, beside RouteViewGeometry.kt: a function of (base
polylines/stops, focus session data, focused geometry/stops/routes, palette,
mode flags, selected-trip render inputs) -> a RouteMapPresentation render
plan. The controller keeps IO/lifecycle and now just resolves the IO-backed
pieces (selectedTripRenderInput) and forwards each plan field to the render /
stop layers. The one Location-dependent step, the focused-stop projection,
enters as a lazy thunk so the assembler stays plain-data and JVM-testable
across every branch.
Also dedup the nearest-point-across-polylines kernel shared by
projectFocusedStops and projectStopsOntoPolylines (moved to the new file) and
give both a unit home.
Tests:
- RouteMapPresentationPlanTest (JVM): the three-mode precedence, the
adjacency-colour/underlay interaction (both sides of the #1899 case), the
degenerate-selection fall-through, and selection-wins-over-focus.
- RouteStopProjectionTest (instrumented): the projection geometry, which snaps
against android.location.Location and so can't run in this module's
plain-JVM tests. Verified on-device (6/6 pass).
No behaviour change: the assembler is a faithful extraction of the prior
branching.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Cleanup: laziness, single lookup, file split for the presentation assembler
Follow-up polish on the #1907 extraction (no behaviour change):
- Restore the laziness the extraction lost. SelectedTripRenderInput built its
directionUnderlay (a per-segment RoutePolyline copy) and stopPresentation
(a Location stop projection) eagerly on every publish with a selected
vehicle, but the assembler discards the underlay whenever the route has an
adjacency colour and the stop projection whenever the trip is undrawable.
The pre-extraction code computed both only inside the branch that used them.
Defer both as thunks (mirroring the existing projectedFocusStops thunk) so
each is computed only when its branch is taken.
- Collapse the selected-vehicle branch to one adjacency-colour lookup and drop
the redundant `selected != null` guard (selectedTrip is non-null only when
selected is), restoring the original single-nullable shape.
- Drop the now-dead `= { emptyMap() }` default on projectedFocusStops — the
sole production caller always supplies it; make the contract explicit.
- Move the Location-dependent projection kernels (projectFocusedStops,
projectStopsOntoPolylines, the shared nearest-point kernel) out of
RouteMapPresentationPlan.kt into a new RouteStopProjection.kt, matching the
instrumented RouteStopProjectionTest's name and leaving the assembler file
cleanly JVM-pure.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Document why whole-route emphasis keeps the base route; pin it with a test
Address CodeRabbit review on #1920: the exact-equality showBaseRoute check
(it.routeDirection == emphasizedRoute) was flagged as incorrectly keeping the
base route in whole-route mode. It is intentional, not a bug:
- In whole-route mode emphasizedRoute carries a null direction, so basePolylines
is the merged both-directions shape. The single-direction adjacency lines cover
only part of it, so the base must stay — dropping it (matching route id alone)
would erase the unfocused direction.
- The proposed null-direction match would also empty the focused-stop
presentation, since routeDirectionsByStopId's exact-match filter drops every
concrete-direction trip against a null-direction key.
Expand the comment to record this, and add a JVM test pinning that whole-route
mode keeps the base route (and base stops) under a same-route focused stop. No
behaviour change.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a56e5f6 commit 00cdfd1
5 files changed
Lines changed: 778 additions & 113 deletions
File tree
- onebusaway-android/src
- androidTest/java/org/onebusaway/android/map
- main/java/org/onebusaway/android/map
- test/java/org/onebusaway/android/map
Lines changed: 152 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
Lines changed: 42 additions & 113 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | 129 | | |
136 | 130 | | |
137 | 131 | | |
| |||
590 | 584 | | |
591 | 585 | | |
592 | 586 | | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
593 | 591 | | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
639 | 607 | | |
640 | | - | |
641 | | - | |
642 | | - | |
643 | | - | |
644 | | - | |
645 | | - | |
646 | | - | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
647 | 611 | | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
660 | 632 | | |
661 | 633 | | |
662 | 634 | | |
| |||
700 | 672 | | |
701 | 673 | | |
702 | 674 | | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | 675 | | |
730 | 676 | | |
731 | 677 | | |
| |||
818 | 764 | | |
819 | 765 | | |
820 | 766 | | |
821 | | - | |
822 | | - | |
823 | | - | |
824 | | - | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | 767 | | |
839 | 768 | | |
840 | 769 | | |
| |||
0 commit comments