Files
Aislo/B06_Section/B06_Section_Engine_Tilt.py
T
eomsangdonandClaude Opus 5.5 172ff8170b refactor(511-B B-6 정리): 운영 부름 0 파이썬 짝 걷음 · 남는 짝 머리에 남는 까닭 · 등록부 until 걷음 · 알려진 차 까닭 · 322_3 flow 빨강 고침
걷은 함수(운영 부름 0 · 전수 확인 = 화면 · 서버 · 체인 · 추천 엔진 · B07 · 시험)
- common_util/common_util_excavation.py 통째(126 줄 · pipe_trench_width_m · wall_trench_area_m2 · wall_trench_width_m · 서버 = Node excavation.trench)
- Engine_Grade_Carry.carry_edits(Node carry_seat 겉) · Route_Save_Parts.seat_route_moved(시험 헬퍼 helper_475_1_moved 로 옮김)
- Engine_Tilt.attach_underdrains · Engine_Structures_Wall.attach_wall_structures · load_wall_structures
- Engine_Grade_Alignment.tangent_elevation(부름 0) · station_key.dedupe_station_keys · loose_chainage
줄 수 전 → 후: excavation.py 126 → 0 · Grade_Carry 178 → 157 · Save_Parts 289 → 269 · Wall 221 → 197 · Tilt 115 → 112 · station_key 141 → 122 · Alignment 657 → 654

남는 짝(머리 「남는 까닭」 한 줄) — Grade · Grade_Profile · Alignment · CurveLaw(2~4 순위 폴백 · 추천) · NodeEdits · SampleExtend · Router_Design · Ranges · Engine_Design · Areas · cross_berm(DTM 아닌 지표면 · Node 못 부를 때 · B07 · 추천) · Tilt · Wall · Culvert(B04 B07 B08) · route_follow · structure_station · station_key · route_polyline(745 줄 · 까닭 = 등록부 R1 줄)

등록부 — until 칸 걷음(G1 = py 표본기 남김 · 까닭 note) · C6 pair = attach_underdrain_specs · F8 pair null
알려진 차 — golden KNOWN 셋 그대로 나타남(R7 표본 출처 · W0 저장 때 경고 · X2 입력 선 자릿수 · 까닭 고침) · underdrain 알려진 차 까닭 · 511_b5 KNOWN_ARC 그대로
계산 자리 창 — 45 줄 · 서버만 아닌 41(바꿀 수 있음 40 + F9) · 서버만 넷(G3 D1 D2 N1 줄마다 까닭) · 옛 까닭 「짝 모으는 중 · B-4」 글 걷음
test_322_3_flow 빨강 — 헬퍼가 @config/config_frontend 흉내(511-A design_calc_server import)
시험 기준 — 걷은 짝 거울 = 걷기 전 파이썬 값 고정(excavation · station_key) · Node carry_seat · attach_underdrain_specs · wall_specs_from

검증: 고친 대상 시험 97 파일 562 통과 · 21 건너뜀 · typecheck 0 · 700 줄 넘는 새 파일 없음 — 요구 320-4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 16:34:08 +09:00

113 lines
4.8 KiB
Python

"""구조물 자리 기울기 — 물넘이포장 · 맹암거 측점의 노면(287-4 · 288-1).
그 자리 횡단 설계 = 측구 없음 · 노면 = 한 경사로 지대 낮은 쪽(`compute_cross_design(tilted=…,
tilt_pct=…)`). 경사 = 물넘이 경사각도(%) · 맹암거 = 표준 횡단경사(암거 경사는 형상 하단 · 371-3).
· 물넘이포장 = 관 지점 정본(pipe_points) 범위(기준 ± 월류 폭/2).
· 맹암거 = 구조물 정본(structures.json) A군 점형 · 기준 측점 한 곳 — 횡단 dict 에
`underdrain`(높이 · 경사)을 얹어 횡단도가 돌 무늬 형상을 그림(TS 짝
`common_util_structure_underdrain.ts`).
판정 폭 = 포장 범위와 같은 0.02 m(`paved_at`).
짝(349-0n): `tilt_ranges` · `tilt_args` ↔ `B06_Section/logic/B06_Section_Cross_Enforce.ts`
(거울 시험 `test_349_0n_cross_enforce_mirror.py`).
남는 까닭(511-B B-6) — 얹기 = GET 형상 Node `facility.attach` · 이 짝 = Node 못 부를
때(`_attach_python`) · 파이썬 횡단 설계 폴백 기울기.
"""
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_Sets 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):
# 노면 = 표준 경사 · 암거 경사는 맹암거 하단 경계만(371-3 · TS `facilityRanges` 짝)
out.append((drain["chainage_m"], drain["chainage_m"], None))
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_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