feat(B07): 표지를 A1 전면 템플릿으로 만들고 도면 목록에 붙인다

표지는 DRAWING_GROUPS에 kind 없이 라벨만 있어 화면에서 열 수 없었다. 실무 설계도면
원본(울진 소광리, A3) 1쪽의 잉크 bbox를 pymupdf로 mm 실측해 A1로 2배 환산했다.
원본에 도각이 없다 — 좌우 테두리 없이 상·하 굵은 가로선 두 줄뿐이라, 사용자가 고른
"도각 없는 전면 디자인"이 실무 그대로였다.

- resources/template_2dDrawing/00_template_cover.json 신설. 엔티티 14개(재단 표식
  Point 4·띠 Hatch 3·글자 Text 7), bbox가 정확히 A1(840x594). 좌표계는 00_template_A1
  과 같아 도각 도면과 나란히 놓인다.
- 굵은 띠는 solid Hatch로 냈다. lineWidth는 캔버스 화면 픽셀이라(screenCanvas
  .drawController.ts:261) 확대해도 두꺼워지지 않아 실치수를 못 낸다.
- 글자 크기는 잉크 높이가 아니라 폭으로 잡았다. 원본은 장평이 좁은 CAD 글꼴이라
  높이를 그대로 옮기면 위치값이 종이 밖으로 44mm 넘치고 라벨과 겹친다.
- B07_DesignDetail_Engine_Cad_Cover.py 신설. frame_entities()를 쓰지 않는다 —
  _transform_entity()가 Hatch의 points 배열을 못 옮기고, 표지는 A1 실치수 고정이라
  애초에 변환이 필요 없다. 공용 함수는 건드리지 않았다.
- kind "cover" 배선: Schema Literal, Api_Fetch, UI_Page DRAWING_GROUPS,
  Router_Support 목록·빌드 분기·확정 캐시 매핑.

값(공사명·위치·사업량·시행청)은 아직 빈칸이다 — 메타 배선은 다음 판.

검증: tmp/tests/test_cover_template.py 6건 통과(A1 치수·Hatch 두께·잠금 레이어·
치환·lru_cache 오염 없음). 공용 브라우저에서 표지를 열어 엔티티 14개 전부
b08-frame, Ctrl+A 선택 0 확인.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-31 19:49:47 +09:00
co-authored by Claude Opus 5
parent 9bc722dfd6
commit 44fbe480df
6 changed files with 421 additions and 7 deletions
@@ -4,7 +4,7 @@ import { API_BASE_URL, API_TIMEOUT_MS } from "@config/config_frontend";
export interface DesignDrawingItem {
id: string;
kind: "longitudinal" | "cross" | "mass_haul" | "watershed";
kind: "cover" | "longitudinal" | "cross" | "mass_haul" | "watershed";
label: string;
chainage_m: number | null;
confirmed: boolean;
@@ -73,7 +73,7 @@ export interface DesignDrawingResponse {
project_id: string;
route_id: number;
id: string;
kind: "longitudinal" | "cross" | "mass_haul" | "watershed";
kind: "cover" | "longitudinal" | "cross" | "mass_haul" | "watershed";
label: string;
drawing: CadDrawing;
confirmed: boolean;
@@ -0,0 +1,56 @@
"""B07 표지 도면 — 템플릿 한 장을 그대로 도면으로 낸다 (2026-08-31 신설).
다른 도면과 다르게 **설계 자료가 없다**. 표지는 A1 종이에 고정 배치된 글자와 띠뿐이라
콘텐츠를 감쌀 일도, 척도를 맞출 일도 없다. 그래서 도각(`frame_entities()`)을 두르지
않고 `00_template_cover.json` 을 실치수 1:1 로 싣는다 — 사용자 확정(2026-08-31)
"표지를 일단 전체가 템플릿이 되면 좋겠어" · "도각 없는 전면 디자인".
`frame_entities()` 를 재사용하지 않는 이유는 두 가지다.
① 표지는 변환이 필요 없다(A1 실치수 고정).
② `_transform_entity()` 가 옮기는 좌표 키는 `startPoint·endPoint·basePoint·point·
center` 뿐이라 표지의 굵은 띠(`Hatch`)가 쓰는 `points` 배열을 **못 옮긴다**.
띠를 `Hatch` 로 낸 것은 `lineWidth` 가 캔버스 화면 픽셀이라 실치수 두께를 못 내기
때문이다(`screenCanvas.drawController.ts:261`).
"""
from __future__ import annotations
from typing import Any
from uuid import uuid5
from B07_DesignDetail.B07_DesignDetail_Engine_Cad import (
_ENTITY_NS,
DRAWING_FORMAT,
FRAME_LAYER_ID,
_layer,
)
from B07_DesignDetail.B07_DesignDetail_Engine_Template import (
_fill_placeholders,
_load_template,
)
COVER_TEMPLATE = "00_template_cover"
def build_cover_drawing(drawing_id: str, fields: dict[str, str] | None = None) -> dict[str, Any]:
"""표지 도면 문서. 템플릿이 없으면 빈 도면을 낸다.
`fields` 의 `{{키}}` 는 도각과 같은 규약으로 치환하고, 값이 없으면 빈칸으로 둔다
(남의 값이 남지 않는다). 값 공급은 다음 판(메타 배선) 몫이다.
"""
template = _load_template(COVER_TEMPLATE) or {}
entities: list[dict[str, Any]] = []
for index, entity in enumerate(template.get("entities", [])):
placed = dict(entity)
placed["id"] = str(uuid5(_ENTITY_NS, f"{drawing_id}:cover:{index}"))
placed["layerId"] = FRAME_LAYER_ID
shape = entity.get("shapeData")
if isinstance(shape, dict):
placed["shapeData"] = dict(shape)
entities.append(placed)
_fill_placeholders(entities, fields or {})
return {
"format": DRAWING_FORMAT,
"entities": entities,
"layers": [_layer(FRAME_LAYER_ID, "도각", locked=True)],
}
@@ -22,6 +22,7 @@ from B07_DesignDetail.B07_DesignDetail_Engine_Cad import (
station_no_label,
)
from B07_DesignDetail.B07_DesignDetail_Engine_Cad_Basin import build_watershed_drawing, map_area_mm
from B07_DesignDetail.B07_DesignDetail_Engine_Cad_Cover import build_cover_drawing
from B07_DesignDetail.B07_DesignDetail_Engine_Cad_Long import (
build_longitudinal_drawing,
longitudinal_chunks,
@@ -52,6 +53,7 @@ _LONG_ID = re.compile(r"^longitudinal(?:_(\d+))?$")
# 노선 전장에 한 장씩만 나오는 도면 — 라우터가 원본 자료를 따로 실어 넘긴다.
MASS_HAUL_ID = "mass_haul"
WATERSHED_ID = "watershed"
COVER_ID = "cover"
def _read_json(path: Path) -> dict[str, Any]:
@@ -300,6 +302,7 @@ def _drawing_list(
)
# 노선 전장 1장짜리 도면 — 자료가 없으면 여는 시점에 404로 알린다(목록에는 항상 둔다).
for drawing_id, kind, label in (
(COVER_ID, "cover", "표지"),
(MASS_HAUL_ID, "mass_haul", "토적도(유토곡선)"),
(WATERSHED_ID, "watershed", "유역도(배수 유역도)"),
):
@@ -490,7 +493,7 @@ def _read_drawing(
# 포맷 버전이 다르면(테이블·레이어 구성 변경 전 저장본) 캐시를 버리고
# 아래에서 원본 기준으로 재생성한다. 확정 상태도 무효로 응답해 재확정 유도.
if saved.get("format") == DRAWING_FORMAT:
if drawing_id in (MASS_HAUL_ID, WATERSHED_ID):
if drawing_id in (COVER_ID, MASS_HAUL_ID, WATERSHED_ID):
kind = drawing_id # id와 kind가 같은 단장 도면
else:
kind = "longitudinal" if _LONG_ID.fullmatch(drawing_id) else "cross"
@@ -498,6 +501,10 @@ def _read_drawing(
stored_table = manifest_entry.get("quantity_table")
table = stored_table if kind == "cross" and isinstance(stored_table, dict) else None
return kind, label, saved, True, table
if drawing_id == COVER_ID:
# 표지는 설계 자료를 쓰지 않는다 — 템플릿 한 장이 곧 도면이다.
return "cover", "표지", build_cover_drawing(drawing_id), False, None
if drawing_id == MASS_HAUL_ID:
# stored_design = 확정 종단 DB row의 mass_haul 산출물(라우터가 실어 준다).
if not isinstance(stored_design, dict):
+2 -2
View File
@@ -9,7 +9,7 @@ class DesignDrawingItem(BaseModel):
"""B06 확정 산출물에서 노출하는 도면 메타데이터."""
id: str
kind: Literal["longitudinal", "cross", "mass_haul", "watershed"]
kind: Literal["cover", "longitudinal", "cross", "mass_haul", "watershed"]
label: str
chainage_m: float | None = None
confirmed: bool = False
@@ -31,7 +31,7 @@ class DesignDrawingResponse(BaseModel):
project_id: str
route_id: int
id: str
kind: Literal["longitudinal", "cross", "mass_haul", "watershed"]
kind: Literal["cover", "longitudinal", "cross", "mass_haul", "watershed"]
label: str
drawing: dict[str, Any]
confirmed: bool = False
+2 -2
View File
@@ -43,7 +43,7 @@ import { appendStructureEntities } from "./B07_DesignDetail_UI_Cad_Structures";
/** CAD 앱 수량 패널로 넘기는 설계 컨텍스트 (openwebcad DesignMeta와 동일 형식). */
interface DesignMeta {
kind: "cross" | "longitudinal" | "mass_haul" | "watershed";
kind: "cover" | "cross" | "longitudinal" | "mass_haul" | "watershed";
title: string;
info: string;
confirmed: boolean;
@@ -81,7 +81,7 @@ const CAD_TOAST_ACTION_MESSAGE = "aislo:b08:toast-action";
/** 도면 구성 12분류 (2026-08-29 사용자 확정 순서). kind가 없으면 아직 만들지 않는 도면. */
const DRAWING_GROUPS: readonly { label: string; kind?: DesignDrawingItem["kind"] }[] = [
{ label: "표지" },
{ label: "표지", kind: "cover" },
{ label: "계획평면도(지형)" },
{ label: "계획평면도(노선배치도)" },
{ label: "계획평면도(배치도)" },