Skip to content

fix(eew): show every intensity the map paints in the legend - #659

Open
whes1015 wants to merge 2 commits into
mainfrom
fix/eew-legend-painted-ceiling
Open

whes1015 wants to merge 2 commits into
mainfrom
fix/eew-legend-painted-ceiling

Conversation

@whes1015

@whes1015 whes1015 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

這個 PR 做了什麼

地震速報的圖例上限改成跟著「地圖實際塗到的最高震度」,而不是警報自己回報的 max。

前一個 PR(#656)讓圖例在速報時只顯示到預估最高震度,但地圖的著色是 eewTownLevels 自己算的(ML 模型,模型還沒好時用公式),它可以算得比警報回報的整數級更高。結果就是 #ET-2026-0199 討論串裡烤大鴨 11/05 貼的那張圖:資訊欄和圖例只到 2 級,地圖上卻有 3 級的顏色——圖例少一格,那個顏色就被讀成別的震度。

改動內容

正式程式碼:

  • lib/features/earthquake/domain/eew_town_levels.dart:新增 highestPaintedLevel()(掃過整張 368 鄉鎮的預估、忽略透明的 0)與 legendCeiling()(回報值與實際著色取較高者;兩者都不知道時回 null,顯示完整色階)。
  • lib/features/map/presentation/layers/rts_layer.dart:_updateAreaFill 把著色到的最高級別寫進 _paintedMaxLevel,沒有速報時清成 null;buildLegend 改成同時聽這個 notifier,用 legendCeiling 算上限。
  • lib/features/earthquake/presentation/pages/report_replay_page.dart:回放頁的 _ReplayMapState 走同一條路,把著色上限交回頁面上方的圖例。
  • lib/shared/widgets/intensity_legend.dart:只補 maxEewLevel 的註解,說明它是「著色的上限」而不是警報回報值,沒有行為改動。

測試:

  • test/features/earthquake/domain/eew_town_levels_test.dart:新增兩則——highestPaintedLevel 要忽略 0 級的鄉鎮;legendCeiling 在地圖算得比回報值高時要取地圖那個值。

刻意沒做的:

  • 沒重做圖例 UI,也沒動左側「各地震度排行」和下方卡片(討論串的結論是那邊才有真正的空間問題)。
  • 沒做「點開看完整色階」的互動,維持原本就沒有這個入口的狀態。

相關 issue

怎麼驗

  • tool/dev/analyze.sh:通過(dart format --set-exit-if-changed 與 flutter analyze 都沒有問題)。
  • tool/dev/test.sh:本機 3670 個測試通過;另有 test/tool/*_script_test.dart 共 10 個失敗(Expected: <7> Actual: <126>,執行暫存腳本時拿不到執行權限)。我把 origin/main(07c0c3d)開成乾淨的 worktree 重跑 test/tool/run_script_test.dart,同樣的測試以相同錯誤失敗,確認與這個改動無關、是本機環境的問題。tool/check/commits.sh origin/main..HEAD 通過。
  • 沒有實機或模擬器驗證畫面:圖例高度跟著著色上限變動這件事,只有在一場「模型算得比警報回報高」的速報裡才看得到。要請有裝 app 的人在一場速報裡對一下圖例最高那一格和地圖上最深的顏色。

檢查清單

  • tool/check/commits.sh origin/main..HEAD 通過
  • 一個 commit 一件事
  • mise exec -- flutter analyze 與 mise exec -- flutter test 通過 —— analyze 通過、測試只有上述與改動無關的 10 個環境失敗
  • 新的使用者可見字串都走 AppLocalizations,沒有寫死(這次沒有新增字串)
  • CI 全部通過(Android、iOS、build、codecov 都是 pass,Instrumented 是 skipped)
  • 沒有 UI 尺寸/顏色改動;圖例既有的深淺色與 spacing 都沒動

Platform: all

Fix(zh-Hant): 修正地震速報的圖例最高只到警報回報的震度、地圖卻塗到更高一級時,顏色與圖例對不上的問題
Fix(en-US): fix the map legend stopping below an intensity the map does paint
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.94737% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.42%. Comparing base (07c0c3d) to head (3e6b7d1).

Files with missing lines Patch % Lines
...ib/features/earthquake/data/eew_ml_max_source.dart 84.37% 5 Missing ⚠️
...ib/features/map/presentation/layers/rts_layer.dart 33.33% 4 Missing ⚠️
...thquake/presentation/pages/report_replay_page.dart 72.72% 3 Missing ⚠️

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Platform: all

Fix(zh-Hant): 地震速報改用 ML 模型預測的全國最大震度
Fix(en-US): use the ML model's nationwide maximum intensity for EEW
@lowrt

lowrt commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

這次改為在 EEW 資料進入 realtime channel 時處理:

  • 模型可用時,計算全部鄉鎮的 ML 預測震度,並以其中最大值替換 EewInfo.max
  • 首頁、地震頁、強震監視器、重播、圖例、無定位時的排序與前景播報會共用同一個 ML 最大震度
  • 模型尚未載入時不延遲警報,暫時保留 payload 值並啟動模型載入
  • 模型無法估算或警報已取消時保留 payload 值
  • 移除前一版只在圖例末端替換最大震度的邏輯
  • 新增 ML 最大震度資料來源測試,包含 ML 結果低於 payload 的情況

Commit: 3e6b7d1

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants