89 lines
3.0 KiB
Python
89 lines
3.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""582 등고선 줌 단계 색인 · 글 폭 기억 — 그림 그대로(D03 먼저).
|
|
|
|
- 색인 붙인 레이어 = 안 붙인 레이어와 그리기 명령(차례 · 좌표)이 똑같음 — 여러 줌 · 자리 ·
|
|
닫힌 고리 · 짧은 조각(색인 없음) · 간격 거름(25 m)
|
|
- 고른 단은 「무게 ≥ 허용 오차」 정점을 모두 담고 원래 차례 · 아주 확대하면 색인 없이 전부 훑음
|
|
- 다 줌아웃에서 훑는 정점이 줄어듦
|
|
- 글 폭 기억 = 같은 글 · 같은 자리 · 두 번째부터 재지 않음
|
|
- 색인 · 바탕 캔버스는 D03 만 켬(B04 · B05 는 안 부름)
|
|
|
|
Node 헬퍼(`helper_582_contour_lod.cjs`)가 진짜 TS 를 가짜 캔버스로 돌린다.
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
ROOT = Path(HERE).parents[1]
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def r():
|
|
proc = subprocess.run(
|
|
["node", os.path.join(HERE, "helper_582_contour_lod.cjs")],
|
|
capture_output=True,
|
|
text=True,
|
|
encoding="utf-8",
|
|
timeout=120,
|
|
)
|
|
assert proc.returncode == 0, proc.stderr
|
|
return json.loads(proc.stdout)
|
|
|
|
|
|
def test_조각_갈래가_다_있음(r):
|
|
assert r["lodParts"] > 20
|
|
assert r["shortParts"] > 10
|
|
assert r["closedParts"] > 10
|
|
|
|
|
|
def test_색인으로_그린_명령이_지금과_같음(r):
|
|
assert len(r["cases"]) == 27
|
|
for case in r["cases"]:
|
|
assert case["same"], case
|
|
# 줌 · 자리마다 그린 정점 수가 실제로 달라짐(거름이 일함)
|
|
assert len({c["vertices"] for c in r["cases"]}) > 15
|
|
assert all(c["vertices"] > 0 for c in r["cases"] if c["scale"] <= 13)
|
|
|
|
|
|
def test_고른_단은_남는_정점을_모두_담음(r):
|
|
assert r["supersetOk"]
|
|
assert r["noLodFinest"]
|
|
|
|
|
|
def test_다_줌아웃_훑기가_줄어듦(r):
|
|
assert r["scannedRatio"] < 0.5
|
|
|
|
|
|
def test_글_폭_기억은_같은_글(r):
|
|
for case in r["cases"]:
|
|
assert case["labelsSame"], case
|
|
assert case["labelsRepeatSame"], case
|
|
assert case["labelMeasuredCached"] == 0
|
|
assert any(c["labelMeasuredPlain"] > 0 for c in r["cases"])
|
|
|
|
|
|
def _read(rel: str) -> str:
|
|
return (ROOT / rel).read_text(encoding="utf-8")
|
|
|
|
|
|
def test_D03_만_켬():
|
|
layers = _read("D03_PlanAnalysis/D03_PlanAnalysis_UI_Layers.ts")
|
|
assert "indexLayerLod(prepare(collection" in layers
|
|
# 581-1 합침 — 겹 모두 바탕 캔버스
|
|
assert layers.count("base: true") == layers.count("draw: (context, map)") >= 12 # 겹 모두 바탕(581 · 584 로 늘어남)
|
|
plan_map = _read("D03_PlanAnalysis/D03_PlanAnalysis_UI_Map.ts")
|
|
assert "requestAnimationFrame(flush)" in plan_map
|
|
assert "drawTop();" in plan_map
|
|
users = [
|
|
p.relative_to(ROOT).as_posix()
|
|
for folder in ("B04_PreProcess", "B05_Profile", "B06_Section", "A00_Common")
|
|
for p in (ROOT / folder).rglob("*.ts")
|
|
if "indexLayerLod(" in p.read_text(encoding="utf-8")
|
|
]
|
|
assert users == ["B04_PreProcess/logic/B04_PreProcess_UI_MapRender_Prepare.ts"]
|