feat(640-1): 라이다 기본 고름 — 확정 implicit · 평활 끔 · 분류 덮임 조건 · implicit 기본 필터에만

- 확정 기본 표현 implicit · 평활 False · WF1 자동 짓기에 확정 표현 더함(SURFACE_AUTO_METHODS 는 dtm 그대로)
- 「분류 있음」 자동 고름 = 비율 0.2 % + 10 m 칸 덮임 50 % · 덮임 저장본(classification_coverage.json · 점군 안 풂)
- 분류 LAS 의 implicit 는 기본 필터에만 지음(csf 두 번 안 지음)
- B04 화면 확정 없을 때 기본 표현 implicit
- 지킴 시험 test_640_lidar_default

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-01 21:20:24 +09:00
co-authored by Claude Opus 5.5
parent 887ca4a035
commit 366fd7a700
8 changed files with 162 additions and 10 deletions
+1 -1
View File
@@ -279,7 +279,7 @@ def run_surface_analysis(
_report(40, "ground_filter", "지면 필터 적용 중")
# 자동 전처리는 목록을 넘기지 않는다 — 기본 필터는 입력 LAS를 보고 여기서 정한다.
if not source_filters:
source_filters = resolve_auto_source_filters(data)
source_filters = resolve_auto_source_filters(data, processed_dir)
logger.info("B04 자동 전처리 기본 필터: %s", ", ".join(source_filters))
masks: dict[str, np.ndarray] = {}
for filter_key in source_filters:
@@ -5,11 +5,18 @@
쓸 수 있는지는 has_classified_ground()로 먼저 판정한다.
"""
import json
from pathlib import Path
from typing import Any
import numpy as np
from config.config_system import SURFACE_CLASSIFIED_GROUND_MIN_RATIO
from common_util.common_util_json import atomic_write_json
from config.config_system import (
SURFACE_CLASSIFIED_COVERAGE_CELL_M,
SURFACE_CLASSIFIED_COVERAGE_MIN_RATIO,
SURFACE_CLASSIFIED_GROUND_MIN_RATIO,
)
# ASPRS 표준 지면 클래스 코드
GROUND_CLASS_CODE = 2
@@ -38,3 +45,51 @@ def has_classified_ground(
return False
ground = int(np.count_nonzero(classification == GROUND_CLASS_CODE))
return ground / total >= minimum_ratio
def classified_coverage(
structured_data: dict[str, Any] | np.lib.npyio.NpzFile,
cell_meters: float = SURFACE_CLASSIFIED_COVERAGE_CELL_M,
) -> float:
"""점 있는 칸 중 class 2 가 있는 칸의 비율 — 일부만 분류된 LAS 를 가려냄."""
if "classification" not in structured_data:
return 0.0
classification = np.asarray(structured_data["classification"])
xyz = structured_data["xyz"]
bounds = np.asarray(structured_data["bounds"], dtype=np.float64)
cell = max(float(cell_meters), 0.1)
cols = int((bounds[0, 1] - bounds[0, 0]) // cell) + 1
rows = int((bounds[1, 1] - bounds[1, 0]) // cell) + 1
occupied = np.zeros((rows, cols), dtype=bool)
ground = np.zeros((rows, cols), dtype=bool)
for start in range(0, len(classification), 5_000_000):
points = np.asarray(xyz[start : start + 5_000_000, :2], dtype=np.float64)
gx = np.clip(((points[:, 0] - bounds[0, 0]) // cell).astype(np.int32), 0, cols - 1)
gy = np.clip(((points[:, 1] - bounds[1, 0]) // cell).astype(np.int32), 0, rows - 1)
occupied[gy, gx] = True
is_ground = classification[start : start + len(points)] == GROUND_CLASS_CODE
ground[gy[is_ground], gx[is_ground]] = True
total = int(np.count_nonzero(occupied))
return float(np.count_nonzero(ground)) / total if total else 0.0
def has_classified_coverage(
structured_data: dict[str, Any] | np.lib.npyio.NpzFile,
processed_dir: Path | None = None,
minimum_ratio: float = SURFACE_CLASSIFIED_COVERAGE_MIN_RATIO,
) -> bool:
"""분류 덮임 문턱 판정 — `processed_dir` 면 structured.npz 지문으로 저장본 재사용."""
if processed_dir is None:
return classified_coverage(structured_data) >= minimum_ratio
stat = (processed_dir / "structured.npz").stat()
stamp = [int(stat.st_size), int(stat.st_mtime_ns)]
path = processed_dir / "classification_coverage.json"
try:
stored = json.loads(path.read_text(encoding="utf-8"))
coverage = float(stored["coverage"]) if stored.get("structured") == stamp else None
except (OSError, ValueError, KeyError, TypeError, AttributeError):
coverage = None
if coverage is None:
coverage = classified_coverage(structured_data)
atomic_write_json(path, {"structured": stamp, "coverage": coverage})
return coverage >= minimum_ratio
@@ -5,12 +5,14 @@
source_filters를 따른다.
"""
from pathlib import Path
from typing import Any
import numpy as np
from B04_PreProcess.B04_PreProcess_Engine_Filter_Classification import (
filter_classification,
has_classified_coverage,
has_classified_ground,
)
from B04_PreProcess.B04_PreProcess_Engine_Filter_CSF import filter_csf
@@ -45,14 +47,18 @@ def usable_conditional_filters(
def resolve_auto_source_filters(
structured_data: dict[str, Any] | np.lib.npyio.NpzFile,
processed_dir: Path | None = None,
) -> list[str]:
"""자동 전처리가 만들 필터를 입력 LAS를 보고 정한다. 첫 항목이 기본 확정값이다.
업체가 이미 지면을 분류해 놨으면 그것을 기본으로 쓴다 — 계산이 없고 품질도 가장
안정적이다. **csf는 분류가 있어도 함께 만든다** — csf 처리 결과를 눈으로 검증할 수
있어야 하기 때문이다 (2026-09-01 사용자 확정). 분류가 없으면 csf 하나만 남는다.
「분류 있음」 = 비율 문턱 + 덮임(일부만 분류된 LAS 거름) — 자동 고름에만(요구 558).
"""
usable = usable_conditional_filters(structured_data)
if usable and not has_classified_coverage(structured_data, processed_dir):
usable = []
return [*usable[:1], SURFACE_AUTO_FALLBACK_FILTER]
@@ -190,6 +190,8 @@ def _build_all_terrain_models(
methods_list.remove("dtm")
methods_list.insert(0, "dtm")
methods = tuple(methods_list)
# 무거운 implicit 은 기본 필터(첫 필터)에만 — 분류 LAS 의 csf 까지 두 번 짓지 않음(요구 558).
later_methods = tuple(method for method in methods if method != "implicit")
signature = config_signature(config)
bounds = np.asarray(structured_data["bounds"], dtype=np.float64)
xyz = structured_data["xyz"]
@@ -211,7 +213,7 @@ def _build_all_terrain_models(
}
started_at = time.monotonic()
timeout = max(0, int(config.get("sync_timeout_seconds", 0)))
total_units = max(1, len(filters) * len(methods))
total_units = max(1, len(methods) + (len(filters) - 1) * len(later_methods))
done_units = 0
failures = 0
@@ -229,7 +231,7 @@ def _build_all_terrain_models(
)
filter_entry["source_point_count"] = context.source_count
for method in methods:
for method in later_methods if filter_index else methods:
stem = f"{method}_{filter_key}"
entry = filter_entry["methods"].get(method, {})
+2 -2
View File
@@ -54,7 +54,7 @@ import { currentProjectId, guardProjectLeave } from "../A00_Common/b_project_swi
const SOURCE_FILTERS = ["classification", "grid_min_z", "csf", "pmf"] as const;
const MODEL_METHODS = ["tin", "dtm", "nurbs", "implicit", "meshfree"] as const;
const DEFAULT_FILTER = "csf";
const DEFAULT_METHOD = "dtm";
const DEFAULT_METHOD = "implicit"; // 확정 기본 표현(요구 558) — 확정본이 있으면 그것이 먼저
const ROUTE_STAGE = ROUTES.B05_PROFILE;
// 도엽 서피스 보간 방식 버튼 순서 — 백엔드 SHEET_SURFACE_METHODS와 같은 차례로 둔다.
const SHEET_METHOD_ORDER = ["tin_sheet", "tin", "biharmonic", "anudem", "multires", "laplace"];
@@ -494,7 +494,7 @@ export async function renderB04Surface(root: HTMLElement): Promise<void> {
]);
models = modelResponse.models;
// 확정본과 같은 조합에서 시작해야 B05와 같은 파일을 보고, 보관함도 한 벌만 쓴다.
// 확정 이력이 없을 때만 개발 기본값(csf·dtm)으로 둔다.
// 확정 이력이 없을 때만 개발 기본값(csf·implicit)으로 둔다.
if (confirmed.model_id) {
if (confirmed.source_filter) filterGroup.select.value = confirmed.source_filter;
if (confirmed.method) methodGroup.select.value = confirmed.method;