Repository navigation
オートモードを到着時間推定の見込みで走らせ、ETAとGPXと同じ時間で駅に着いて停まるようにした - #7158
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Repository guideline files applied to this review (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (14)
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. 📝 WalkthroughWalkthrough推定到着・出発時刻を使う走行計画を追加しました。オートモードは推定モデルの経路を取得し、クエリ失敗時は従来の経路クエリに切り替えます。GPX生成も共通の時間計画関数を使います。 Changes推定時刻ベースの走行計画
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant useSimulationMode
participant GraphQLAPI as GraphQL API
participant trainRouteTiming
useSimulationMode->>GraphQLAPI: Estimated経路クエリ
GraphQLAPI-->>useSimulationMode: 推定時刻を含む経路、またはエラー
alt Estimatedクエリがエラー
useSimulationMode->>GraphQLAPI: Legacy経路クエリ
GraphQLAPI-->>useSimulationMode: Legacy経路データ
end
useSimulationMode->>trainRouteTiming: 区間時間と速度プロファイルの計算
trainRouteTiming-->>useSimulationMode: 計画時間と速度プロファイル
Merge Risk: ⚪ Minimal · up to Auto mode now follows estimated arrival times and dwell times, and falls back to the previous behavior if the new query fails. No blocking issues were found; the change has not been tested on a device. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
うさぎは時刻表をひらき Comment |
概要
オートモードを、StationAPI の到着時間推定の見込み(
trainRouteのmodel: Estimated)で走らせるようにしました。各停車駅には見込みの到着時刻に着き、推定の停車時間だけ止まります。TrainLCD/StationAPI#1715 で、ETA(
estimateArrivalTimes)もEstimatedと同じ値になります。GPX の生成もオートモードと同じ計算を使うので、オートモードの移動時間・ETA・GPX の移動時間がそろいます。変更の種類
変更内容
src/hooks/useSimulationMode.ts)trainRouteをmodel: Estimatedで引きます(GET_ESTIMATED_TRAIN_ROUTE、GET_ESTIMATED_CONNECTED_TRAIN_ROUTE)。model引数を知りません。Estimatedの問い合わせがエラーになったら、これまでの問い合わせ(Legacy)に戻して走ります。modelを宣言した文書は、知らない API では検証エラーになります。そのため、$sortByと同じく別の文書に分けました。src/utils/trainRouteTiming.ts)speedProfileForDurationを足しました。列の長さは求めた秒数ちょうどで、合計は区間の距離になります。generateTrainSpeedProfileは加速・巡航・減速を 1 秒単位で切り上げて並べます。そのため、巡航速度を選び直しても列の長さが 1 秒ずれることがありました。距離・加減速・秒数を振った 233,160 通りで測ると、約 4 分の 1 でずれていました。新しい関数では 0 件です。cruiseSpeedForDurationとplanLegTimingsを GPX 生成スクリプトから移し、オートモードと共有しました。このファイルは Node からも直接読むので、何も import しません。src/utils/currentLineGroupStations.ts)alignConnectedTrainRouteSegmentsに、同じ駅グループが続く行をまとめる関数を渡せるようにしました。scripts/generate-location-gpx.mjs、assets/gpx/)speedProfileForDurationで作るようにしました。SampleTohokuShinkansen.gpxは--lineで作っているので変わりません。FLinerSeibu.gpxの最長の欠測が 326 秒から 327 秒になりました。location.subwayGpx.test.tsの実測値とdocs/location-simulation.mdの記述を合わせました。欠測の件数(7 件、うち 5 件が 90 秒超)は変わりません。useSimulationMode.test.tsxで、主に引く文書をEstimated側に替えました。乗換経路では区間を渡し、1 系統の問い合わせはしないという検査は、そのまま残しています。Estimatedがエラーなら、1 系統でも乗換経路でもLegacyに戻す。src/utils/trainRouteTiming.test.tsを足しました。リリースの順序
StationAPI#1715 が本番に入る前にこのアプリが出ても、オートモードは
Legacyの値で今までどおり走ります。ETA とそろうのは、StationAPI の本番にmodel: Estimatedが入ってからです。テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ることnpm run lint、npm run typecheck、npm test(322 スイート・3,589 件)はすべて成功しました。npm run test:scripts(109 件)も成功しました。実機・エミュレータでの動作確認はしていません。関連Issue
Refs TrainLCD/StationAPI#1715
スクリーンショット(任意)
UI 変更なし: オートモードの走行の時間配分と開発用の GPX(
assets/gpx/はアプリに同梱されません)の変更で、画面の見た目は変わりません。🤖 Generated with Claude Code
Summary by CodeRabbit