feat(b08): 거리이정표 기준점 방위 칸 없앰 — 주소 좌표로 자리 · 없으면 공사지 서쪽 (244-5)
- 좌측 패널 「공사지에서 본 방위」 칸 · 8방 고르기 지움 · 옛 저장 값 방위는 무시 - 기준점 모달에 「주소를 고르면 실제 방위로 놓임」 안내 한 줄 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01STqEqztUthVFBmEP18wBSz
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
"""244-5 B08 거리이정표 기준점 방위 칸 없앰 — 기준점 자리 = 주소 좌표 → 공사지 기준 방위각 ·
|
||||
좌표 없으면 공사지 서쪽(견본) · 옛 저장 값의 방위(dir)는 무시.
|
||||
"""
|
||||
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
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": []}
|
||||
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["base"]
|
||||
|
||||
|
||||
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 and 'label: "기준점 주소"' in state
|
||||
modal = _read("B08_Quantity/B08_Quantity_UI_Milestone_Modal.ts")
|
||||
base = modal[modal.index("export function openBaseInfo") : modal.index("interface SiteAddress")]
|
||||
assert "주소를 고르면 다이어그램에 실제 방위로 놓임" in base
|
||||
layout = _read("B08_Quantity/B08_Quantity_Milestone_Layout.ts")
|
||||
assert (
|
||||
"placeDeg({ dir: null, lon: data.base.lon, lat: data.base.lat }, startLL) ?? 270" in layout
|
||||
)
|
||||
Reference in New Issue
Block a user