fix: preserve S-52 multi-light arcs

This commit is contained in:
OpenAI Codex
2026-09-19 15:56:37 +08:00
parent 472acd6938
commit 8ac774dff1
10 changed files with 471 additions and 12 deletions

View File

@@ -179,6 +179,7 @@ USAGE_PRESENCE_FIELDS = (
*USAGE_VALUE_FIELDS,
"s52_text_literal",
"s52_light_label_text",
"s52_light_presentations",
"s52_light_rotation_deg",
"s52_text1_value",
"s52_text2_value",
@@ -186,6 +187,20 @@ USAGE_PRESENCE_FIELDS = (
)
def _parse_light_presentations(props: dict[str, Any]) -> list[dict[str, Any]]:
raw = props.get("s52_light_presentations")
if raw in (None, ""):
return []
if isinstance(raw, str):
try:
raw = json.loads(raw)
except Exception:
return []
if not isinstance(raw, list):
return []
return [dict(item) for item in raw if isinstance(item, dict)]
def _scan_pbf_usage(path: Path) -> dict[str, Any]:
try:
import mapbox_vector_tile
@@ -251,7 +266,17 @@ def _scan_pbf_usage(path: Path) -> dict[str, Any]:
render_kind_counts["TXTE"][placement] += 1
if props.get("s52_csp_resolved") == "LIGHTS05" and "s52_text_literal" in props:
render_kind_counts["LIGHT_TX"][placement] += 1
if "s52_arc_color" in props:
light_presentations = _parse_light_presentations(props)
if light_presentations:
for presentation in light_presentations:
nested_placement = (
layer_name,
str(presentation.get("s52_display_priority") or priority),
str(presentation.get("s52_display_category") or category),
)
if presentation.get("s52_arc_color"):
render_kind_counts["RUNTIME_CA"][nested_placement] += 1
elif "s52_arc_color" in props:
render_kind_counts["RUNTIME_CA"][placement] += 1
for field in USAGE_PRESENCE_FIELDS:
if field not in props: