Files
Aislo/common_util/common_util_structure_pavement.py
T
eomsangdonandClaude Opus 5.5 bbd6254892 feat(구조물표): 322-1 부품 상자 · 표 읽기 — 목록 · 측점 · 카드 이름 · 형상 고르기 · 3D 몸체 · 알약 띠가 종류 키 · 군 글자 · 자리꼴 · managed_by 대신 구조물 표(catalog) 한 줄을 읽음 · 코드 숨김 목록 걷음 · ★ 넷 + 관 공식 한 벌
- 부품 상자 common_util_structure_parts.json(갈래마다 부품 · 읽는 칸 · 자리꼴 · 정본 · 42종 처음값) · 표 읽기 common_util_structure_catalog.ts / .py 짝(정의 반영 ⊕ 처음값 ⊕ 부품 끔) · 거울 시험 test_322_1_catalog_mirror
- 목록: pickGroups 군 차례 = 구조물군 열쇠 · 페이지 거르기 listPick(B05 both · B06 both + b06) · HIDDEN_PICK_GROUPS · HIDDEN_PICK_TYPES · pickable 걷음(옛 대피 셋 asRoad 그대로)
- 측점: structureStationMarks · pipeStationMarks · is_station_planting_type · resolve_extra_stations = 표 횡단도(anchor · span3 · none)
- 카드 이름: cardTitle / card_title 한 공식(빈칸 = 그 종류 정의 기본값) · 표시 이름이 정의 관종도 앎
- 형상: 벽 = shape wall(형태 = 형상칸.form · 물빼기 = 형상칸.weep) · 포장 = shape pavement(「사용 중」 거르기 없앰) · 맹암거 · 사토 · 관 지점 시설 세트 = shape
- 3D 몸체 = 그림 자료 주인 종류의 표 3D 부품 · 알약 띠 = 표 자리꼴 구간(관 지점 시설은 알약만)
- ★1 노출형 · 개거 횡단도 none · ★2 쇄석 화면에서도 포장층 · ★3 기슭막이 표 자리꼴 interval(정의 파일 그대로) · ★4 코드 숨김 10종 list hidden · ★5 관 빈칸 D800 → 정의 기본 D1000
- 옛 시험: 도움 파일 로더 27개가 표 모듈 공용 한 벌(helper_322_catalog_module) 씀 · 기대값 고침(272_1 · b05_extra_stations · roundtrip · 314 · 52_7 · walls 거울 · wall_drain_pipe)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ji4nuyLVHcxrXWHTdb5nRD
2026-10-14 15:09:45 +09:00

117 lines
4.7 KiB
Python

"""노면공(G군) 구조물 정본 → 횡단 측점 포장 제원(`section.pavement`).
범위(start~end · ±0.02 m) 안 측점마다 `[{type_id, spec, thickness_m, start_m, end_m, widening_on}]`.
두께 = `options.height_m` · 무늬 = `options.pave_spec` · 확폭 끈 구간 = `options.widening_off`("s-e,s-e").
그림 · 정보만 — 토공 면적 · 포장 켜기(`design.paved`)는 건드리지 않음.
**짝**: `common_util/common_util_structure_pavement.ts` — 브라우저는 저장 전 목록으로 같은 제원을 얹음.
거울 시험 `resources/tester/test_b06_structure_pavement_mirror.py`.
"""
import logging
import math
from pathlib import Path
from typing import Any
logger = logging.getLogger(__name__)
# 구간 경계 측점을 구간 안으로 볼 허용 오차(m) — C군 벽(`common_util_structure_walls`)과 같은 값.
_EDGE_TOLERANCE_M = 0.02
def _num(value: Any) -> float | None:
if isinstance(value, bool) or not isinstance(value, (int, float)):
return None
return value if math.isfinite(value) else None
def widening_off_ranges(text: Any) -> list[tuple[float, float]]:
"""「시작-끝,시작-끝」(측점 m) → 구간 목록. 못 읽는 조각은 버림(= 켬)."""
ranges: list[tuple[float, float]] = []
for part in str(text or "").split(","):
bounds = part.split("-")
if len(bounds) != 2 or not bounds[0].strip() or not bounds[1].strip():
continue
try:
start, end = float(bounds[0]), float(bounds[1])
except ValueError:
continue
if math.isfinite(start) and math.isfinite(end):
ranges.append((min(start, end), max(start, end)))
return ranges
def pavement_specs_from(
structures: list[dict[str, Any]], type_ids: set[str]
) -> list[dict[str, Any]]:
"""G군 구조물 → 구간 제원. 범위가 없으면(시작 · 끝 · 기준 모두 빔) 건너뜀."""
specs: list[dict[str, Any]] = []
for item in structures:
if item.get("type_id") not in type_ids:
continue
anchor = _num(item.get("chainage_m"))
start = _num(item.get("start_m"))
end = _num(item.get("end_m"))
start = anchor if start is None else start
end = anchor if end is None else end
if start is None or end is None:
continue
options = item.get("options") or {}
spec = options.get("pave_spec")
specs.append(
{
"type_id": item["type_id"],
"spec": spec if isinstance(spec, str) and spec else None,
"thickness_m": _num(options.get("height_m")),
"start_m": min(start, end),
"end_m": max(start, end),
"widening_off": widening_off_ranges(options.get("widening_off")),
}
)
return specs
def _inside(chainage: float, start: float, end: float) -> bool:
return start - _EDGE_TOLERANCE_M <= chainage <= end + _EDGE_TOLERANCE_M
def attach_pavement_specs(sections: list[dict[str, Any]], specs: list[dict[str, Any]]) -> int:
"""범위 안 측점에 `pavement` 목록을 얹음. 얹은 측점 수를 돌려줌."""
attached = 0
for section in sections:
chainage = _num(section.get("chainage_m"))
if chainage is None:
continue
found = [
{
"type_id": spec["type_id"],
"spec": spec["spec"],
"thickness_m": spec["thickness_m"],
"start_m": spec["start_m"],
"end_m": spec["end_m"],
"widening_on": not any(
_inside(chainage, start, end) for start, end in spec["widening_off"]
),
}
for spec in specs
if _inside(chainage, spec["start_m"], spec["end_m"])
]
if found:
section["pavement"] = found
attached += 1
return attached
def attach_pavement_structures(project_root: Path, cross_sections: list[dict[str, Any]]) -> int:
"""저장된 구조물 정본으로 `section.pavement` 를 얹음. 정본을 못 읽으면 0(비치명)."""
from B05_Profile.B05_Profile_Structures_Repository import load_structures
from common_util.common_util_structure_catalog import type_ids_with
try:
type_ids = type_ids_with(shape="pavement") # 표 형상(322-1 · 옛 G 군)
structures = [item.model_dump() for item in load_structures(str(project_root))[1]]
except Exception: # noqa: BLE001 — 정본을 못 읽어도 횡단 조회는 이어 감
logger.exception("B06 노면공 정본을 읽지 못했습니다 (없는 것으로 본다)")
return 0
return attach_pavement_specs(cross_sections, pavement_specs_from(structures, type_ids))