雷達風向疊圖、選單點了不關,震度 0 不再被 S 波染色、重播圖例可收合 - #574
Open
PiscesXD wants to merge 4 commits into
Open
Conversation
Fix(zh-Hant): 圖層選項選單改成點選項目後不再自動關閉,只有點篩選器或空白處才會關閉 Fix(en-US): Keep the layer options menu open when a row is tapped; only the chip or a tap outside closes it
New(zh-Hant): 雷達回波圖新增「顯示風向」圖層,畫出同一時刻的測站風向風速,和顯示閃電兩者只能擇一 New(en-US): Add a wind overlay to the radar echo drawing the same frame's station wind, exclusive with the lightning overlay
Fix(zh-Hant): 震度速報期間,震度 0 的鄉鎮不再被 S 波圓盤染上顏色 Fix(en-US): Stop the EEW S-wave disc showing through townships the estimate puts at 0
New(zh-Hant): 報告重播的震度圖例可以收起來了,預設收合成一顆「圖例」按鈕 New(en-US): The report replay's intensity legend now collapses, and starts collapsed as a legend chip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
這個 PR 做了什麼
五件事,四件在地圖上:雷達回波多了一個「顯示風向」疊圖(畫同一幀時間的測站風向風速,和顯示閃電互斥);所有圖層的選項選單改成點一列不會自動關閉;強震監視器與報告重播在速報期間,震度 0 的鄉鎮不再被 S 波圓盤染色;報告重播的震度圖例可以收起來。第五件在測試裡:雷達疊圖那幾組不再靠猜事件圈數等非同步工作 —— 那是滿載時
lightning overlay會偶爾紅的真正原因。相關 issue
怎麼驗
1/5 雷達風向(
feat(map))m/s的鍵。radar-wind-*vswind-arrow-*)。時間對齊這段最值得看,因為兩邊的刻度差很多:
/api/v2/tiles/radar/list/api/v5/meteor/lightning/list/api/v5/meteor/weather/list觀測是整點一筆(差量全是 3600,連
latest的time都落在整點)。所以風向不是照閃電那樣取「最近一筆 ±10 分」—— 那樣一小時六張影格裡只有三張對得上,拖時間軸時箭頭會一直閃掉。改成取該影格時刻當下生效的那筆(時間 ≤ 影格時間、且最新),一筆整點觀測覆蓋它之後的六張影格。跟著這個規則要確認兩件事:
ARCHITECTURE.md那條「stale 的資料不得呈現為現況」,所以showEmpty()保留圖層本身,讓「開著但沒資料」和「關掉」在畫面上是兩件事。2/5 選項選單不再自動關閉(
fix(map))MapMenuToggleRow做的,維持原本行為。3/5 震度 0 不再被 S 波染色(
fix(map))現象:強震監視器有速報時,震度 0 的鄉鎮會被 EEW 的 S 波圓盤染上一層紅。
成因要從
c8fb4372 fix(map): keep the OSM ground visible under the township wash說起 —— 那次把震度洗(town圖層)在震度 0 的matchfallback 從灰色改成rgba(0, 0, 0, 0),好讓 OSM 詳細底圖透出來,但沒動到旁邊那行:速報期間county圖層被設成fillOpacity: 0。疊圖順序是而 S 波圓盤(
fillOpacity: 0.16)是刻意掛在belowLayerId: landLayerId,讓它只染開闊海面。於是速報一來、某個鄉鎮估到 0:洗是透明的、county被藏起來,台灣上面沒有任何不透明的圖層,下面那圈 S 波就透上來了。改法不是把 fallback 改回灰色(那會把
c8fb4372修的 OSM 問題再弄回來),而是讓county在有無速報時都維持原本的灰色,寫在分支前面:county之上、洗之下,照樣看得到 ——c8fb4372修的東西沒有退回去。report_replay_page.dart的_updateAreaFill和rts_layer.dart是逐字複製的同一段,同一個 bug,一起改;map_style.dart上兩段已經過期的註解(還在講「洗可以直接把 county 藏掉」)也一併更新。4/5 重播圖例可以收合(
feat(eew))報告重播是自己一頁全螢幕地圖、沒走
MapScaffold,所以漏掉了CollapsibleMapLegend—— 雷達、衛星、雨量那些圖例本來就是預設收合成一顆「圖例」鈕、點開才展開。這次補上,沒有新字串(圖例/收合圖例12 個 locale 都已經有了)。7)換成分級震度(17),但圖例不會被關掉 —— 收合狀態包在 mode 切換的外層,換的是「哪個尺標」,不是「你要不要看」。5/5 雷達疊圖測試不再靠猜事件圈數(
test(map))滿載跑全套時
radar_layer_test.dart的lightning overlay那組會偶爾掛(先是draws the snapshot nearest the frame,後來換成draws nothing when no snapshot is near the frame),斷言看到的是 source 還沒掛上。不是疊圖本身的 bug,是測試等的方式:shown()用await pumpEventQueue()等疊圖工作落地,而pumpEventQueue()預設只給20 圈事件圈。疊圖掛載時要烘八顆圖示,每顆走
Picture.toImage+toByteData(png)—— 那是 engine 的回覆,不是 microtask,16 次各自佔一圈。實測把圈數壓到 16 就穩定
失敗、20 才會過,也就是說單單烘圖就把預算吃光,後面的 history 抓取、
addSource、addSymbolLayer、第一次setGeoJsonSource全都在借剩下那三四圈 —— 機器閒著時有些回覆會併在同一圈所以塞得進去,滿載時就塞不進去。
改法是不要猜:
RadarMapLayer開一個@visibleForTesting的overlaySettled,直接回那條序列化疊圖工作的 chain,測試
await它。閃電、風向、兩者互斥三組共 11 處await pumpEventQueue()換成await layer.overlaySettled,等待條件從「圈數夠不夠」變成「工作做完了沒有」,和機器負載無關。
測試
test/features/map/radar_layer_test.dart63 個(風向疊圖新增一組 group,含三條時間對齊的邊界;閃電/風向/互斥三組的等待方式一併換掉)test/features/map/radar_overlay_menu_test.dart12 個(三方互斥、以及「點一列選單留著/點篩選器才關」)test/features/map/presentation/layers/rts_layer_demo_test.dart新增一條:放一個震央上的鄉鎮和一個 250 km 外的鄉鎮,斷言洗的 fallback 還是透明而且county的fill-opacity是 1test/features/earthquake/presentation/widgets/intensity_legend_chip_test.dart新增 2 條:預設收合/點開/收回,以及「速報換尺標不會關掉已展開的圖例」全套
tool/dev/test.sh1832 passed / 5 skipped(連兩次綠)。tool/dev/analyze.sh乾淨,tool/check/commits.sh origin/main..HEAD5 則全過。檢查清單
tool/check/commits.sh origin/main..HEAD通過—— commit 訊息就是更新日誌,格式見 commit.md
—— 五件事拆成五則;
radar_overlay_menu_test.dart一個檔同時含前兩件事,所以先把只含「點一列選單留著」的中間版本進第一則、確認那棵樹是綠的,再還原最終版進第二則
mise exec -- flutter analyze與mise exec -- flutter test通過—— 走
tool/dev/analyze.sh、tool/dev/test.shAppLocalizations,沒有寫死—— 「顯示風向」12 個 locale 都補齊了;圖例收合沿用既有的
mapLegendExpand/mapLegendCollapse,沒有新增字串AppSpacing/AppRadius/AppMotion,深色模式看過,文字對比度可接受
—— 風向是既有雷達選單裡多一列,沿用同一個 row 樣式;箭頭圖例沿用
SymbolLegendItem,箭頭本身是預先烘好的 PNG 且跟著色覺輔助設定重烘;圖例收合直接沿用
CollapsibleMapLegend,和其他圖層同一個外觀與動畫