Skip to content

feat(metro): locate nearest station across systems - #114

Open
steventeng2022 wants to merge 1 commit into
YetAnotherBusDeveloper:mainfrom
steventeng2022:codex/nearest-metro-station
Open

steventeng2022 wants to merge 1 commit into
YetAnotherBusDeveloper:mainfrom
steventeng2022:codex/nearest-metro-station

Conversation

@steventeng2022

Copy link
Copy Markdown
Contributor

Adds a Find nearest station / 定位最近的車站 button to the metro dashboard. For example, a rider in Kaohsiung with Taipei Metro selected can locate once to switch to the nearest station's system and serving line, open its map, and load its arrival information.

  • Compare stations across all metro systems using the existing cached repository and shared location resolver. Calculate distances locally and request location only after a tap.
  • Resolve line membership from station-of-line, including stations whose line_id is empty. Ignore invalid coordinates and unavailable lines; prefer the current line at an interchange when distances tie.
  • Keep usable results when a system fails and disclose the incomplete coverage. Preserve the current selection on failure, and discard late results after a manual selection or tab change.
  • Include English and Traditional Chinese strings, generated localizations, README documentation, and unit/widget regression coverage.

Closes #55.

Validation with Flutter 3.47.6 / Dart 3.13.5:

  • 26 focused tests passed across nearest_metro_station_test.dart, metro_nearest_station_test.dart, user_location_test.dart, metro_direction_test.dart, and metro_direction_selector_test.dart.
  • Static analysis of all changed Dart files: no issues.
  • Formatting and git diff --check: passed.

The repository-wide analyzer reports six pre-existing unawaited_return_in_try_block warnings in app_controller.dart, app_update_service.dart, and bus_repository.dart with this newer local SDK. The repository's CI uses Flutter 3.41.6; no dependency or SDK versions are changed by this PR. Physical-device GPS and the full test suite were not exercised locally.

@Av1anJay Av1anJay 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.

Code review: changes requested

  • lib/screens/metro_dashboard_screen.dart:262-263 — Incomplete system data is reported as complete. A system is counted as available whenever its three requests return successfully, even if its stations or station-of-line list is empty, or all its stations have invalid coordinates / no matching line. For example, if KRTC returns HTTP 200 with an empty station list while TRTC has data, a user in Kaohsiung will be told that a Taipei station is the nearest with no incomplete-coverage warning. _getJsonList also converts a non-list HTTP 200 response to an empty list, so this can occur without an exception. Detect systems without usable candidate stations as incomplete, and add a widget regression test with one unusable and one usable system.

Checks: GitHub CI Verify passed (Flutter analyze, full Flutter tests, web route test, Node runtime tests); Android, iOS, Linux, macOS, Windows, Wear OS and Web builds passed. Locally, git diff --check passed and the Node runtime tests passed on Node 22.23.4 (3 tests). Flutter SDK is not installed locally, so Flutter checks were not rerun here. Inspected live metro API responses and reproduced the incomplete-coverage condition with an empty KRTC station list.

This branch has not been deployed

No deployments
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.

[Feature] 捷運分頁:定位最近的車站

2 participants