fix(637-4): [초기화] 때 설계 지형도 초기값으로 — 초기값에 stage 1 지형 고름 담음 · 되돌릴 때 stage 1 확정값 · CONFIRMED 모델(노선 행이 가리키는 것) 함께 · 옛 초기값 = 지형 그대로 + 로그 한 줄(요구 546)
- 재현(검증_sub4 B · 라이다 → 수치지형도 → [초기화]): stage 1 = 수치지형도 · 노선 행 = 라이다 모델 · 횡단 지반선 대 stage 1 지형 평균 3.78 m · 최대 13.67 m - 고친 뒤 같은 길(API · ORCA 칩 → [초기화]): 세 자리 라이다 · 어긋남 0 - las_selection · 등고선 간격 등 지형 밖 칸 안 건드림 · stage 1 행 없으면 안 씀 - 시험 test_637_4_reset_terrain 새로 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,12 +11,15 @@ CLAUDE.md 5장(조작·데이터 흐름 정책)의 **초기값** 층이다. 자
|
||||
|
||||
import csv
|
||||
import json
|
||||
import logging
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import aiomysql
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# 스냅샷 폴더는 워크플로우 단계가 아니므로 PROJECT_STORAGE_LAYOUT_V2에 넣지 않는다.
|
||||
SNAPSHOT_DIRNAME = "initial_snapshot"
|
||||
_DB_DUMP_NAME = "db.json"
|
||||
@@ -50,6 +53,9 @@ _LEGACY_DRAINAGE_TREE = "B04_PreProcess__drainage__edits"
|
||||
# 번호 없는 이름으로 두었다가 복원 때 새 번호로 되돌린다.
|
||||
_CORRIDOR_NAME = "initial_corridor.json"
|
||||
|
||||
# 설계 지형 고름 — stage 1 확정값 중 지형 칸(PLAN 637-4 · 요구 546)
|
||||
_TERRAIN_KEYS = ("source_filter", "method", "smooth")
|
||||
|
||||
# `routes.id`를 참조하는 표는 스키마상 이 넷이 전부다(001_create_schema.sql:539~556).
|
||||
_CHILD_TABLES = ("route_points", "route_statistics", "longitudinal_sections", "cross_sections")
|
||||
|
||||
@@ -220,6 +226,8 @@ async def save_initial_snapshot(
|
||||
dump[table] = _json_safe(await _dump_rows(connection, table, route_id))
|
||||
# stage 2 params(제어점 · 페이지 설정)도 — [초기화]가 함께 되돌림(448 E3)
|
||||
dump["stage2_params"] = await _stage2_params(connection, str(route["project_id"]))
|
||||
# 설계 지형 고름도 — 초기값은 그 지형으로 센 값이라 [초기화]가 함께 되돌림(637-4)
|
||||
dump["stage1_terrain"] = await _stage1_terrain(connection, str(route["project_id"]))
|
||||
(target / _DB_DUMP_NAME).write_text(json.dumps(dump, ensure_ascii=False), encoding="utf-8")
|
||||
|
||||
|
||||
@@ -325,9 +333,46 @@ async def restore_initial_snapshot(
|
||||
child["project_id"] = project_id
|
||||
await _insert_row(connection, table, child)
|
||||
await _restore_stage2_params(connection, project_id, dump)
|
||||
await _restore_stage1_terrain(connection, project_id, dump, route.get("surface_model_id"))
|
||||
return new_id
|
||||
|
||||
|
||||
async def _stage1_terrain(connection: aiomysql.Connection, project_id: str) -> dict[str, Any]:
|
||||
from common_util.common_util_surface_confirmation import get_surface_confirmation_params
|
||||
|
||||
params = await get_surface_confirmation_params(connection, project_id)
|
||||
return {key: params[key] for key in _TERRAIN_KEYS}
|
||||
|
||||
|
||||
async def _restore_stage1_terrain(
|
||||
connection: aiomysql.Connection, project_id: str, dump: dict[str, Any], model_id: Any
|
||||
) -> None:
|
||||
"""뜬 설계 지형으로 stage 1 확정값 · CONFIRMED 모델(노선 행이 가리키는 것)을 되돌림(637-4).
|
||||
|
||||
옛 초기값(지형 칸 없음)은 지형 그대로 · 라이다 적어 둔 값(`las_selection`)은 안 건드림.
|
||||
"""
|
||||
terrain = dump.get("stage1_terrain")
|
||||
if not isinstance(terrain, dict):
|
||||
logger.info(
|
||||
"[초기화] 옛 초기값 — 설계 지형 칸 없음 · 지형 그대로: project_id=%s", project_id
|
||||
)
|
||||
return
|
||||
from B04_PreProcess.B04_PreProcess_Repository import confirm_surface_model
|
||||
from common_util.common_util_surface_confirmation import (
|
||||
get_surface_confirmation_params,
|
||||
merge_surface_confirmation_params,
|
||||
)
|
||||
|
||||
params = await get_surface_confirmation_params(connection, project_id)
|
||||
try:
|
||||
await merge_surface_confirmation_params(connection, project_id, {**params, **terrain})
|
||||
except LookupError: # stage 1 행 없음 — 되돌릴 자리 없음(아무것도 안 씀)
|
||||
logger.warning("[초기화] stage 1 행 없음 · 설계 지형 그대로: project_id=%s", project_id)
|
||||
return
|
||||
if model_id is not None:
|
||||
await confirm_surface_model(connection, project_id, int(model_id))
|
||||
|
||||
|
||||
async def _stage2_params(connection: aiomysql.Connection, project_id: str) -> Any:
|
||||
async with connection.cursor() as cursor:
|
||||
await cursor.execute(
|
||||
|
||||
Reference in New Issue
Block a user