# -*- coding: utf-8 -*- """433-11 — 덧 측점 넣기 · 빼기 뒤 브라우저 누가토량 = 서버(0.1 ㎥ 안). 뿌리: 갈아끼움이 안 바뀐 측점까지 지반 표본 · 상단측 · 중심고를 브라우저 지형 값으로 갈음. 못박는 것 - 자리 · 축이 같은 앞 단면 = 서버 표본 · 중심고 그대로 · 새 측점만 브라우저 표본. - 덧 측점 넣은 뒤 누가토량 = 서버 기준(저장 표본 + 새 측점) · 빼면 저장 값 그대로. - 노선이 옮겨 간 측점(좌표 다름)은 새 지형 표본. - 고치기 전 꼴(모든 측점 브라우저 표본)은 1 ㎥ 넘게 어긋남(시험이 차를 잼). Node 헬퍼 `helper_433_swap.cjs` — 진짜 갈아끼움 · 횡단 엔진 · 유토. """ import json import subprocess import sys from pathlib import Path import pytest HERE = Path(__file__).resolve().parent ROOT = HERE.parents[1] if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT)) from config.config_system import STANDARD_CROSS_SECTION # noqa: E402 from config.config_system_design import EARTHWORK_CONVERSION_FACTORS # noqa: E402 TOL_M3 = 0.1 @pytest.fixture(scope="module") def plus(tmp_path_factory): work = tmp_path_factory.mktemp("b433_11") standard = work / "standard.json" conversion = work / "conversion.json" standard.write_text(json.dumps(STANDARD_CROSS_SECTION), encoding="utf-8") conversion.write_text(json.dumps(EARTHWORK_CONVERSION_FACTORS), encoding="utf-8") proc = subprocess.run( ["node", str(HERE / "helper_433_swap.cjs"), str(standard), str(conversion)], cwd=ROOT, capture_output=True, text=True, encoding="utf-8", timeout=120, ) assert proc.returncode == 0, proc.stderr return json.loads(proc.stdout)["plus"] def _max_gap(a, b): assert [p[0] for p in a] == [p[0] for p in b] return max(abs(x[1] - y[1]) for x, y in zip(a, b)) def test_안_바뀐_측점은_서버_표본_중심고(plus): assert plus["keptSamples"] assert plus["keptCenterZ"] == plus["savedCenterZ"] assert plus["newSamples"] def test_덧_측점_넣은_뒤_누가토량_서버와_같음(plus): assert _max_gap(plus["browser"], plus["server"]) < TOL_M3 def test_덧_측점_뺀_뒤_저장_값_그대로(plus): assert _max_gap(plus["back"], plus["saved"]) < TOL_M3 def test_고치기_전_꼴은_어긋남(plus): assert _max_gap(plus["allBrowser"], plus["server"]) > 1.0 def test_노선이_옮긴_측점은_새_지형(plus): assert plus["shiftedFresh"]