feat(배수유역): 347-2 「지금 노선으로 셈」 서버 길 · 347-3 관 자리 후보 · [확정] 다시 셈

- POST drainage/live — 몸통 = 차례 번호 + 노선 초안(RouteDraft · 노선 [확인]과 같은 폴리라인 규칙) + 관 목록 · 서버 단독 · 작업본(00_watershed_response · 격자 배열 · 관 지점)에 안 씀 · 세부 유역까지 메모리 격자로 한 요청
- 프로젝트별 마지막 차례 · 1차 영역 뒤 · 확장 회차마다 · 세부 유역 앞에서 바뀌었으면 그만둠(superseded · AnalysisStopped)
- build_detail 에 메모리 routing · 상류선 · 관 자리 후보 suggest_pipe_positions(간격 보충 규칙 · 흐름 세기 + 오목 · 기존 관에서 먼 곳 · 정수 m) · 응답 pipe_candidates
- PUT pipe-points ?recompute=true([확정]) = 낡았으면 배수유역부터 다시 셈 · [저장]은 낡음 달고 관만
- 시험 test_347_2_drainage_live(늦은 차례 그만둠 둘 · 엔진 회차 그만둠 · 메모리 격자 · 후보 · 확정 다시 셈) · 검증_sub3 실측 저장 노선 16.9 s · 초안 노선 11.5 s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XWh5wNNycMkbwMpACz1rte
This commit is contained in:
2026-10-16 11:38:17 +09:00
co-authored by Claude Opus 5.5
parent c0ad3edc80
commit d5d6415966
7 changed files with 399 additions and 5 deletions
+27 -2
View File
@@ -73,7 +73,11 @@ STALE_MESSAGE = (
def _build(
stored_path: str, context: DrainageContext, points: list[PipePoint] | None
stored_path: str,
context: DrainageContext,
points: list[PipePoint] | None,
routing: Any = None,
upstream_lonlat: list | None = None,
) -> tuple[DrainageDetail | None, list[PipePoint]]:
"""세부유역을 계산하고, 그 결과에 쓰인 관 목록을 함께 돌려준다.
@@ -83,7 +87,7 @@ def _build(
"""
directory = drainage_dir(stored_path)
chainages = [point.chainage_m for point in points] if points is not None else None
detail = build_detail(directory, context.vertices, chainages)
detail = build_detail(directory, context.vertices, chainages, routing, upstream_lonlat)
if detail is None:
return None, []
if points is not None:
@@ -377,6 +381,11 @@ def _raw_payload(
for basin in detail.basins
],
"pipe_count": len(points),
# 관 자리 후보(347-3) — 제안만 · [적용] 때 화면이 관 초안에 더함.
"pipe_candidates": [
{"chainage_m": round(pipe.chainage_m, 2), "lonlat": list(to_lonlat(pipe.x, pipe.y))}
for pipe in detail.pipe_candidates
],
}
@@ -479,6 +488,13 @@ async def _resolve(
return context, detail, resolved, saved, False
async def _analysis_stale(project_id: UUID) -> bool:
context, _ = await load_drainage_context(project_id)
if context is None:
return False
return analysis_route_signature(context.stored_path) != route_signature(context.vertices)
@router.get("/{project_id}/drainage/pipe-points", response_model=None)
async def get_pipe_points(project_id: UUID) -> dict[str, Any] | JSONResponse:
"""저장된 관 지점과 그 세부유역을 돌려준다. 저장분이 없으면 자동 생성한 목록."""
@@ -529,8 +545,17 @@ async def put_pipe_points(
project_id: UUID,
payload: dict[str, Any] | None = None,
session: dict[str, Any] | None = Depends(get_optional_session), # 가져온이(142-2)
recompute: bool = False,
) -> dict[str, Any] | JSONResponse:
"""관 지점을 정본으로 확정하고 세부유역 산출물까지 함께 남긴다(모델 확정 시점)."""
# [확정](recompute) = 낡았으면 지금 노선으로 배수유역부터 다시 셈(정본 · 작업본에 씀 · 347-2) ·
# [저장] = 낡음 표시 달고 관만 저장.
if recompute and await _analysis_stale(project_id):
from B04_PreProcess.B04_PreProcess_Router_Watershed import get_primary_region
region = await get_primary_region(project_id, refresh=True)
if isinstance(region, JSONResponse):
return region
resolved = await _resolve(project_id, payload, use_stored=True, fresh=True)
if isinstance(resolved, JSONResponse):
return resolved