- 저장 모듈 D03_PlanAnalysis_Store — 읽기 · 원자 쓰기 · 판 · 옛 DB 칸 읽을 때 옮김(지점 셋 꼴 · 연도 행 접기 · 옛 연도 노선) · plan_state(조각 · 연도 지문 · 확정 = 지문 같을 때만) - D03 [저장] · [초기화] · D02 지점 = 파일만 + 연도 상태 줄(지문 · 확정) · 프로젝트 잠금 · 파일 쓰기 실패 = DB 되돌림 · 빈 연도 줄 지움 - D04 요약 · 업체 지정 · 확정 메일 · 내보내기 · 대시보드 [연결] · 받은 예정노선 · 산림청 홈 · 개요 연결 = 파일에서 · 업체 줄 연도 칸 안 읽음(⑤) - 산림청 홈 「분석 전」 = 노선 안 그은 예정노선 프로젝트 수 · plan-source 지운 원본 거름 - 옛 연도 단위 지정 · 옛 연도 행 노선 길 걷음(DB 실측 0) · 연결 때 설계속도 씨앗 걷음(591-1 이음) - SQL 023 = 업체 줄 year NULL 허용(옛 칸은 590-3 에서 지움) - 시험: 새 지킴 590_1(옮김 · 원자 쓰기 · 연도 읽기 · 잠금) · 낡은 시험 고침 — 529_3 · 530_2 · 531_3 · 531_d04 · 547_2 · 563_2(DB 조각 · 연도 행 흉내 → 파일 흉내 · 옛 연도 지정 시험 · 설계속도 씨앗 시험 지움 = 그 길 걷음) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
2.1 KiB
Python
57 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""시험 도움 — 예정노선 설계 내용(파일 꼴 · PLAN 590-1)을 메모리로 꽂음."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
from D03_PlanAnalysis import D03_PlanAnalysis_Network as network
|
|
from D03_PlanAnalysis import D03_PlanAnalysis_Store as store
|
|
|
|
|
|
def plan_of(lines: list, marks: list, pieces: list, epsg: int = 5186, points=()) -> dict:
|
|
return {
|
|
**store.empty_plan(epsg),
|
|
"points": list(points),
|
|
"lines": lines,
|
|
"marks": marks,
|
|
"pieces": pieces,
|
|
}
|
|
|
|
|
|
def use_plan(monkeypatch: Any, plan: dict, confirmed: dict | None = None) -> dict:
|
|
"""`store.load_plan` · `store.year_status` 를 갈아 끼움 — `confirmed` = {연도: 확정 시각}
|
|
(지문은 파일과 같게) · 돌려준 dict 의 plan · confirmed 를 고치면 다음 읽기에 반영."""
|
|
state = {"plan": plan, "confirmed": dict(confirmed or {})}
|
|
|
|
async def load(_pid):
|
|
return Path("."), state["plan"]
|
|
|
|
async def status(_pid):
|
|
years = network.year_rows(store.plan_units(state["plan"]))
|
|
return {
|
|
y: {"fingerprint": years[y]["fingerprint"], "confirmed_at": at}
|
|
for y, at in state["confirmed"].items()
|
|
if y in years
|
|
}
|
|
|
|
monkeypatch.setattr(store, "load_plan", load)
|
|
monkeypatch.setattr(store, "year_status", status)
|
|
return state
|
|
|
|
|
|
def year_line_plan(parts: dict[int, list]) -> dict:
|
|
"""본선 하나 = 연도 꺾은선 이음(앞 끝 = 뒤 시작) · 연도 경계 마크 · 조각 `p26` · `p27` …"""
|
|
vertices: list = []
|
|
pieces = []
|
|
for year, points in sorted(parts.items()):
|
|
start = network.draw.line_length(vertices)
|
|
vertices += [list(p) for p in (points[1:] if vertices else points)]
|
|
end = network.draw.line_length(vertices)
|
|
pieces.append(
|
|
{"id": f"p{year % 100}", "line": "main", "from_m": start, "to_m": end, "year": year}
|
|
)
|
|
marks = [{"line": "main", "at_m": p["to_m"]} for p in pieces[:-1]]
|
|
return plan_of([{"id": "main", "vertices": vertices, "branch": None}], marks, pieces)
|