Repository navigation
feat(share): add earthquake report v2 adapter - #680
Open
YinCheng0106 wants to merge 1 commit into
Open
YinCheng0106 wants to merge 1 commit into
YinCheng0106 wants to merge 1 commit into
Conversation
Platform: all New(zh-Hant): 新增地震報告分享資料轉接,保留來源與震度資訊 New(en-US): Add a data adapter for earthquake report sharing that preserves source and intensity information
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
🔍 OpenCodeReview found 3 issue(s) in this PR.
|
Comment on lines
+345
to
+353
| final list = Map.of(modern.list); | ||
| final model = modern.copyWith(list: list); | ||
| final evidence = _evidence(model); | ||
| list.clear(); | ||
| _expectFailure( | ||
| adaptEarthquakeShareInput(model, evidence: evidence), | ||
| EarthquakeShareInputError.snapshotMismatch, | ||
| '', | ||
| ); |
Comment on lines
+368
to
+370
| final content = _decode(bytes)['report'] as Map<String, dynamic>; | ||
| expect(content['epicenter'], {'lat_e6': 23090001, 'lon_e6': -121400001}); | ||
| }); |
Comment on lines
+409
to
+413
| _expectFailure( | ||
| adaptEarthquakeShareInput(report, evidence: _evidence(report)), | ||
| EarthquakeShareInputError.conflictingIntensity, | ||
| '/list/臺東縣/town/成功/int', | ||
| ); |
Codecov Report❌ Patch coverage is
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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 做了什麼
新增純 Dart 的
adaptEarthquakeShareInput。它接受完整的EarthquakeReport和經查核的同份 Core v2 詳情快照證據,回傳不可變的 v2 UTF-8 JSON,或帶有分類、來源 JSON Pointer 與診斷的失敗。範圍限於地震報告的資料轉接與離線測試。source.namespace / report_idexptech.eq-report-v2搭配原始完整id。比對請求 ID 與詳情快照,保留小區域共用序號之後的完整尾碼。source.event_id / revision / publicationnull。列表md5、ETag、擷取次序與內容雜湊各有不同用途。更正若影響完整 ID,跨 ID 關聯需來源證據。origin_time_unix_mstime是 UTC 瞬間的 Unix 毫秒,原值傳遞。現代樣本等於臺灣時間 2026-04-22 11:15:24。epicenter / locationlat、lon轉成百萬分之一度,精確檢查值域後以半值遠離零取整。保留完整loc含空白,英譯未知。magnitude / depth_mmag為芮氏規模。確認適用後輸出ml與百分之一級。原始depth由公里轉公尺。intensity_scale / scale_evidencepublished_max_intensitynull。DPIP 的maxIntensity從測站衍生且空集合會回 0,列表摘要也缺同版快照綁定。areaslist[縣市].int。縣市代碼由適用該快照的內政部代碼證據提供,作為區域 ID 與 scopedregion_id。observationslist[縣市].town[測站名稱]的名稱、兩軸及int。驗證過的氣象署站碼同時提供 scopedstation_id。每站每份詳情一筆觀測時使用cwa:<站碼>作觀測 ID,重複身分整份拒絕。trem與未證實的來源 metadata 留在原始紀錄。區域與觀測依 ID 排列,明確 0 值保留,空陣列維持空。目前離線驗證的完整來源是臺東縣近海
115000-2026-0422-111524,涵蓋兩個縣市與五筆已對照測站。兩個公開詳情快照的來源、原始 SHA-256 與站碼證據見 樣本說明。詳細欄位及量表以 ExpTech API 文件 與 eq-report-pic v2 契約 為準。一般詳情缺少穩定站碼與區域識別。相同快照還需要原始十進位數值及規模、量表證據。公開美濃詳情可依契約解碼為新制序碼,歷史行政區與測站的有效身分仍缺完整對照。未知量表、獨立來源的舊制記錄、縮短或不符的報告 ID、未知規模類型、重複身分、缺座標證據、欄位越界或測站震度高於所屬區域最大值會回傳失敗。v2 可表示位置未知的已識別觀測,現行 DPIP 詳情模型要求完整座標,原始回應缺軸時會在解碼階段失敗。
相容性與接續工作
time和震度的num轉成int。證據提供端須在解碼前檢查來源整數及重複鍵,並保存來源十進位字面值。目前支援最多 128 字元的一般十進位表示,指數記法會回報來源格式不支援。ReportPicture.renderSharePngV2(Uint8List),本轉接器可提供該型別。feat(share): integrate native Rust rendering runtime #679 仍開啟,DPIP 原生串接測試依賴該 PR 進入 main。此 PR 來自 main,build: prepare the app to draw report images over native FFI #677 的 FFI 準備與 feat(earthquake): add 4:5 and 9:16 report sharing cards #674 的卡片、動線、分享和儲存皆由各自分支處理。相關 issue
怎麼驗
以公開來源本文離線測試完整 ID、臺灣時間對照、精確單位換算、最大震度語意、0 與未知、排序、重複輸出、修訂未知及具體失敗分類。
Rust 驗證器接受 Dart 測試逐位元組核對的完整 JSON。Rust、Dart 及 Python 的 canonical content SHA-256 一致,為
6eac3077aae8b992e8c752c2c71a137a5601ad94e52c8d8952e7261b179c9e95。Rust 摘要為區域來源的 2 級。主機 Rust CLI 使用同一份資料產生 1920×1080 PNG。eq-report-pic Rust 指定套件共 17 個測試通過。上游 Rust/Dart 與 Draft 2020-12 檢查覆蓋 8 個有效及 39 個無效樣本。
Dart 格式化與 Flutter 靜態分析通過。地震功能測試 387 項通過,含 14 項轉接器測試。5 項既有測試因本機沒有 ONNX 模型而跳過。
tool/check.sh通過,完整套件 3,843 項通過、11 項跳過。iOS 模擬器RunnerTests421 項通過。檢查清單