"""635-5 B05 경위도 ↔ 사업지 좌표 서버 변환(요구 546) — 속성 판 경위도(찾기 이동 = 755-2 걷음). - 서버 `POST /route/coords` = 작업 좌표계(`resolve_project_crs` · WKT 그대로) pyproj 묶음 변환. - 화면 = 노드 고름 때만 부름 · 같은 점 캐시 · 바탕 `tm_grid` 늘려 쓰기 걷음. ./venv/Scripts/python.exe -m pytest resources/tester/test_635_5_b05_coords.py -q """ from __future__ import annotations from pathlib import Path import pytest from pyproj import Transformer from B05_Profile.B05_Profile_Router_Coords import CoordsRequest, convert ROOT = Path(__file__).resolve().parents[2] B05 = ROOT / "B05_Profile" # 서울 근처 · 50 km · 180 km 떨어진 점(경위도) POINTS = [(127.0, 37.5), (127.5, 37.6), (129.0, 36.5)] @pytest.mark.parametrize("crs", ["EPSG:5176", "EPSG:5186", "EPSG:5179"]) def test_묶음_변환_pyproj_대조_왕복(crs): plan = convert(crs, "plan", POINTS) want = Transformer.from_crs("EPSG:4326", crs, always_xy=True) for (lon, lat), (x, y) in zip(POINTS, plan): wx, wy = want.transform(lon, lat) assert abs(x - wx) < 1e-6 and abs(y - wy) < 1e-6 back = convert(crs, "lonlat", [tuple(p) for p in plan]) for (lon, lat), (blon, blat) in zip(POINTS, back): assert abs(lon - blon) < 1e-7 and abs(lat - blat) < 1e-7 # 1 cm 안(Bessel 왕복) def test_빈_묶음_점_꼴(): assert convert("EPSG:5186", "plan", []) == [] with pytest.raises(ValueError): CoordsRequest(to="plan", points=[[1.0]]) with pytest.raises(ValueError): CoordsRequest(to="tm", points=[]) def test_라우터_등록(): main = (ROOT / "main.py").read_text(encoding="utf-8") assert "app.include_router(b05_coords_router, dependencies=protected_with_company)" in main router = (B05 / "B05_Profile_Router_Coords.py").read_text(encoding="utf-8") assert '@router.post("/{project_id}/route/coords"' in router assert "resolve_project_crs(root, route_crs_input=" in router def test_화면_서버_변환_고름만(): panel = (B05 / "B05_Profile_UI_Panel_Plan.ts").read_text(encoding="utf-8") assert "`/projects/${projectId}/route/coords`" in panel # requestJson 이 /api 를 붙임 assert "known.has(key)" in panel # 같은 점 캐시 ui = (B05 / "B05_Profile_UI_ExpectedDraw.ts").read_text(encoding="utf-8") assert "lonLat: coords.lonLat," in ui and "toPlan" not in ui + panel assert "normOfLonLat" not in ui and "tm_grid` 늘려" not in ui # 끌기 중엔 판을 안 그림 — 속성 판은 고름 · 놓음(commit) 때만 kit = (ROOT / "D03_PlanAnalysis" / "D03_PlanAnalysis_UI_Kit.ts").read_text(encoding="utf-8") assert "lonLat: params.lonLat," in kit