Files
Aislo/B06_Section/B06_Section_Engine_Tilt.py
T
eomsangdonandClaude Opus 5.5 81f7d98e6f feat(구조물표): 323-7 새 종류 · 정리 — M02 종류 더하기(본보기 복사 · 일곱 갈래 본보기 그대로) · 손코딩 동작 · 명세 = 본보기 키 · 특수 동작 = 동작 이름 · 정본 목록 = 표 · drawing_views 걷음 · 옛 이름 되짚기 걷음(자리로 가름) · 허용 거리 파이썬 한 곳 · 벽 툴팁 = 종류 이름
- 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
2026-10-14 18:59:13 +09:00

113 lines
4.6 KiB
Python

"""구조물 자리 기울기 — 물넘이포장 · 맹암거 측점의 노면(287-4 · 288-1).
그 자리 횡단 설계 = 측구 없음 · 노면 = 한 경사로 지대 낮은 쪽(`compute_cross_design(tilted=…,
tilt_pct=…)`). 경사 = 물넘이 경사각도(%) · 맹암거 암거 경사(%) · 비면 표준 횡단경사.
· 물넘이포장 = 관 지점 정본(pipe_points) 범위(기준 ± 월류 폭/2).
· 맹암거 = 구조물 정본(structures.json) A군 점형 · 기준 측점 한 곳 — 횡단 dict 에
`underdrain`(높이 · 경사)을 얹어 횡단도가 돌 무늬 형상을 그림(TS 짝
`common_util_structure_underdrain.ts`).
판정 폭 = 포장 범위와 같은 0.02 m(`paved_at`).
"""
from __future__ import annotations
import logging
from pathlib import Path
from typing import Any
from B05_Profile.B05_Profile_Structures_Repository import load_structures
from B06_Section.B06_Section_Engine_Culvert import load_culvert_sets
from common_util.common_util_structure_catalog import catalog_row
from common_util.common_util_structure_station import EDGE_TOLERANCE_M
logger = logging.getLogger(__name__)
_EDGE_TOLERANCE_M = EDGE_TOLERANCE_M
TiltRange = tuple[float, float, float | None]
def _number(value: Any) -> float | None:
try:
parsed = float(value)
except (TypeError, ValueError):
return None
return parsed if parsed == parsed else None
def load_underdrains(project_root: Path) -> list[dict[str, Any]]:
"""구조물 정본의 맹암거 — `{structure_id, chainage_m, height_m, slope_pct}` ·
실패하면 빈 목록."""
try:
structures = load_structures(str(project_root))[1]
except Exception: # noqa: BLE001 — 정본을 못 읽어도 설계 계산은 이어 간다
logger.exception("B06 맹암거를 읽지 못했습니다 (없음으로 본다)")
return []
return underdrains_from(structures)
def underdrains_from(structures: list[Any]) -> list[dict[str, Any]]:
"""구조물 목록의 맹암거 제원(TS `underdrainSpecsFrom` 짝 · 형상 얹기 한 벌 323-4)."""
found: list[dict[str, Any]] = []
for structure in structures:
if (catalog_row(structure.type_id) or {}).get("shape") != "underdrain":
continue
options = structure.options or {}
height = _number(options.get("culvert_height_m"))
slope = _number(options.get("culvert_slope_pct"))
found.append(
{
"structure_id": structure.structure_id,
"chainage_m": float(structure.anchor_m()),
"height_m": height if height and height > 0 else None,
"slope_pct": slope if slope and slope > 0 else None,
}
)
return found
def tilt_ranges(project_root: Path | None) -> list[TiltRange]:
"""측구 없이 노면을 지대 낮은 쪽 한 경사로 기울이는 자리 — (시작, 끝, 경사 %)."""
if project_root is None:
return []
out: list[TiltRange] = []
for at, spec in load_culvert_sets(project_root).items():
if spec.get("type") == "ford_pavement":
half = float(spec.get("span_m") or 0.0) / 2.0
out.append((at - half, at + half, spec.get("slope_pct")))
for drain in load_underdrains(project_root):
out.append((drain["chainage_m"], drain["chainage_m"], drain["slope_pct"]))
return out
def tilt_args(chainage_m: float, ranges: list[TiltRange]) -> dict[str, Any]:
"""그 측점의 구조물 자리 기울기 — `compute_cross_design(**...)` 로 넘김 ·
저장분 짝 `stored_tilt`."""
tol = _EDGE_TOLERANCE_M
hit = next((r for r in ranges if r[0] - tol <= chainage_m <= r[1] + tol), None)
pct = hit[2] if hit else None
return {"tilted": hit is not None, "tilt_pct": float(pct) if pct is not None else None}
def attach_underdrains(project_root: Path, cross_sections: list[dict[str, Any]]) -> int:
"""맹암거 기준 측점의 횡단 dict 에 `underdrain` 을 얹는다. 얹은 개수를 돌려준다."""
return attach_underdrain_specs(cross_sections, load_underdrains(project_root))
def attach_underdrain_specs(
cross_sections: list[dict[str, Any]], drains: list[dict[str, Any]]
) -> int:
"""기준 측점에 맹암거 제원을 얹는다(TS `attachUnderdrainSpecs` 짝). 얹은 개수를 돌려준다."""
attached = 0
for section in cross_sections:
chainage = _number(section.get("chainage_m"))
if chainage is None:
continue
hit = next(
(d for d in drains if abs(d["chainage_m"] - chainage) <= _EDGE_TOLERANCE_M), None
)
if hit:
section["underdrain"] = dict(hit)
attached += 1
return attached