tmp/ 가 창끼리 안 건너가는 것이 확정돼(랩탑이 시간 두고 두 번 확인) 시험·예외가 저절로 건너가도록 git 안으로 옮김. 사용자 확정. - 내용은 하나도 안 고침 — 자리만 옮김. tmp/tests 는 남겨 둠. - 같은 이름이 이미 있던 64 개는 랩탑 것을 그대로 두고 건너뜀. - helper_b05_*.js 둘은 랩탑이 .cjs 로 이미 올린 것과 **줄바꿈만 다른 같은 내용**이라 복사본을 도로 뺌(시험이 .cjs 를 부름). - resources/tester/ 에서 전체 1176 통과 · 29 건너뜀 · 실패 0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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
|