fix(B05·B06): 노선 고친 [저장] 계획고 = 서버 옮김 위에 사용자 손댐만 (PLAN 498-2 · 요구 411~417)

- 브라우저 — 노선 바뀐 [저장]의 계획고 본문 = 묶음 계획고 대 저장분 옮김(같은 carryEdits · 이 초안 첫 기준)의 다른 열쇠 · 지운 열쇠만(`gradeTouch` · `routeGradeTouch`) · 못 가르면 옛 길(노선 0 칸 통째)
- 서버 — `alignment_cleared` 가 오면 관 · 구조물 · 추가 측점 차례 뒤 새 종단 편집(서버 옮김) 위에 손댐만 얹어 한 번 저장(`touched_alignment` · 얹기 실패도 되돌림 안)
- follow 옮김 측점 = stations 단계와 같은 추가 측점(`plus` 넘김)
- 재현: 꼬리 추가 측점 ▲ 뒤 앞 교점 끌기 [저장] = 990 m 편집 버림 · ▲ 잃음 · 최대 −0.50 m → 고친 뒤 버림 0 · 끌 때 = 저장 뒤
- 시험: test_498_2_grade_touch 새로 · helper_design_store_save 에 묶음 창구 가짜 하나(옛 길)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 21:51:29 +09:00
co-authored by Claude Opus 5.5
parent 76bb0c3fd3
commit b92fa06f34
10 changed files with 453 additions and 20 deletions
@@ -5,7 +5,8 @@
노선 저장(`/route/replan` 체인 · 관 · 구조물 · 추가 측점 좌표 따라감 · 종횡단 · 계획고 ·
횡단 이월)
→ 관 · 구조물 초안 다시 얹기(Node `facility.rebase` · 서버 따라감 위에)
→ 6-A 차례(새 노선) → 횡단 = 옛 노선 세션 칸을 새 측점에 넘긴 patch(Node `stations.carry`)
→ 6-A 차례(새 노선 · 계획고 = 서버 옮김 위에 사용자 손댐만 · 498-2)
→ 횡단 = 옛 노선 세션 칸을 새 측점에 넘긴 patch(Node `stations.carry`)
브라우저가 하던 다시 얹기(`rebasePipeDraft` · `carryAfterRouteSave`)와 같은 TS 를 서버가 부름 —
브라우저는 노선 초안 + 사용자 칸만 보냄. 손 상단측은 안 넘김(요구 274 · 새 지형이 정함).
@@ -36,6 +37,15 @@ class RouteCarryRequest(BaseModel):
pipe_ids: dict[str, Any] | None = None
class AlignmentCleared(BaseModel):
"""노선 바뀐 [저장]에서 사용자가 지운 계획고 열쇠(498-2 · 브라우저 `gradeTouch`)."""
model_config = ConfigDict(extra="forbid")
station_offsets: list[str] = Field(default_factory=list)
curve_radii: list[str] = Field(default_factory=list)
class StepFailed(Exception):
def __init__(self, step: str, message: str) -> None:
super().__init__(message)
@@ -121,3 +131,46 @@ async def carry_cross(
**(carry or RouteCarryRequest()).model_dump(mode="json"),
}
return _node(["stations.carry"], {"carry": inputs}, "cross")
def overlay_edits(
carried: dict[str, Any], touch: dict[str, Any], cleared: AlignmentCleared
) -> dict[str, dict[str, float]]:
"""서버 옮김 편집 위에 사용자 손댐만(498-2) — 지운 · 고친 열쇠 자리(0.006 m 안)의 옮김 값을 걷고
손댐 값을 얹음. 손대지 않은 옮김 열쇠는 서버 측점 그대로(브라우저 열쇠로 안 덮음)."""
from B05_Profile.B05_Profile_Engine_Grade_Alignment import SAME_STATION_SNAP_M
out: dict[str, dict[str, float]] = {}
for field in ("station_offsets", "curve_radii"):
merged = {str(key): float(value) for key, value in (carried.get(field) or {}).items()}
mine = {str(key): float(value) for key, value in (touch.get(field) or {}).items()}
for key in [*getattr(cleared, field), *mine]:
for near in [k for k in merged if abs(float(k) - float(key)) < SAME_STATION_SNAP_M]:
del merged[near]
out[field] = {**merged, **mine}
return out
async def touched_alignment(
project_id: UUID, route_id: int, touch: Any, cleared: AlignmentCleared
) -> Any:
"""노선 바뀐 [저장] 계획고 본문(498-2) = 새 종단 편집(노선 차례 서버 옮김) ⊕ 사용자 손댐."""
import json
from pathlib import Path
from B03_FileInput.B03_FileInput_Repository import get_project_storage_relative_path
from B05_Profile.B05_Profile_Schema import ProfileAlignmentSaveRequest
from B06_Section.B06_Section_Repository import get_longitudinal_section
from common_util.common_util_storage import resolve_stored_project_path
from config.config_db import get_db_pool
async with get_db_pool().acquire() as connection:
row = await get_longitudinal_section(connection, project_id, route_id)
stored = await get_project_storage_relative_path(connection, project_id)
if not row:
raise StepFailed("alignment", "새 노선 종단을 못 읽었습니다")
path = Path(resolve_stored_project_path(stored)) / str(row["longitudinal_file_path"])
longitudinal = json.loads(path.read_text(encoding="utf-8"))
carried = (longitudinal.get("profile_alignment") or {}).get("edits") or {}
edits = overlay_edits(carried, touch.edits() if touch is not None else {}, cleared)
return ProfileAlignmentSaveRequest(route_id=route_id, **edits)