Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F3mdb91125mPoC6tpsQx4P
73 lines
2.7 KiB
Python
73 lines
2.7 KiB
Python
"""139-6 [저장] 때 서버가 모든 측점 설계선을 저장 입력으로 다시 냄 — 노견 확장이 설계선에 들어감.
|
|
|
|
그전에는 포장 · 세월교 · 사토장 측점만 다시 냈고 보통 측점은 브라우저 설계를 받아 적음
|
|
(`B07` 이 저장된 선을 그려 쉬프트가 안 보였을 자리).
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
|
if str(PROJECT_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(PROJECT_ROOT))
|
|
|
|
from B06_Section.B06_Section_Engine_Design import ( # noqa: E402
|
|
compute_cross_design,
|
|
stored_shoulder_extend,
|
|
)
|
|
from B06_Section.B06_Section_Router_Design import enforce_design_lines # noqa: E402
|
|
|
|
|
|
def _ground(slope: float) -> list[dict]:
|
|
return [
|
|
{"offset_m": o / 2, "elevation_m": round(100.0 + slope * o / 2, 4), "valid": True}
|
|
for o in range(-24, 25)
|
|
]
|
|
|
|
|
|
LONG = {
|
|
"design_profiles": [
|
|
{
|
|
"samples": [
|
|
{"chainage_m": 0, "elevation_m": 100.4},
|
|
{"chainage_m": 200, "elevation_m": 100.4},
|
|
]
|
|
}
|
|
]
|
|
}
|
|
|
|
|
|
def test_저장값_없으면_0_음수_0() -> None:
|
|
assert stored_shoulder_extend(None) == {
|
|
"shoulder_extend_left_m": 0.0,
|
|
"shoulder_extend_right_m": 0.0,
|
|
}
|
|
got = stored_shoulder_extend({"shoulder_extend_left_m": 0.7, "shoulder_extend_right_m": -1})
|
|
assert got == {"shoulder_extend_left_m": 0.7, "shoulder_extend_right_m": 0.0}
|
|
|
|
|
|
def test_저장_때_노견_확장_설계선이_다시_나옴(tmp_path: Path) -> None:
|
|
samples = _ground(0.35)
|
|
old = compute_cross_design(samples, 100.4, ground_type="soil", section_mode="left_cut")
|
|
# 브라우저 patch 가 사용자 값만 얹은 꼴 — 설계선 · 노견 끝은 옛 값 그대로
|
|
stored = {
|
|
**old,
|
|
"shoulder_extend_left_m": 0.7,
|
|
"revet_adjust": {"outlet": {"x": 1.0, "d": None, "h": None, "m": None}},
|
|
}
|
|
sections = [{"chainage_m": 100.0, "samples": samples, "design": stored}]
|
|
assert enforce_design_lines(LONG, sections, tmp_path) == 1
|
|
design = sections[0]["design"]
|
|
assert design["road_edges"]["left"]["offset_m"] == old["road_edges"]["left"]["offset_m"] + 0.7
|
|
assert design["road_edges"]["right"] == old["road_edges"]["right"]
|
|
assert design["shoulder_extend_left_m"] == 0.7
|
|
assert design["revet_adjust"] == stored["revet_adjust"] # 사용자 값 승계
|
|
assert design["design_line"] != old["design_line"]
|
|
|
|
|
|
def test_서버_재계산이_먼저_돌고_미교차_판정은_그_뒤() -> None:
|
|
src = (PROJECT_ROOT / "B06_Section" / "B06_Section_Server_Calc_Prebuild.py").read_text(
|
|
encoding="utf-8"
|
|
)
|
|
assert src.index("enforce_design_lines, detail.get") < src.index("unclosed = any(")
|