auto: 2026-08-31 14:38 (ESD_LAPTOP)

This commit is contained in:
2026-08-31 14:38:53 +09:00
parent ee065091c1
commit 8ae61af7dd
6 changed files with 46 additions and 146498 deletions
@@ -381,7 +381,11 @@ def build_watershed_drawing(
)
)
entities.extend(compass_entities(drawing_id, (max_bx - 8.0, max_by - 8.0), 14.0))
entities.extend(frame_entities(drawing_id, entities_bbox(entities) or bbox, fit=False))
entities.extend(
frame_entities(
drawing_id, entities_bbox(entities) or bbox, fit=False, fields={"도면명": "유역도"}
)
)
return {
"format": DRAWING_FORMAT,
@@ -669,7 +669,7 @@ def build_longitudinal_drawing(
# A1 도각: 콘텐츠가 이미 종이 mm라 도각도 실치수(1:1)로 두고 위치만 맞춘다.
bbox = entities_bbox(entities)
if bbox:
entities.extend(frame_entities(drawing_id, bbox, fit=False))
entities.extend(frame_entities(drawing_id, bbox, fit=False, fields={"도면명": "종단면도"}))
return {
"format": DRAWING_FORMAT,
@@ -517,7 +517,11 @@ def build_mass_haul_drawing(
align="right",
)
)
entities.extend(frame_entities(drawing_id, entities_bbox(entities) or bbox, fit=False))
entities.extend(
frame_entities(
drawing_id, entities_bbox(entities) or bbox, fit=False, fields={"도면명": "토적도"}
)
)
return {
"format": DRAWING_FORMAT,
@@ -204,7 +204,7 @@ def build_cross_sheet(sheet: dict[str, Any], sections: list[dict[str, Any]]) ->
bbox = entities_bbox(entities)
if bbox:
entities.extend(frame_entities(sheet["id"], bbox, fit=False))
entities.extend(frame_entities(sheet["id"], bbox, fit=False, fields={"도면명": "횡단면도"}))
return {
"format": DRAWING_FORMAT,
@@ -11,6 +11,7 @@ A1 템플릿 기하(변환 시점 고정값): 전체 840x594, 하단 y17~47 표
import json
import logging
import re
from functools import lru_cache
from pathlib import Path
from typing import Any
@@ -137,11 +138,28 @@ def usable_area() -> tuple[float, float]:
)
_PLACEHOLDER = re.compile(r"\{\{\s*([^}]+?)\s*\}\}")
def _fill_placeholders(entities: list[dict[str, Any]], fields: dict[str, str]) -> None:
"""도각 텍스트의 {{키}}를 값으로 바꾼다. 값이 없으면 빈칸 — 남의 값이 남지 않는다."""
for entity in entities:
if entity.get("type") != "Text":
continue
shape = entity.get("shapeData") or {}
label = shape.get("label")
if isinstance(label, str) and "{{" in label:
shape["label"] = _PLACEHOLDER.sub(
lambda match: str(fields.get(match.group(1), "")), label
)
def frame_entities(
drawing_id: str,
content_bbox: tuple[float, float, float, float],
template_name: str = A1_TEMPLATE,
fit: bool = True,
fields: dict[str, str] | None = None,
) -> list[dict[str, Any]]:
"""콘텐츠 bbox를 감싸는 도각 프레임 엔티티 목록(잠금 레이어). 템플릿 없으면 빈 목록.
@@ -173,7 +191,9 @@ def frame_entities(
dx = (min_x + max_x) / 2.0 - (ix0 + ix1) / 2.0 * scale
dy = (min_y + max_y) / 2.0 - (iy0 + iy1) / 2.0 * scale
return [
placed = [
_transform_entity(entity, f"{drawing_id}:frame:{index}", scale, dx, dy)
for index, entity in enumerate(template.get("entities", []))
]
_fill_placeholders(placed, fields or {})
return placed
File diff suppressed because it is too large Load Diff