fix: restore Kyushu semantic beacon variants

This commit is contained in:
OpenAI Codex
2026-08-06 19:31:45 +08:00
parent 69b4f961a6
commit 6d9c0d571a
5 changed files with 106 additions and 17 deletions

View File

@@ -267,15 +267,43 @@ def transform_style(config: dict[str, Any]) -> dict[str, Any]:
}
style["sources"]["navsea_delivery"]["tiles"] = [TARGET_TILE_URL]
canonical_restore = {
"lt_hbr": "harbor_lighthouse",
"lt_bkw": "breakwater_lighthouse",
"lt_bcn": "light_beacon",
}
def restore_canonical_values(value: Any) -> Any:
if isinstance(value, list):
if len(value) >= 3 and value[:2] == ["get", "canonical_object_type"]:
return value
return [restore_canonical_values(item) for item in value]
if isinstance(value, dict):
return {key: restore_canonical_values(item) for key, item in value.items()}
if isinstance(value, str):
return canonical_restore.get(value, value)
return value
for layer in style["layers"]:
layer_id = layer.get("id")
layout = layer.get("layout") or {}
layer_filter = layer.get("filter")
if layer_id in SIMPLE_ICON_LAYERS:
layout["icon-image"] = ["coalesce", ["get", "icon_id"], ""]
layer["layout"] = layout
elif layer_id == "nav-light-arc":
layout["icon-image"] = ["coalesce", ["get", "arc_id"], ""]
layer["layout"] = layout
elif layer_id in {
"nav-marks-harbor-lighthouses",
"nav-marks-breakwater-lighthouses",
"nav-marks-light-beacons",
"nav-marks",
}:
if layer_filter is not None:
layer["filter"] = restore_canonical_values(layer_filter)
if layer_id == "nav-marks":
layer["layout"] = restore_canonical_values(layout)
return style
@@ -296,7 +324,7 @@ def write_newpec_style() -> None:
write_style(style, NEWPEC_STYLE_OUTPUT, NEWPEC_STYLE_DEPLOY)
def collect_literal_sprite_refs(style: dict[str, Any]) -> set[str]:
def collect_literal_sprite_refs(style: dict[str, Any], sprite_keys: set[str] | None = None) -> set[str]:
refs: set[str] = set()
def walk(value: Any) -> None:
@@ -307,7 +335,9 @@ def collect_literal_sprite_refs(style: dict[str, Any]) -> set[str]:
for child in value:
walk(child)
elif isinstance(value, str):
if (
if sprite_keys is not None and value in sprite_keys:
refs.add(value)
elif (
value.startswith("pattern_fill_")
or value.startswith("fill-daytime-")
or value.startswith("fill_")
@@ -335,11 +365,12 @@ def build_sprite(config: dict[str, Any], style: dict[str, Any]) -> dict[str, Any
source_meta: dict[str, dict[str, dict[str, Any]]] = {}
for filename in ("sprite.json", "sprite@2x.json"):
source_meta[filename] = json.loads((SPRITE_SOURCE / filename).read_text(encoding="utf-8"))
source_sprite_keys = set().union(*(meta.keys() for meta in source_meta.values()))
key_map = dict(config["sprite_key_map"])
key_map.update(STYLE_EXTRA_MAP)
fallback_sources = {"lm_cus": "symbol-daytime-660"}
passthrough_keys = collect_literal_sprite_refs(style)
passthrough_keys = collect_literal_sprite_refs(style, source_sprite_keys)
added: dict[str, str] = {}
for filename, meta in source_meta.items():
# 测试包只改名图标/灯弧fill/line pattern 等非图标纹理必须按 style 原名保留。