- M02 종류별 탭 [종류 더하기] = 본보기(구조물 정본 원본) 복사 — 키 자동 · 이름 「본보기 2」 · 옵션 · 표시 · 그룹 · 배치 · 규칙 · 종류 덧칸 · 반영 그대로 · 종류.{새}.본보기 · 관 지점 종류 · 복사본은 본보기 밖
- 구조물 표 = 본보기 처음값 이어받음(resolveCatalog · resolve_catalog 짝 · 줄 칸 base) · baseType/base_type · specFor(명세) · 덧단 · 길이 전후 풀기 · 옹벽 추가 단 콘크리트
- 검사(화면 = 서버 짝) — 본보기 = 원본 · 같은 군 · 자리꼴 · 정본 · 만든 뒤 고정 · 복사본은 본보기가 숨긴 칸 이어받음 · 서버 덧칸 본보기 받음
- 특수 동작 = 동작 이름 — 바로 안 놓기 · 포장 나누기 = 포장_물넘이_겹침 · 월류 높이 기다림 = 월류단면
- 정본 목록 = 표 — 파이썬 관 지점 종류 = catalog owner · B05 시설 서브폼 = 표 형상 · 안 쓰는 손 목록 걷음
- drawing_views — 스키마에서 빼고 읽을 때 버림 · M02 [저장] 때 빠짐(코드는 마스터 안 고침)
- 이관 = 지난 판 이름 대신 측점 계획 자리(planted)로 가름 · all_type_names 걷음
- 허용 거리 = common_util_structure_station.py 한 곳(SAME_STATION_M · EDGE_TOLERANCE_M · PIPE_MATCH_M) · TS 표는 station.ts 머리
- 시험: test_323_7_new_type(템플릿 · 일곱 갈래 · 그림 · 검사 짝 · 서버 읽기) · 322-0 유령 시험 = 자리 · 옛 도움 파일 동작 · 표 길 · 기대 글 고침
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ji4nuyLVHcxrXWHTdb5nRD
119 lines
4.8 KiB
Python
119 lines
4.8 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
|
|
|
|
from common_util.common_util_structure_station import EDGE_TOLERANCE_M
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# 구간 경계 측점을 구간 안으로 볼 허용 오차(m) — 같은 자리 거리 한 곳(323-7)
|
|
_EDGE_TOLERANCE_M = EDGE_TOLERANCE_M
|
|
|
|
|
|
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))
|