"""244-5 B08 거리이정표 기준점 방위 칸 없앰 — 기준점 자리 = 주소 좌표 → 공사지 기준 방위각 · 좌표 없으면 공사지 서쪽(견본) · 옛 저장 값의 방위(dir)는 무시. """ import json import re import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[2] if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT)) from B08_Quantity.B08_Quantity_Milestone_Calc import migrate_milestone # noqa: E402 IMPORTS = re.compile(r"^import[^;]*;\n", re.MULTILINE) def _read(rel): return (ROOT / rel).read_text(encoding="utf-8") def _layout(base, site): data = {"site": {"mid_station_m": None, "mid_road": "비포장"}, "base": base, "routes": []} data = migrate_milestone(data) # 254 옛 꼴 → bases(옛 기준점 = b1) src = IMPORTS.sub("", _read("B08_Quantity/B08_Quantity_Milestone_Layout.ts")) expr = f"layoutMilestone({json.dumps(data)}, {json.dumps(site)}, 0)" result = subprocess.run( ["node", "--experimental-strip-types", "--no-warnings", "--input-type=module-typescript", "-e", src + f"\nconsole.log(JSON.stringify({expr}));"], capture_output=True, text=True, encoding="utf-8", timeout=60, ) # fmt: skip assert result.returncode == 0, result.stderr lay = json.loads(result.stdout) center = {b["id"]: (b["x"] + b["w"] / 2, b["y"] + b["h"] / 2) for b in lay["boxes"]} return center["site"], center["b1"] BASE = {"enabled": True, "name": "기준", "address": "", "legs": []} SITE = {"start_lonlat": [127.8, 35.7], "mid_lonlat": None} def test_좌표_없음_서쪽_옛_방위_무시(): for site in (SITE, None): (cx, cy), (bx, by) = _layout({**BASE, "dir": "E"}, site) assert bx < cx - 200 and abs(by - cy) < 1 # 옛 「동」 무시 · 서(왼) def test_좌표_있음_공사지_기준_방위각(): (cx, cy), (bx, by) = _layout({**BASE, "dir": "W", "lon": 127.8, "lat": 35.8}, SITE) assert abs(bx - cx) < 1 and by < cy - 150 # 북 = 위(옛 「서」 무시 · 254 최소 선 길이) (cx, cy), (bx, by) = _layout({**BASE, "dir": None, "lon": 127.9, "lat": 35.7}, SITE) assert bx > cx + 200 and abs(by - cy) < 1 # 동 = 오른 # 시점 좌표 모름 = 서쪽 기본 (cx, cy), (bx, by) = _layout({**BASE, "lon": 127.9, "lat": 35.7}, None) assert bx < cx - 200 def test_좌측_패널_방위_칸_없음_모달_안내(): state = _read("B08_Quantity/B08_Quantity_UI_Milestone_State.ts") assert "공사지에서 본 방위" not in state and "dirOptions" not in state assert "d.base.dir" not in state # 244-6 — 기준점 칸은 다이어그램 기준점 모달로 modal = _read("B08_Quantity/B08_Quantity_UI_Milestone_Modal.ts") base = modal[ modal.index("export function openPlaceModal") : modal.index("interface SiteAddress") ] assert ( "placePicker(" in base and "방위는 이 자리로 자동" not in base ) # 255-3 소재지 머리 줄 지움 layout = _read("B08_Quantity/B08_Quantity_Milestone_Layout.ts") assert "placeDeg({ dir: null, lon: b.lon, lat: b.lat }, anchorLL) ??" in layout assert '(anchor === "site" && !used.has(keyOf("site", 270)) ? 270 : free(anchor))' in layout