ruff 글로브를 `resources/tester/*.py` 로 넓게 잡아 내 작업과 무관한 시험 파일까지 서식이 바뀌었음. 다른 창이 그 파일을 만지면 충돌만 남으므로 되돌림. 내가 실제로 고친 다섯(열쇠 장부·Z01 둘·표 읽기·못 읽은 표)만 남김. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsGw1Dz9HmhuAxGisxmDPF
76 lines
2.6 KiB
Python
76 lines
2.6 KiB
Python
"""실제 노선(용화_LAS)에 사용 범위를 걸면 그 구간만 남는지 (2026-09-04 사용자 지시)."""
|
|
|
|
import asyncio
|
|
import math
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
sys.path.append(str(ROOT))
|
|
|
|
PROJECT_ID = "5cff3920-a181-4a3d-bec0-e0ac4082b75d" # 용화_LAS
|
|
|
|
|
|
def _project_root() -> Path:
|
|
import aiomysql
|
|
|
|
from common_util.common_util_storage import resolve_stored_project_path
|
|
from config.config_db import DB_HOST, DB_NAME, DB_PASSWORD, DB_PORT, DB_USER
|
|
|
|
async def run():
|
|
conn = await aiomysql.connect(
|
|
host=DB_HOST, port=DB_PORT, user=DB_USER, password=DB_PASSWORD,
|
|
db=DB_NAME, charset="utf8mb4",
|
|
)
|
|
try:
|
|
async with conn.cursor(aiomysql.DictCursor) as cursor:
|
|
await cursor.execute(
|
|
"SELECT storage_path FROM projects WHERE id = %s", (PROJECT_ID,)
|
|
)
|
|
return await cursor.fetchone()
|
|
finally:
|
|
conn.close()
|
|
|
|
row = asyncio.run(run())
|
|
if not row:
|
|
pytest.skip("용화_LAS 프로젝트가 없습니다.")
|
|
return Path(resolve_stored_project_path(row["storage_path"]))
|
|
|
|
|
|
def test_range_clips_real_route():
|
|
from common_util.common_util_route_geometry import load_design_route
|
|
|
|
project_root = _project_root()
|
|
# surface_params 없이 = 정본 CSV 지름길을 타지 않는 원본 판독 경로.
|
|
full = load_design_route(project_root)
|
|
if full is None:
|
|
pytest.skip("계획노선을 읽지 못했습니다.")
|
|
total = full.vertices[-1].chainage_m
|
|
clipped = load_design_route(project_root, None, (100.0, 400.0))
|
|
assert clipped is not None
|
|
length = clipped.vertices[-1].chainage_m
|
|
print(f"\n전 구간 {total:.1f}m → 범위 100~400m 적용 {length:.1f}m")
|
|
assert abs(length - 300.0) < 1.0
|
|
# 시점이 원 노선의 100m 자리와 같은 좌표인지.
|
|
walked = 0.0
|
|
target = None
|
|
for index in range(1, len(full.vertices)):
|
|
a = full.vertices[index - 1]
|
|
b = full.vertices[index]
|
|
step = math.dist((a.x, a.y), (b.x, b.y))
|
|
if walked + step >= 100.0:
|
|
ratio = (100.0 - walked) / (step or 1)
|
|
target = (a.x + (b.x - a.x) * ratio, a.y + (b.y - a.y) * ratio)
|
|
break
|
|
walked += step
|
|
assert target is not None
|
|
start = clipped.vertices[0]
|
|
assert math.dist((start.x, start.y), target) < 0.5
|
|
|
|
# 비우면 전 구간 그대로.
|
|
same = load_design_route(project_root, None, (None, None))
|
|
assert same is not None
|
|
assert abs(same.vertices[-1].chainage_m - total) < 1e-6
|