- 데이터 = bases[](id · to = 시점 또는 다른 기준점 · linked) · 경로 via_base 대신 to - 옛 꼴(base · via_base) = 읽을 때 · 받을 때 새 꼴로 옮김(migrate 짝 Py · TS · 저장 = 새 꼴) - 행 합 = 거래처 구간 + 기준점 사슬 구간들(방문 집합으로 돌기 끊음 · 안 이은 기준점에서 멈춤) - 도로 구분 = 시점에 닿는 기준점 구간 1차 · 그 밖 기준점 구간 · 거래처 → 기준점 2차 - 화면 = 기준점 여럿 등록 · 삭제(이은 상자 안 이음) · 연결 놓기 = 기준점 id · 길찾기 · 표지 사슬 - 시험 = test_254_1 새로 · 244 · 250 기대값 새 꼴로 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01STqEqztUthVFBmEP18wBSz
72 lines
3.1 KiB
Python
72 lines
3.1 KiB
Python
"""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 - 200 # 북 = 위(옛 「서」 무시)
|
|
(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 "방위는 이 자리로 자동" in base # 244-13 — 기준점 = 등록 모달 분류 기준위치
|
|
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
|