"""카드 미리보기 재료(라이다 점 그림·GeoTIFF 썸네일) 생성 검증 (2026-09-04 사용자 지시).""" import asyncio import sys import time 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_las_preview_points(): from B03_FileInput.B03_FileInput_Engine_Analyze import analyze_las_metadata root = _project_root() files = sorted((root / "B03_FileInput" / "input" / "las").glob("*.la*")) if not files: pytest.skip("LAS 파일이 없습니다.") started = time.perf_counter() meta = analyze_las_metadata(files[0]) elapsed = time.perf_counter() - started points = meta.get("preview_points") or [] print(f"\n{files[0].name}: 점 {meta['point_count']:,}개, 미리보기 점 {len(points)}개, {elapsed:.1f}s") assert 0 < len(points) <= 5000 bounds = meta["bounds"] for x, y in points[:200]: assert bounds["x"][0] - 1 <= x <= bounds["x"][1] + 1 assert bounds["y"][0] - 1 <= y <= bounds["y"][1] + 1 def test_geotiff_thumbnail(): from B03_FileInput.B03_FileInput_Engine_Analyze import analyze_tif_metadata root = _project_root() files = sorted((root / "B03_FileInput" / "input" / "tif").glob("*.tif")) if not files: pytest.skip("GeoTIFF 파일이 없습니다.") started = time.perf_counter() meta = analyze_tif_metadata(files[0]) elapsed = time.perf_counter() - started thumb = meta.get("preview_thumbnail") print(f"{files[0].name}: 썸네일 {'있음 %d바이트' % len(thumb) if thumb else '없음(오버뷰 없음)'}, {elapsed:.1f}s") if thumb: assert thumb.startswith("data:image/png;base64,") assert elapsed < 5.0