From b98072955dcf2665ee80abe83c426139c77809bb Mon Sep 17 00:00:00 2001 From: jhl-hk Date: Thu, 19 Nov 2026 01:04:17 +0900 Subject: [PATCH] Verify the ground artifact from the selected Sector plugin --- AGENTS.md | 7 ++++--- README.md | 4 +++- scripts/verify-ground-port.ts | 15 ++++++++++++--- src/components/GroundPreview.vue | 4 ++-- src/lib/groundMap.ts | 4 ++-- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index d43d8c7..fe31b2b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -96,9 +96,10 @@ Direct2D 的虚线段长以描边宽度为单位、线帽是平的,这边也 对得上是**可以证明的**,改完跑一次 `bun run verify:ground`:它 拿 `Ground//airports/*.json` 加 `.sct`、`.ese`、`GRpluginStands.txt` 和 `Ground/NavData/naip.json` 跑一遍 `buildAirportFromSource`(有 -`Ground//layers/.json` 的机场跑 `buildPrebuiltAirport`),和 -`Sector//Plugins/GroundMap/ground.json` 里对应的机场逐字节比较,漂了就非零 -退出。检查范围和结果以命令输出为准,不在文档中固定机场或图层数量。 +`Ground//layers/.json` 的机场跑 `buildPrebuiltAirport`), +与扇区包中选定的 `ground.json` 逐字节比较。选目录的规则和 `merge.py` 一样: +`Plugins/CANGroundRender/` 存在就用它,否则用 `Plugins/GroundMap/`。选定目录内 +缺少 `ground.json` 或产物不一致时以非零状态退出。检查范围和结果以命令输出为准。 两个参数的 `undefined` 和 `[]` 不是一回事: `undefined` 是"没有扇区文件,跑道用 OSM 近似",`[]` 是"扇区文件在,但它没有这 个机场的跑道行"(ZL02、ZL03 那种只在站位表里的场,产物里本来就没有跑道层)。 diff --git a/README.md b/README.md index 663896b..bbfe30a 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,9 @@ can-api 再检查 `apps:manage`、当前开发者资格和应用所有权。 `merge.py` 把 `cos(36°)` 当纬度传给抽稀函数那个怪癖也抄了。改动那边而不改这边 的下场,是预览和管制员机器上装的那份对不上,而预览工具唯一不能犯的就是这个 错。`bun run verify:ground` 用源文件重建机场和 world 图层,与扇区包中的 -`ground.json` 逐字节比较。检查范围和结果以命令输出为准。 +`ground.json` 逐字节比较。优先使用已有的 `Plugins/CANGroundRender/`,否则使用 +`Plugins/GroundMap/`。选定目录缺少 `ground.json` 时检查失败,不改读另一个目录。 +检查范围和结果以命令输出为准。 ## 部署 diff --git a/scripts/verify-ground-port.ts b/scripts/verify-ground-port.ts index f04775f..53857a1 100644 --- a/scripts/verify-ground-port.ts +++ b/scripts/verify-ground-port.ts @@ -16,7 +16,7 @@ * 退出码非零就是漂了。差异会打印出第一处不同的位置 —— 通常是某个常量,或者 * merge.py 那边加了一层而这边没跟。 */ -import { readdirSync, readFileSync, existsSync } from "node:fs"; +import { readdirSync, readFileSync, existsSync, statSync } from "node:fs"; import { join } from "node:path"; import { fileURLToPath } from "node:url"; @@ -81,11 +81,20 @@ let checked = 0; let failed = 0; for (const [fir, sctName] of Object.entries(FIRS)) { - const groundJson = join(SECTOR, fir, "Plugins/GroundMap/ground.json"); + // Like Ground/tools/common.py:deploy_dir, select the directory, not the file. + const plugins = join(SECTOR, fir, "Plugins"); + const preferred = join(plugins, "CANGroundRender"); + const preferredStat = statSync(preferred, { throwIfNoEntry: false }); + const deployDir = preferredStat?.isDirectory() + ? preferred + : join(plugins, "GroundMap"); + const groundJson = join(deployDir, "ground.json"); const airportsDir = join(GROUND, fir, "airports"); const layersDir = join(GROUND, fir, "layers"); if (!existsSync(groundJson)) { - console.log(`${fir}: 扇区包里没有 ground.json,跳过`); + checked++; + failed++; + console.log(`[x] ${fir}: 找不到 ${groundJson}`); continue; } const truth = json(groundJson); diff --git a/src/components/GroundPreview.vue b/src/components/GroundPreview.vue index b6f559e..f1d9276 100644 --- a/src/components/GroundPreview.vue +++ b/src/components/GroundPreview.vue @@ -9,8 +9,8 @@ * * 两条路进来,走的是同一个渲染器: * - * - **合并产物** `Sector//Plugins/GroundMap/ground.json`:插件读什么就画 - * 什么,一比一。 + * - **合并产物** `ground.json`(扇区包的 `Plugins/CANGroundRender/` 或 + * `Plugins/GroundMap/`):插件读什么就画什么,一比一。 * - **每机场源文件** `Ground//airports/.json`:先在浏览器里跑一遍 * `merge.py`(`lib/groundMap.ts`),再画。手工改完一个机场,拖进来就能看, * 不用先合并再开 EuroScope。 diff --git a/src/lib/groundMap.ts b/src/lib/groundMap.ts index 751c88e..eae8855 100644 --- a/src/lib/groundMap.ts +++ b/src/lib/groundMap.ts @@ -4,8 +4,8 @@ * 这个站不碰 Ground 仓库,也不带任何地面数据:文件是使用者自己拖进来的,全部 * 在浏览器里解析。之所以要在这里重做一遍合并,是因为**手工编辑的是每机场文 * 件**(`Ground//airports/.json`),而插件读的是合并产物 - * (`Sector//Plugins/GroundMap/ground.json`)—— 改一笔要跑一次 merge.py - * 再开 EuroScope 才看得见,这个来回是这个页面要消掉的东西。 + * `ground.json`(扇区包的 `Plugins/CANGroundRender/` 或 `Plugins/GroundMap/`)。 + * 改一笔要跑一次 merge.py 再开 EuroScope 才看得见,这个来回是这个页面要消掉的东西。 * * **逐行照着 merge.py 抄,包括它的常量和它的怪癖**(见 `dp()` 在 world 图层上 * 的调用)。这里"更正确"一点,预览就和真正装到管制员机器上的那份对不上了 ——