Skip to content

gpx:replayで終点の座標から行先を引いて表示し、引けなければ再生を始めないようにした - #7190

Merged
TinyKitten merged 1 commit into
devfrom
feature/gpx-replay-destination
Oct 5, 2026
Merged

TinyKitten merged 1 commit into
devfrom
feature/gpx-replay-destination

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

概要

npm run gpx:replay の再生中に、列車がどの駅へ向かっているのかが分かりませんでした。再生を始める前に GPX の終点の座標で StationAPI に 1 回だけ問い合わせ、いちばん近い駅を行先として表示するようにしました。行先を引けなかったときは、再生を始めずに異常終了します。

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • scripts/replay-location-gpx.mjs
    • GPX の最後の点の座標で stationsNearby(limit: 1) を呼び、行先を決めます。
    • 問い合わせ先の既定はステージングの https://gql-stg.trainlcd.app/ です。環境変数 GQL_API_URL があればそちらを使います。
    • 行先は開始時に 行先: 京王八王子 と表示し、進捗行にも [812/2484] 京王八王子行 +811s … のように載せます。
    • 次のどれかに当たると、行先を取得できませんでした: <理由> を出して終了コード 1 で止まります。通信の失敗、5 秒のタイムアウト、HTTP エラー、GraphQL のエラー、駅が見つからない場合です。
    • 問い合わせはテストプロバイダを有効にする前に行います。止まったときに端末側の後始末は要りません。
  • scripts/replay-location-gpx.test.mjs(新規): adb と StationAPI を偽物に差し替えて、次の 2 点を確かめるテストです。
    • 終点の座標で 1 回だけ問い合わせ、行先を表示すること。
    • 失敗の 3 パターンで、adb を一度も呼ばずに終了コード 1 で止まること。
  • docs/location-simulation.md: Android で再生する節に、上の動作の説明を追記しました。

GPX ファイルと生成スクリプト(gpx:generate)は変更していません。

テスト

  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

省略: アプリのコード(src/ など)は変更していません。npm run lint は実行して通りました。ただし対象は src だけです。

  • npm run test:scripts: 111 件すべて成功しました。
  • 実機(T12_ROW)で、本物の adb を使って同梱の GPX 7 本を流しました。各ファイルとも終点の手前 15 秒だけを等倍で再生しています。問い合わせ先はステージングです。全本とも行先が表示され、正常終了しました。
    • FLinerSeibu: 飯能
    • HitachiShinagawaSendai: 仙台
    • KatamachiRapid: 木津
    • KeioSpecialExpress: 京王八王子
    • SampleJY: 池袋
    • SampleTohokuShinkansen: 仙台
    • SobuRapid: 津田沼
  • 実機で、届かない API(GQL_API_URL=http://127.0.0.1:1/)を指定しました。行先を取得できませんでした: fetch failed と出て終了コード 1 で止まりました。このとき android:mock_location は default のままで、テストプロバイダも作られていませんでした。
  • アプリは起動しておらず、アプリの画面は確認していません。

関連Issue

スクリーンショット(任意)

UI変更なし: 開発用スクリプトと docs だけの変更で、アプリの画面には影響しません。

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 新機能
    • AndroidでGPX再生を開始する前に、終点に最も近い駅を取得して行先として表示するようになりました。駅名は再生開始時と進捗表示に含まれます。
    • 駅を取得できない場合や問い合わせが失敗・タイムアウトした場合は、再生を開始せずエラーを表示します。
    • 問い合わせ先には環境設定のURLを使用し、未設定の場合はステージング環境に接続します。

@TinyKitten TinyKitten self-assigned this Oct 5, 2026
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 736bc84e-50fb-43a0-9ee6-f211c6ab6239
📥 Commits

Reviewing files that changed from the base of the PR and between a5750f4 and 48628f4.

📒 Files selected for processing (3)
  • docs/location-simulation.md
  • scripts/replay-location-gpx.mjs
  • scripts/replay-location-gpx.test.mjs

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.


📝 Walkthrough

Walkthrough

AndroidのGPX再生スクリプトに、再生開始前に終点座標でStationAPIへ問い合わせる処理を追加しました。取得した駅名を開始時と進捗に表示します。駅を取得できない場合は、テストプロバイダの設定前に終了します。

Changes

GPX再生の行先駅表示

Layer / File(s) Summary
終点座標による駅検索
scripts/replay-location-gpx.mjs
GPXの終点座標を使い、StationAPIのstationsNearbyへ駅数1で問い合わせます。GQL_API_URLがない場合はステージングURLを使います。5秒でタイムアウトし、HTTPエラー、GraphQLエラー、駅情報がない場合は例外を返します。
再生処理への組み込みと検証
scripts/replay-location-gpx.mjs, scripts/replay-location-gpx.test.mjs, docs/location-simulation.md
再生開始前に駅名を取得し、開始時と進捗に表示します。取得に失敗するとエラーを出して終了コード1で終了します。テストは問い合わせ回数、表示、HTTP 500、駅情報なし、GraphQLエラー時の終了とadb未実行を確認します。手順書に同じ動作を記載します。

Priority: ⬇️ Low

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ReplayScript
  participant StationAPI
  participant adb
  ReplayScript->>StationAPI: GPX終点座標でstationsNearbyを問い合わせる
  StationAPI-->>ReplayScript: 最寄り駅の情報を返す
  ReplayScript->>adb: 行先駅の取得後にsetupを実行する
Loading

Merge Risk: ⚪ Minimal · up to 48628

No actionable issue was identified that would prevent merging. The deployed staging API was not independently verified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed GPX再生前に終点座標から行先を取得して表示し、取得に失敗した場合は再生を開始しない変更を明確に示しています。
Description check ✅ Passed 概要、変更内容、テスト結果、関連Issue、スクリーンショットの各節があります。テスト結果と実機確認の内容も具体的です。テスト欄のチェックボックスは未選択ですが、実行したテストと結果を本文で説明しています。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 …
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 docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

うさぎは地図をくるりと広げ
終点の駅名をAPIにたずねる
返った名前を進捗にのせ
失敗なら再生前に止まり
「これで道案内もばっちり!」と跳ねる

Comment @coderabbitai help to get the list of available commands.

@TinyKitten
TinyKitten merged commit ad5f3a6 into dev Oct 5, 2026
7 checks passed
@TinyKitten
TinyKitten deleted the feature/gpx-replay-destination branch October 5, 2026 11:01
This was referenced Oct 5, 2026
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