Files
Aislo/B07_DesignDetail/B07_DesignDetail_Router_Support_Io.py
eomsangdonandClaude Opus 5 4280a6d821 chore(B07): 아무도 안 쓰는 빈-도각 목록 삭제 — 덫만 남아 있었음
`Router_Support_Io.BLANK_DRAWINGS` 일곱 줄(계획평면도 3종·라이다·표준 횡단면도·표준도·
용지도)이 **어느 모듈도 import 하지 않는 죽은 목록**이었음. 일곱 전부 실제 도면이 되면서
차례로 빠졌고 표준도가 마지막이었음(2026-09-09).

남겨 두면 「계획평면도가 빈 도각으로 열리나?」로 읽히는 덫임.

확인 — 실제 파일로 도면 목록을 만들어 봄(프로젝트 936be972)
  도면 36장 · kind 별 longitudinal 3 · cross 20 · plan 3 · plan_lidar 1 · landuse 1 ·
  cover 1 · cross_standard 1 · mass_haul 1 · watershed 1 · **standard 4**
  **blank 0** — 빈-도각 경로를 타는 도면이 하나도 없음.
  표준도 넉 장 제목에 판정된 기울기가 뜸(메 1:0.35 · 찰 1:0.3).

`build_blank_drawing` 자체는 남김 — 도각 표제란 시험이 쓰고, 다음에 또 「목록엔 있는데
아직 안 그리는」 도면이 생기면 그 함수가 쓰임.

자체검증 — 회귀 573 통과 · 0 실패.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 20:09:56 +09:00

80 lines
2.9 KiB
Python

"""B07 도면 조립 지원 — 원본 JSON·매니페스트 읽기/쓰기와 측점 대응표.
지원 모듈이 700줄을 넘어 떼어냈다(2026-09-04). 유역도 조각과 본체가 함께 쓴다.
"""
import json
import logging
import re
from pathlib import Path
from typing import Any
from B05_Profile.B05_Profile_Engine_Sections import prune_stale_cross_files
logger = logging.getLogger(__name__)
_STAGE_DIR = "B07_DesignDetail"
_CROSS_ID = re.compile(r"^cross_(\d+)m$")
_LONG_ID = re.compile(r"^longitudinal(?:_(\d+))?$")
# 노선 전장에 한 장씩만 나오는 도면 — 라우터가 원본 자료를 따로 실어 넘긴다.
MASS_HAUL_ID = "mass_haul"
WATERSHED_ID = "watershed"
COVER_ID = "cover"
# ⚠ 빈-도각 목록이 여기 있었다 — 계획평면도·표준 횡단면도·용지도·표준도 일곱 줄.
# 2026-09-09 지웠다: 일곱 **전부 실제 도면이 되어** 아무도 이 목록을 import 하지 않았다
# (표준도가 마지막이었다). 남겨 두면 「계획평면도가 빈 도각으로 열리나?」로 읽히는 덫이다.
def _read_json(path: Path) -> dict[str, Any]:
payload = json.loads(path.read_text(encoding="utf-8"))
if not isinstance(payload, dict):
raise ValueError("도면 원본 JSON 형식이 올바르지 않습니다.")
return payload
def _cross_files(longitudinal_path: Path, longitudinal: dict[str, Any]) -> list[Path]:
cross_dir = longitudinal_path.parent.parent / "cross_sections"
if not cross_dir.is_dir():
raise FileNotFoundError("B06 횡단면 파일을 찾을 수 없습니다.")
stations = longitudinal.get("stations")
valid_names = prune_stale_cross_files(cross_dir, stations if isinstance(stations, list) else [])
files = sorted(cross_dir.glob("cross_*.json"))
if valid_names:
files = [path for path in files if path.name in valid_names]
return files
def _station_map(longitudinal: dict[str, Any]) -> dict[int, dict[str, Any]]:
stations = longitudinal.get("stations", [])
if not isinstance(stations, list):
return {}
return {
round(float(station.get("chainage_m", 0))): station
for station in stations
if isinstance(station, dict)
}
def _design_root(project_root: Path) -> Path:
return project_root / _STAGE_DIR
def _read_manifest(project_root: Path) -> dict[str, Any]:
path = _design_root(project_root) / "manifest.json"
if not path.is_file():
return {"drawings": {}}
payload = _read_json(path)
return payload if isinstance(payload.get("drawings"), dict) else {"drawings": {}}
def _write_manifest(project_root: Path, manifest: dict[str, Any]) -> None:
stage_root = _design_root(project_root)
stage_root.mkdir(parents=True, exist_ok=True)
path = stage_root / "manifest.json"
temporary = path.with_suffix(".tmp")
temporary.write_text(json.dumps(manifest, ensure_ascii=False, indent=2), encoding="utf-8")
temporary.replace(path)