- POST /api/projects/{id}/route/coords — 작업 좌표계(resolve_project_crs · WKT 그대로) pyproj 묶음 변환
- 찾기 이동 = 서버 변환 좌표 · 바탕 tm_grid 늘려 쓰기(ponytail) 걷음
- 키트 lonLat = 노드 고를 때 한 번 묻기 · 같은 점 캐시
- test_635_3 찾기 줄 = 서버 변환 부름으로 고침(옛 tm_grid 부름 걷힘)
- 실측 검증_sub6 B: 50.4 km · 181.2 km 찾기 이동 어긋남 0.000 m · 경위도 = pyproj
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
2.7 KiB
Python
63 lines
2.7 KiB
Python
"""635-5 B05 경위도 ↔ 사업지 좌표 서버 변환(요구 546) — 찾기 이동 · 속성 판 경위도.
|
|
|
|
- 서버 `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 "coords.toPlan(hit.lon, hit.lat)" in ui and "lonLat: coords.lonLat," in ui
|
|
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
|