/* ============================================================================= * design_structure_ford.ts * 횡단배수 › 세월교 명세 — 사용자 구조물 표 04(`docs/raw/구조물정의_표/04_횡단배수_세월교.md`) 그대로. * * 컨테이너 셋: 세월교(필수) · 유입 구조(필수) · 유출 구조(필수). 구조 · 정본 = 이 명세 · 이름만 정의(M02)에서 바꿈. * 저장 키 = pipe_points.json 옛 키 그대로(B06 세월교 세트 · B07 · B08 이 읽는 자리) — 새 키 = 유입 · 유출 구조 * (`inlet_type` · `outlet_type` = 없음 · 날개벽 · 흙막이) · 고르면 옛 날개벽 설치 칸(`wing_in` · `wing_out`)도 함께 적음. * 월류 높이 = 월류 폭과 연동(폭을 바꾸면 필요 수심으로 채움 · 그 아래로는 안 받음) — 계산은 `design_structure_ford_calc`. * import 없음 — 시험이 이 파일만 옮겨 돌림. * ========================================================================== */ import type { SpecContainer, SpecChoice, StructureSpec } from "./design_structure_spec"; /** 유입 · 유출 구조 — 날개벽만 옛 설치 칸이 「있음」. */ const guard = (side: "in" | "out"): SpecChoice[] => [ { value: "없음", label: "없음", also: { [`wing_${side}`]: "없음" } }, { value: "날개벽", label: "날개벽", also: { [`wing_${side}`]: "있음" } }, { value: "흙막이", label: "흙막이", also: { [`wing_${side}`]: "없음" } }, ]; const guardContainer = (id: "inlet" | "outlet", title: string, link: string): SpecContainer => ({ id, title, required: true, link, items: [ { id: "structure", label: "구조", kind: "select", key: `${id}_type`, choices: guard(id === "inlet" ? "in" : "out"), }, ], }); export const FORD_SPEC: StructureSpec = { typeId: "ford_bridge", containers: [ { id: "ford", title: "세월교", required: true, link: "gford", items: [ { id: "diameter", label: "관경", kind: "select", key: "pipe_diameter_mm", asNumber: true, choices: ["800", "1000", "1200", "1500"].map((v) => ({ value: v, label: v })), }, { id: "width", label: "월류 폭 (m)", kind: "number", key: "ford_width_m", step: 0.1 }, { id: "height", label: "월류 높이 (m)", kind: "number", key: "ford_height_m", step: 0.01 }, { id: "count", label: "수량 (련)", kind: "number", key: "pipe_count", step: 1 }, ], }, guardContainer("inlet", "유입 구조", "gfordin"), guardContainer("outlet", "유출 구조", "gfordout"), ], // 표 04 에 없는 옛 칸 — 화면에서 빼고 값은 남김(지난 정의 값) retired: [ "pipe_kind", "wing_in_height_m", "wing_in_length_m", "wing_in_angle_deg", "wing_out_height_m", "wing_out_length_m", "wing_out_angle_deg", ], }; /** 구조를 날개벽 설치 칸(옛 저장 · B06 조정창이 고치는 칸)에 맞춤 — 있음 = 날개벽 · 없음 = 날개벽이면 없음 * (흙막이는 그대로) · 설치 칸이 없으면 구조 그대로. */ export function withLegacyGuards( options: Record, ): Record { const out = { ...options }; for (const [type, wing] of [ ["inlet_type", "wing_in"], ["outlet_type", "wing_out"], ]) { if (out[wing] === "있음") out[type] = "날개벽"; else if (out[wing] === "없음" && (out[type] ?? "날개벽") === "날개벽") out[type] = "없음"; } return out; }