Merge remote-tracking branch 'origin/dev' into CODEX

This commit is contained in:
2026-10-06 17:00:53 +09:00
386 changed files with 81726 additions and 3042 deletions
+4 -3
View File
@@ -73,10 +73,11 @@ config/spreadsheet_node/
# graphify 위키 산출물 — 창끼리 같은 위키를 찾게 **통째로** git 으로 나름
# (2026-09-09 사용자 확정 「출력물 전체를 공유해도 됨」).
# 다만 아래 둘은 PC 마다 다른 값이라 나르면 안 됨 — 나르면 상대 PC 에서 어긋남.
docs/wiki/graphify-out/.graphify_python
docs/wiki/graphify-out/.graphify_incremental.json
# docs/wiki/graphify-out/.graphify_python
# docs/wiki/graphify-out/.graphify_incremental.json
# 캐시는 **PC 마다 다시 만들어지는 파생물**이라 git 으로 나르지 않는다(2026-09-10 사용자 확정).
# 까닭 — 코드 창에서 graphify 가 돌 때마다 이 폴더가 바뀌어, 위키 브랜치를 받을 때
# 「덮으면 네 것이 날아간다」로 **병합이 막혔다**. 4.3MB·443파일도 함께 가벼워진다.
docs/wiki/graphify-out/cache/
#docs/wiki/graphify-out/cache/
docs/
~$*
+2
View File
@@ -118,6 +118,8 @@ export const STATE_REGISTRY = {
},
/** 설계 가게(`design/design_store`)의 고른 측점 · 구조물 — `{chainageM, structureId}`. */
selection: { bucket: "draft", scope: "project" },
/** 구조물 패널 종류별 캐시 — 고른 구조물 하나 × 종류마다 옛 값(54-32). [저장]·[확정] 뒤 비움. */
"structure-type-cache": { bucket: "draft", scope: "project" },
/** 배수관·암거 조정창에서 예약한 옵션 값. */
culvertopt: { bucket: "draft", scope: "route", legacy: (p, r) => `b06:culvertopt:${p}:${r}` },
/** 배수관 이동(측점 옮김) 예약. */
-7
View File
@@ -1,7 +0,0 @@
/* 좌측 패널 아래 고정 영역의 단추 넷([초기화][저장][확정][보기 전환]) — 좁은 패널에서도 글자가
두 줄로 꺾이지 않게 안쪽 여백을 줄이고 줄바꿈을 막는다(계획서 24-2b). */
.b05-route__dock .b05-route__actions .ui-btn,
.b05-route__dock .b06-profile__actions .ui-btn {
padding-inline: var(--spacing-8);
white-space: nowrap;
}
+1
View File
@@ -65,6 +65,7 @@ export function createDesignDock(
divider.className = "b05-structure__divider";
const row = document.createElement("div");
row.className = view === "profile" ? "b05-route__actions" : "b06-profile__actions";
row.dataset.helpRow = "";
const press = (name: keyof DesignDockActions) => (): void => {
void Promise.resolve(actions[name].run());
+15
View File
@@ -40,6 +40,21 @@
flex: none;
}
/* 새 창으로 뺀 종단 하단 패널(계획서 54-35) — 창 전체를 채움 · 접기 손잡이 · 높이 끌기는 감춤. */
.b05-route-profile.is-popout {
position: relative;
height: 100dvh;
}
.b05-route-profile.is-popout > :not(.b05-route-profile__content) {
display: none;
}
.b05-route-profile__trailing > .b05-route-profile__popout {
padding: 1px var(--spacing-8);
font-size: var(--text-caption);
}
/* 횡단 조정(카드 조정창 사본 · 폼 칸에 옮겨 붙은 행)은 횡단 보기 몫 — 종단 보기에서는 한 벌 폼
안에서 가린다(패널 뿌리 클래스가 보기를 따라 바뀐다). */
.b05-route__panel .b06-adjust-dock,
+8 -7
View File
@@ -53,7 +53,7 @@ import { createProfileEditStore } from "../../B05_Profile/B05_Profile_UI_Profile
import {
structureGroupMenuItems,
stationIdAtStructure as stationIdAtStructureOf,
structureIdAtStation as structureIdAtStationOf,
structureIdKeeping,
} from "../../B05_Profile/B05_Profile_UI_Profile_Structures";
import { configureBalloonOffsets } from "@util/common_util_mass_haul_balance_view";
import {
@@ -121,7 +121,8 @@ export interface DesignProfileContext {
* 계산이 브라우저 안에서 끝나면서(2026-09-03) 서버 왕복이 사라져 250→60ms 로 줄였다 —
* 실측 전 측점(128) 재계산 7.5ms 라 손을 떼는 즉시 유토곡선이 따라온다.
* 60→16ms(2026-09-06) — ▲ 한 번에 라벨이 서기까지 중앙 130ms 를 쟀는데 그중 60ms 가
* 이 대기였다. 한 프레임(16ms)이면 연속 입력은 여전히 마지막 값만 계산한다. */
* 이 대기였다. 한 프레임(16ms)이면 연속 입력은 여전히 마지막 값만 계산한다.
* 횡단 보기는 120ms — 계산마다 카드를 갈아 끼워 길게 누르면 멈춤이 쌓임(9da48d5e7 · 54-22). */
const CROSS_PREVIEW_DEBOUNCE_MS = 16;
export function createDesignProfile(ctx: DesignProfileContext) {
@@ -261,9 +262,7 @@ export function createDesignProfile(ctx: DesignProfileContext) {
/** 한 측점에 알약이 여럿(배수관 · 메쌓기)이면 지금 고른 알약을 그대로 둔다 — 첫 알약으로
* 갈아 끼우면 누른 것과 다른 알약이 켜졌다(계획서 24-6b). */
const structureIdAtStation = (stationId: string | null): string | null =>
stationId !== null && stationIdAtStructure(selectedStructureId) === stationId
? selectedStructureId
: structureIdAtStationOf(stationId, irregularStations, structures);
structureIdKeeping(stationId, selectedStructureId, irregularStations, structures, detail);
const stationIdAtStructure = (structureId: string | null): string | null =>
stationIdAtStructureOf(structureId, irregularStations, structures);
@@ -386,7 +385,7 @@ export function createDesignProfile(ctx: DesignProfileContext) {
detail: () => detail,
routeId: () => routeId,
edits: () => store.edits(),
debounceMs: CROSS_PREVIEW_DEBOUNCE_MS,
debounceMs: () => (root.dataset.view === "cross" ? 120 : CROSS_PREVIEW_DEBOUNCE_MS),
onApplied: (updated) => {
draw();
callbacks?.onCrossDesignsUpdated?.(updated);
@@ -626,8 +625,10 @@ export function createDesignProfile(ctx: DesignProfileContext) {
},
/** 사이드 목록에서 고른 구조물을 그래프 알약·측점 세로선 선택에 함께 맞춘다. */
setSelectedStructure(structureId: string | null) {
// 지금 측점(B06 카드)이 그 구조물 자리면 측점선도 그대로(53-2)
selectedStructureId = structureId;
selectedStationId = stationIdAtStructure(structureId);
const keep = structureId !== null && structureIdAtStation(selectedStationId) === structureId;
selectedStationId = keep ? selectedStationId : stationIdAtStructure(structureId);
draw();
},
/** 이어 공사 시작 기준(측점번호·누가거리 오프셋)을 반영해 측점 라벨·누가거리 표시를 옮긴다. */
+101
View File
@@ -0,0 +1,101 @@
/* =============================================================================
* A00_Common/design/design_profile_popout.ts
* 종단 하단 패널(종단도 · 표 · 유토곡선 · 배수유역도)을 **브라우저 새 창**으로 뺀다(계획서 54-35).
*
* 화면 조각(DOM)만 옮긴다 — 코드 · 자료 · 가게는 메인 창 그대로, 같은 함수가 그린다.
* 창 전역에 걸린 듣기(방향키 · 포인터 놓기 · 메뉴 닫기)는 메인 창에만 있으므로 새 창에서 난
* 키 · 포인터를 메인 문서로 넘긴다. 새 창을 닫거나 메인 창이 떠나면 조각을 제자리로 돌린다.
* ========================================================================== */
import { showToast } from "@ui/ui_template_elements";
import type { DesignProfile } from "./design_profile";
/** 메인 창 문서 · 창에 걸린 듣기가 받아야 할 새 창 이벤트. */
const FORWARD_TYPES = ["keydown", "keyup", "pointerdown", "pointerup", "pointercancel"];
/** 종단 도구줄 [배수유역도] 단추 뒤에 [새 창] 단추를 붙인다 — 두 보기가 같은 한 벌을 쓴다. */
export function attachProfilePopout(
profile: DesignProfile,
slot: HTMLElement,
sideTool: HTMLElement | null,
): void {
const { root } = profile;
let popup: Window | null = null;
const button = document.createElement("button");
button.type = "button";
button.className = "ui-btn ui-btn--ghost b05-route-profile__popout";
button.textContent = "새 창";
button.title = "종단 하단 패널을 브라우저 새 창으로 띄움";
button.addEventListener("click", () => (popup && !popup.closed ? closePopup() : open()));
sideTool?.after(button);
const restore = (): void => {
if (!root.classList.contains("is-popout")) return;
root.classList.remove("is-popout");
button.textContent = "새 창";
slot.append(root);
popup = null;
requestAnimationFrame(profile.redraw);
};
const closePopup = (): void => {
popup?.close();
restore();
};
window.addEventListener("pagehide", closePopup);
const dispose = profile.dispose;
profile.dispose = () => {
window.removeEventListener("pagehide", closePopup);
closePopup();
dispose();
};
function open(): void {
const next = window.open("", "aislo-profile-popout", "popup,width=1400,height=720");
if (!next) {
showToast("새 창이 막힘 — 주소창의 팝업 허용을 켠 뒤 다시 누름", "error");
return;
}
popup = next;
const doc = next.document;
doc.title = "종단 — Aislo";
// 스타일 · 테마 — 메인 창 시트 · html 속성을 그대로 옮겨 같은 색 · 글꼴로 그린다.
doc.head.replaceChildren(
...Array.from(document.querySelectorAll('link[rel="stylesheet"], style'), (node) =>
doc.importNode(node, true),
),
);
Array.from(document.documentElement.attributes).forEach((attr) =>
doc.documentElement.setAttribute(attr.name, attr.value),
);
doc.body.className = document.body.className;
doc.body.style.cssText = `margin:0;height:100dvh;overflow:hidden;background:${getComputedStyle(document.body).backgroundColor}`;
root.classList.add("is-popout");
button.textContent = "제자리로";
doc.body.replaceChildren(root);
// 새 창 키 · 포인터를 메인 문서로 — 대상은 새 창 요소 그대로(입력칸 판정 · 메뉴 안 판정).
FORWARD_TYPES.forEach((type) =>
next.addEventListener(
type,
(event) => {
const Ctor = (window as unknown as Record<string, typeof Event>)[event.constructor.name];
const copy = new (Ctor ?? Event)(type, event);
Object.defineProperty(copy, "target", { value: event.target });
document.dispatchEvent(copy);
if (copy.defaultPrevented) event.preventDefault();
},
true,
),
);
// 새 창이 초점을 잃으면 길게 누르기를 끊는다(메인 창 blur 듣기).
next.addEventListener("blur", () => window.dispatchEvent(new FocusEvent("blur")));
// 새 창 크기 기준으로 다시 맞춘다.
let pending = 0;
new (next as Window & typeof globalThis).ResizeObserver(() => {
next.cancelAnimationFrame(pending);
pending = next.requestAnimationFrame(profile.redraw);
}).observe(root);
next.addEventListener("pagehide", restore);
}
}
+2 -1
View File
@@ -25,7 +25,7 @@ import {
pendingAlignment,
} from "../../B05_Profile/B05_Profile_UI_Profile_Edit";
import { flushCulvertOptions } from "../../B06_Section/B06_Section_Api_Culvert_Options";
import { stateKey } from "../b_page_state";
import { clearState, stateKey } from "../b_page_state";
/** 저장 차례 — 이 순서 그대로 돈다. */
export const DESIGN_SAVE_ORDER = [
@@ -134,6 +134,7 @@ export async function saveDesign(
const label = TOLERANT[step];
await (label ? run().catch(reportOnly(label)) : run());
}
clearState("structure-type-cache", ctx.projectId); // 종류별 캐시는 저장 뒤 비움(54-32)
await ctx.done?.(confirm);
return true;
} catch (error) {
+14 -3
View File
@@ -136,8 +136,9 @@ export function subscribeSelection(projectId: string | null, fn: SelectionListen
}
/**
* 고름을 적고 구독자에게 알린다. `partKey` 를 안 주면 이미 적힌 부재키를 지킨다 — 3D 로
* 부재를 집은 직후 선택 동기화가 측점만 다시 적어도 조정창이 그대로 열려야 한다.
* 고름을 적고 구독자에게 알린다. `partKey` 를 안 주면 **같은 것**을 다시 적을 때만 부재키를 지킨다 —
* 3D 로 부재를 집은 직후 선택 동기화가 측점만 다시 적어도 조정창이 그대로 열려야 한다.
* 다른 구조물로 옮기면 버리고, 빈 값("")을 주면 지운다(53-1).
* `from` 은 낸 쪽 이름 — 구독자가 제 것을 되받아 다시 그리지 않게 거른다.
* 값이 그대로면 알리지 않고, 알림 도중 다시 낸 값은 적기만 한다(되울림 방지).
*/
@@ -157,7 +158,17 @@ export function selectDesign(
before.structureId === selection.structureId &&
(options.partKey === undefined || options.partKey === before.partKey);
if (same) return;
const key = options.partKey ?? before?.partKey;
// 부재키는 같은 것을 다시 적을 때만 지킴 — 다른 구조물로 옮기면 옛 부재(조정창)가 따라오지 않음(53-1)
const sameTarget =
before !== null &&
before.chainageM !== null &&
isNear(before.chainageM, selection.chainageM) &&
before.structureId === selection.structureId;
// 빈 부재키("") = 부재를 풂
const key =
options.partKey === ""
? undefined
: (options.partKey ?? (sameTarget ? before?.partKey : undefined));
writeState(
"structure-pick",
{ at: selection.chainageM, key, sid: selection.structureId ?? undefined },
+5 -1
View File
@@ -22,6 +22,7 @@ import type { RouteProfilePanelCallbacks } from "../../B05_Profile/B05_Profile_U
import { drainageSide, drainageSideTool } from "../../B05_Profile/B05_Profile_UI_Profile_SideTool";
import { createDesignPanel, type DesignPanel } from "./design_panel";
import { createDesignProfile, type DesignProfile } from "./design_profile";
import { attachProfilePopout } from "./design_profile_popout";
import { saveDesign, type DesignSaveStep } from "./design_save";
import { resetDesign } from "./design_reset";
import type { DesignView } from "./design_dock";
@@ -147,11 +148,12 @@ function toAll<K extends keyof RouteProfilePanelCallbacks>(
/** 종단도 한 벌 — 처음 부를 때 만들어 종단도 자리에 붙인다. */
export function sharedProfile(shared: DesignPageShared): DesignProfile {
if (shared.profile) return shared.profile;
let sideTool: HTMLElement | null = null;
const profile = createDesignProfile({
projectId: shared.projectId,
view: shared.view(),
side: drainageSide,
sideTool: drainageSideTool,
sideTool: (board) => (sideTool = drainageSideTool(board)),
onSelectStation: (stationId) => bound(shared).profile?.onSelectStation(stationId),
onResetAll: () => bound(shared).profile?.onResetAll?.(),
callbacks: {
@@ -173,6 +175,7 @@ export function sharedProfile(shared: DesignPageShared): DesignProfile {
},
});
shared.profileSlot.append(profile.root);
attachProfilePopout(profile, shared.profileSlot, sideTool);
shared.profile = profile;
return profile;
}
@@ -190,6 +193,7 @@ export function sharedStructures(shared: DesignPageShared): StructuresSection {
onPipeUpdate: (from, to, attributes) => on().onPipeUpdate?.(from, to, attributes),
onPipeRemove: (chainageM) => on().onPipeRemove?.(chainageM),
onPipeSelect: (chainageM) => on().onPipeSelect?.(chainageM),
onListRelease: () => on().onListRelease?.(),
onReveal: () => shared.revealLeft(),
},
{ includeDetail: () => shared.view() === "cross", projectId: shared.projectId },
+124
View File
@@ -0,0 +1,124 @@
/* =============================================================================
* design_structure_box.ts
* 횡단배수 › 박스암거 명세 — 사용자 구조물 표 02 고친 판(`docs/raw/구조물정의_표/02_횡단배수_박스암거.md`) 그대로.
*
* 컨테이너 셋(모두 필수): 본체 · 유입 구조 · 유출 구조. 구조 · 정본 = 이 명세 · 이름만 정의(M02)에서 바꿈.
* 저장 키 = pipe_points.json 옛 키 그대로(B06 횡단 · B07 · B08 이 읽는 자리):
* · 본체 = `body_width_m` · `body_height_m` 수 — 규격 칸은 저장 안 함(폭 · 높이로 되찾음 · `bodyOf`)
* · 사용자 입력에 두 칸 다 비면 `body_custom` = 「사용자 입력」 표시만
* · 유입 · 유출 구조 = `wing_in` · `wing_out`(없음 · 날개벽 · 흙막이 · 옛 「있음」 = 날개벽)
* — 엔진은 날개벽만 세움(`_wing_spec` ↔ `wingSpec` 짝)
* 표 02 에 없는 옛 날개벽 치수 칸은 화면에서 빼고 값은 남김(지난 정의 값).
* import 없음(꼴만) — 시험이 이 파일만 옮겨 돌림.
* ========================================================================== */
import type { Instance, SpecItem, StructureSpec } from "./design_structure_spec";
export const BOX_CUSTOM = "사용자 입력";
/** 사용자 입력에 가로 · 세로 둘 다 빈 채 저장했다는 표시(폭 · 높이 수가 없을 때만 적음). */
export const BOX_CUSTOM_KEY = "body_custom";
/** 본체 규격 → [가로, 세로](m) — 실무 관측 규격(2026-08-17 사용자 확정). */
const BOX_PRESETS: Record<string, readonly [number, number]> = {
"2.0×2.0": [2, 2],
"3.0×3.0": [3, 3],
};
/** 유입 · 유출 구조 — 같은 선택지 · 키만 다름. */
const structureItem = (key: string): SpecItem => ({
id: "structure",
label: "구조",
kind: "select",
key,
choices: [
{ value: "없음", label: "없음" },
{ value: "날개벽", label: "날개벽" },
{ value: "흙막이", label: "흙막이" },
],
});
/** 사용자 입력일 때만 서는 숫자 칸. */
const customSide = (id: string, label: string, key: string): SpecItem => ({
id,
label,
kind: "number",
step: 0.1,
by: { item: "size", map: { [BOX_CUSTOM]: { key } } },
});
export const BOX_SPEC: StructureSpec = {
typeId: "box_culvert",
containers: [
{
id: "body",
title: "본체",
required: true,
link: "gboxbody",
items: [
{
id: "size",
label: "본체 규격",
kind: "select",
choices: [
...Object.keys(BOX_PRESETS).map((value) => ({
value,
label: value.replace("×", " × "),
})),
{ value: BOX_CUSTOM, label: BOX_CUSTOM },
],
},
customSide("width", "가로 (m)", "body_width_m"),
customSide("height", "세로 (m)", "body_height_m"),
],
},
{
id: "inlet",
title: "유입 구조",
required: true,
link: "gboxin",
items: [structureItem("wing_in")],
},
{
id: "outlet",
title: "유출 구조",
required: true,
link: "gboxout",
items: [structureItem("wing_out")],
},
],
// 표 02 에 없는 옛 날개벽 치수 — 화면에서 빼고 값은 남김(지난 정의 값)
retired: ["in", "out"].flatMap((side) =>
["height_m", "length_m", "angle_deg"].map((field) => `wing_${side}_${field}`),
),
};
/** 옛 저장 → 폼에 줄 옵션 — 설치 「있음」 = 날개벽(같은 뜻 · 저장하면 새 값으로 굳음). */
export function boxOptionsIn(
options: Record<string, string | number>,
): Record<string, string | number> {
const out = { ...options };
for (const key of ["wing_in", "wing_out"]) if (out[key] === "있음") out[key] = "날개벽";
return out;
}
/** 저장 폭 · 높이 → 본체 칸 값 — 규격과 맞으면 그 규격 · 손 값이 하나라도 있거나 사용자 입력 표시면
* 사용자 입력(빈 칸은 빈 채) · 아니면 빈 값. */
export function bodyOf(options: Record<string, string | number>): Instance {
const width = Number(options.body_width_m);
const height = Number(options.body_height_m);
const preset = Object.entries(BOX_PRESETS).find(
([, [w, h]]) => Math.abs(w - width) < 0.05 && Math.abs(h - height) < 0.05,
);
if (preset) return { size: preset[0] };
if (!(width > 0) && !(height > 0) && options[BOX_CUSTOM_KEY] !== BOX_CUSTOM) return { size: "" };
const side = (n: number): string => (n > 0 ? String(n) : "");
return { size: BOX_CUSTOM, width: side(width), height: side(height) };
}
/** 본체 칸 값 → 저장 폭 · 높이 — 규격이면 규격 수(사용자 입력은 명세 키가 적음) · 사용자 입력에 두 칸 다
* 비면 표시 키만(다시 열 때 「사용자 입력」). */
export function bodyOptions(body: Instance | undefined): Record<string, string | number> {
const preset = BOX_PRESETS[body?.size ?? ""];
if (preset) return { body_width_m: preset[0], body_height_m: preset[1] };
const blank = !(body?.width ?? "").trim() && !(body?.height ?? "").trim();
return body?.size === BOX_CUSTOM && blank ? { [BOX_CUSTOM_KEY]: BOX_CUSTOM } : {};
}
@@ -0,0 +1,88 @@
/* =============================================================================
* 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<string, string | number>,
): Record<string, string | number> {
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;
}
@@ -0,0 +1,27 @@
/* =============================================================================
* design_structure_ford_calc.ts
* 세월교 명세 계산 — 월류 폭 ↔ 월류 높이 연동(PLAN 52-4).
*
* 높이 = 담당 유역 설계유량을 그 월류 폭으로 넘기는 필요 수심(Manning 개수로 · `fordSection` 그대로).
* 근거: Manning 공식 `resources/knowledge/technical_info/01_임도/03_계산정보/통수단면.md:23~33`
* (KDS 44 40 00 2.7.1~2.7.2) · 조도계수 0.017 = 같은 파일 :59(콘크리트 수로 보통 · 울진 물넘이) ·
* 경사 10 % = 실무 수리계산서 역산값(`config_frontend.FORD_SLOPE` · 지식DB 수치 없음).
* 폭을 바꾸면 높이 칸을 이 값으로 채움 · 사용자는 올려 적을 수 있고 이 값 아래로는 안 받음.
* 높이는 저장되는 입력값 — 서버는 받은 높이로 노면을 내림(`B06_Section_Engine_Culvert._ford_set`) · 재계산 안 함.
* 설계유량이 없으면 null = 손 입력.
* ========================================================================== */
import { fordSection } from "../../B05_Profile/B05_Profile_UI_Drainage_Facility_Fields";
/** 월류 폭(m) → 필요 월류 높이(m) · 0.01 m 올림. 유량 · 폭이 없으면 null. */
export function fordHeightM(designFlowM3s: number | null, widthM: number): number | null {
const section = fordSection(designFlowM3s, widthM);
return section ? Math.ceil(section.depthM * 100 - 1e-9) / 100 : null;
}
/** 높이 빈 칸 안내. */
export function fordHeightHint(designFlowM3s: number | null, widthM: number): string {
const need = fordHeightM(designFlowM3s, widthM);
if (need !== null) return `필요 수심 ${need.toFixed(2)} 이상`;
return designFlowM3s ? "월류 폭을 넣으면 셈" : "설계유량 없음 — 손 입력";
}
@@ -0,0 +1,47 @@
/* =============================================================================
* design_structure_ford_pavement.ts
* 횡단배수 › 물넘이 포장 명세 — 사용자 구조물 표 03(`docs/raw/구조물정의_표/03_횡단배수_물넘이포장.md`) 그대로.
*
* 컨테이너 둘: 경사각도(필수 · 각도 손 입력 · 도) · 도수로/돌붙임(선택 · 구조 = 도수로 · 돌붙임).
* 저장 = pipe_points.json `options` — 새 키 `ford_slope_deg` · 선택 컨테이너 `ford_chute_{n}_structure`.
* 경사각도는 옛 「바닥 경사(%)」(`ford_slope_pct` · B06 파임 기울기)와 뜻이 같은지 또렷하지 않아 잇지 않음.
* import 없음 — 시험이 이 파일만 옮겨 돌림.
* ========================================================================== */
import type { StructureSpec } from "./design_structure_spec";
export const FORD_PAVEMENT_SPEC: StructureSpec = {
typeId: "ford_pavement",
containers: [
{
id: "slope",
title: "경사각도",
required: true,
link: "gfordpaveslope",
items: [
{ id: "angle", label: "경사각도 (°)", kind: "number", key: "ford_slope_deg", step: 0.1 },
],
},
{
id: "chute",
title: "도수로/돌붙임",
required: false,
prefix: "ford_chute",
link: "gfordpavechute",
max: 1,
items: [
{
id: "structure",
label: "구조",
kind: "select",
choices: [
{ value: "도수로", label: "도수로" },
{ value: "돌붙임", label: "돌붙임" },
],
},
],
},
],
// 표 03 에 없는 옛 칸 — 화면에서 빼고 값은 남김(지난 정의 값)
retired: ["ford_width_m", "ford_height_m", "ford_slope_pct", "thickness_cm", "length_m"],
};
+361
View File
@@ -0,0 +1,361 @@
/* =============================================================================
* design_structure_form.ts
* 구조물 명세(`design_structure_spec`) 그리기 — B05 · B06 「구조물 배치」 칸이 같은 노드를 씀.
*
* · 필수 컨테이너 = 늘 보임(한 벌) · 선택 컨테이너 = [추가] 로 인스턴스를 늘리고 인스턴스마다 [빼기] ·
* `max` 에 차면 [추가] 숨김
* · 항목: 고르기(상위 값에 따른 선택지 · 저장 키) · 숫자(맞물림 = 길이 · 전 · 후) · 글(손 입력) · 자동(읽기만)
* · 인스턴스마다 「구조물 조합」 잇기 줄(`buildSummaryRow` · 고르기 모달 = 패널의 그룹 [고르기] 길 그대로) —
* 값은 패널 `group_items` 에 `linkOf` 키로 둠(빼면 뒤 인스턴스 잇기를 한 칸씩 당김)
* · 값은 폼이 쥠 — 저장은 패널이 `read()` 로 읽어 정본 자리(옵션)에 씀
* · 칸 표식 = `data-spec-item="{컨테이너}.{항목}"`(정의 규칙 · 그룹 상자가 안 건드리게 옵션 키 표식 안 씀)
* ========================================================================== */
import {
branchOf,
choiceLabel,
choicesOf,
containerTitle,
itemLabel,
linkOf,
readState,
solveSplit,
TEXT_MAX,
writeOptions,
type SpecContainer,
type SpecItem,
type SpecNames,
type SpecState,
type SplitRole,
type StructureSpec,
} from "./design_structure_spec";
import {
group,
grid,
labeled,
numberInput,
stepper,
} from "../../B05_Profile/B05_Profile_UI_Drainage_Facility_Fields";
import { buildSummaryRow } from "../../B05_Profile/B05_Profile_UI_Structures_Summary_Row";
import type { GroupItems, SummaryItem } from "../../common_util/common_util_summary_item";
/** 잇기 값 자리 — 패널 그룹 값(`group_items`)을 그대로 씀. */
export interface SpecLinks {
get: () => GroupItems;
pick: (key: string) => void;
/** [해제] — 패널이 풀고 반영. */
clear: (key: string) => void;
/** 값만 옮김(빼기 뒤 당김) — 반영은 뒤이은 폼 변경 알림이 함. */
set: (key: string, item: SummaryItem | null) => void;
}
export interface SpecFormHooks {
/** 자동 항목 값 글(빈 글 = 「—」). */
auto?: (c: SpecContainer, item: SpecItem, state: SpecState) => string;
onChange?: (c: SpecContainer, item: SpecItem) => void;
/** 선택 컨테이너 개수를 밖에서 정함(54-1 배관 흙막이 = 추가 기슭막이(단)) — 수면 그만큼 늘 보임 ·
* [추가] · [빼기] 없음 · 줄면 끝에서부터 가림(값은 남음 · 54-10) · null = 모름(저장된 것 그대로) ·
* undefined = 손 [추가]. */
count?: (c: SpecContainer) => number | null | undefined;
/** 컨테이너 칸 끝에 덧붙이는 칸(54-27 배관 유출 「추가 흙막이(단)」 · 값은 저장 옵션 밖). */
fields?: (c: SpecContainer, values: Record<string, string>) => HTMLElement[];
/** 그림이 쓰는 값(54-13) — 자동 규칙일 때 그 값 · 꼬리(「자동」) ·
* null = 없음. 보여 주기만(값 · 저장은 사용자가 고를 때만). `values` = 보이는 값(위 칸 반영). */
shown?: (
c: SpecContainer,
item: SpecItem,
values: Record<string, string>,
index: number,
) => { value: string; tag: string } | null;
}
export interface SpecForm {
root: HTMLElement;
/** 명세 · 저장 값으로 다시 그림. `names` = 정의 이름 바꿈 · `groupNames` = 정의 그룹 이름. */
write: (
spec: StructureSpec,
options: Record<string, string | number>,
names?: SpecNames,
groupNames?: Record<string, string>,
/** 정의 기본값(저장 키 → 값) — 필수 상자 빈 고르기 칸이 받는 값(54-43). */
defaults?: Record<string, string | number>,
) => void;
read: () => Record<string, string | number>;
state: () => SpecState;
/** 한 항목 값을 바꿔 그림(B06 조정창 맞춤 등) — change 알림은 안 함. */
setValue: (containerId: string, itemId: string, value: string) => void;
/** 필수 컨테이너 끝에 붙일 자리(B06 조정 행). */
slot: (containerId: string) => HTMLElement;
/** 잇기 값이 바뀌었을 때 줄을 다시 그림. */
paintLinks: () => void;
refresh: () => void;
/** 밖에서 정한 개수(`hooks.count`)가 바뀌었을 때 — 맞춰 그리고 바뀌었으면 change 알림. */
recount: () => void;
}
export function createSpecForm(links: SpecLinks | null, hooks: SpecFormHooks = {}): SpecForm {
const root = document.createElement("div");
root.className = "b05-structure__spec";
let spec: StructureSpec | null = null;
let state: SpecState = {};
let names: SpecNames = {};
let groupNames: Record<string, string> = {};
let defaults: Record<string, string | number> = {};
const recent = new Map<Instance, SplitRole[]>();
const slots = new Map<string, HTMLElement>();
const rows: Array<{ key: string; set: (item: SummaryItem | null) => void }> = [];
type Instance = Record<string, string>;
const slotOf = (id: string): HTMLElement => {
let slot = slots.get(id);
if (!slot) {
slot = document.createElement("div");
slot.className = "b05-structure__adjust-slot";
slots.set(id, slot);
}
return slot;
};
const control = (
c: SpecContainer,
item: SpecItem,
values: Instance,
tag?: string,
): HTMLElement => {
if (item.kind === "select") {
const select = document.createElement("select");
const choices = choicesOf(item, values);
const now = values[item.id] ?? "";
const drawn = choices.find((ch) => ch.value === now);
// 그림이 쓰는 값은 빈 보기 자리에 꼬리를 달아 보임 — 고른 값과 구별(54-13)
const name = drawn ? choiceLabel(c, item, drawn, names) : now;
const blank = !tag ? "" : name ? `${name} (${tag})` : tag;
// 필수 상자 = 빈 보기 없음(54-43) · 선택 상자 빈 보기 = 빈 글
select.replaceChildren(
...(c.required && !tag ? [] : [new Option(blank, "")]),
...choices.map((ch) => new Option(choiceLabel(c, item, ch, names), ch.value)),
);
// 선택지 밖 옛 값은 그 값만 남겨 보임(지운 값을 몰래 바꾸지 않음)
if (!tag && now && !drawn) select.add(new Option(now, now));
select.value = tag ? "" : now;
return select;
}
if (item.kind === "text") {
const input = document.createElement("input");
input.type = "text";
input.maxLength = TEXT_MAX;
input.value = values[item.id] ?? "";
return input;
}
// 빈 칸 = 그냥 빈 칸(54-43 · 자리표시 글 없음)
const input = numberInput(String(item.step ?? 0.1), "0");
if (item.kind === "auto") {
// 보여 주는 칸(54-1) — 손 입력 칸 아님
const shown = document.createElement("output");
shown.className = "b05-structure__auto";
shown.textContent = hooks.auto?.(c, item, state) || "—";
shown.title = "자동 계산";
return shown;
}
input.value = values[item.id] ?? "";
return stepper(input, item.step ?? 0.1);
};
const onEdit = (
c: SpecContainer,
item: SpecItem,
values: Instance,
raw: string,
view: Instance,
): void => {
// 그림 값을 보이던 위 칸 아래를 고침 = 그 위 값을 고른 것 — 다른 갈래 값은 비움(54-13)
const parent = item.by?.item;
if (parent && view[parent] !== values[parent]) {
values[parent] = view[parent];
for (const child of c.items) if (child.by?.item === parent) values[child.id] = "";
}
values[item.id] = raw;
if (item.split) {
const order = [item.split, ...(recent.get(values) ?? []).filter((r) => r !== item.split)];
recent.set(values, order);
const role = (r: SplitRole) => c.items.find((i) => i.split === r)!;
const solved = solveSplit(
{
length: values[role("length").id],
before: values[role("before").id],
after: values[role("after").id],
},
order,
);
for (const r of ["length", "before", "after"] as SplitRole[])
values[role(r).id] = solved[r] ?? "";
}
// 위 항목이 바뀌면 갈래(선택지 · 저장 키)가 달라짐 — 선택지 밖 값은 비움
for (const child of c.items.filter((i) => i.by?.item === item.id)) {
const allowed = choicesOf(child, values);
if (child.kind === "select" && !allowed.some((ch) => ch.value === values[child.id]))
values[child.id] = "";
}
paint();
hooks.onChange?.(c, item);
};
const instanceBox = (c: SpecContainer, values: Instance, index: number): HTMLElement => {
const title = containerTitle(c, names, groupNames[c.link]);
// 하나만 서는 상자(max 1)는 번호 없음(54-50)
const box = group(c.required || c.max === 1 ? title : `${title} ${index + 1}`);
box.root.dataset.specContainer = c.id;
box.root.dataset.specIndex = String(index); // 칸을 고친 뒤 다시 그려도 몇째 상자인지(54-30)
// 필수 상자 빈 고르기 칸 = 정의 기본값(없으면 첫 보기)을 실제 값으로 — 저장도 그 값(54-43)
if (c.required)
for (const item of c.items) {
if (item.kind !== "select" || values[item.id] || (item.by && !branchOf(item, values)))
continue;
const choices = choicesOf(item, values);
const key = branchOf(item, values)?.key;
const wanted = String((key ? defaults[key] : undefined) ?? item.default ?? "");
values[item.id] = (choices.find((ch) => ch.value === wanted) ?? choices[0])?.value ?? "";
}
// 보이는 값 = 고른 값 + 그림이 쓰는 값(54-13) · 위 칸이 다른 갈래를 보이면 아래 칸은 빈 채로
const view: Instance = { ...values };
const tags = new Map<string, string>();
for (const item of c.items) {
if (item.by && view[item.by.item] !== values[item.by.item]) view[item.id] = "";
const drawn = item.kind === "select" ? hooks.shown?.(c, item, view, index) : null;
if (!drawn) continue;
view[item.id] = drawn.value;
tags.set(item.id, drawn.tag);
}
const fields = c.items
.filter((item) => item.kind === "auto" || !item.by || branchOf(item, view))
.map((item) => {
const input = control(c, item, view, tags.get(item.id));
const wrap = labeled(itemLabel(c, item, names), input);
wrap.dataset.specItem = `${c.id}.${item.id}`;
if (tags.has(item.id)) wrap.dataset.specShown = tags.get(item.id);
const target = input.querySelector?.("input, select") ?? input;
target.addEventListener("change", () =>
onEdit(c, item, values, (target as HTMLInputElement | HTMLSelectElement).value, view),
);
return wrap;
});
box.body.append(grid(...fields, ...(hooks.fields?.(c, values) ?? [])));
if (c.required) {
const slot = slotOf(c.id);
// B06 조정 강조(테두리 · 이름표)는 칸 상자에 붙음 — 다시 그려도 이어 감(53-1)
const prev = slot.closest("fieldset");
if (prev?.classList.contains("is-active")) {
const legend = box.root.querySelector("legend")!;
legend.dataset.baseLabel = legend.textContent ?? "";
legend.textContent = prev.querySelector("legend")?.textContent ?? legend.textContent;
box.root.classList.add("is-active");
}
box.body.append(slot);
}
if (links) {
const key = linkOf(c, index + 1);
const row = buildSummaryRow();
row.root.querySelector(".b05-structure__summary-label")!.textContent = "구조물 조합";
row.root.dataset.specLink = key;
row.set(links.get()[key] ?? null);
row.bind({ pick: () => links.pick(key), clear: () => links.clear(key) });
rows.push({ key, set: row.set });
box.body.append(row.root);
}
if (!c.required && hooks.count?.(c) === undefined) {
const remove = document.createElement("button");
remove.type = "button";
remove.className = "b05-route__irregular-btn";
remove.textContent = "빼기";
remove.dataset.specRemove = c.id;
remove.addEventListener("click", () => {
const list = state[c.id];
// 잇기는 인스턴스 차례를 따름 — 뒤 것을 한 칸씩 당기고 마지막 키는 풂
if (links) {
const now = links.get();
for (let n = index + 1; n < list.length; n++)
links.set(linkOf(c, n), now[linkOf(c, n + 1)] ?? null);
links.set(linkOf(c, list.length), null);
}
list.splice(index, 1);
paint();
hooks.onChange?.(c, c.items[0]);
});
box.root.querySelector("legend")!.append(" ", remove);
}
return box.root;
};
// 새로 서는 상자 = 명세 기본값을 칸에 실제 값으로(54-36 · 이미 있는 상자 값은 그대로)
const fresh = (c: SpecContainer): Instance =>
Object.fromEntries(c.items.flatMap((i) => (i.default ? [[i.id, i.default]] : [])));
/** 밖에서 정한 개수 — 모자라면 새 인스턴스를 늘림(늘었으면 true) · 넘친 인스턴스 · 잇기는
* 가리기만 하고 값에 남김(54-10 · 파일에 그대로). */
const fit = (c: SpecContainer, list: Instance[]): boolean => {
const n = hooks.count?.(c);
if (c.required || n === undefined || n === null || n <= list.length) return false;
while (list.length < n) list.push(fresh(c));
return true;
};
const shown = (c: SpecContainer, list: Instance[]): Instance[] => {
const n = c.required ? null : hooks.count?.(c);
return n === undefined || n === null ? list : list.slice(0, n);
};
function paint(quiet = true): void {
rows.length = 0;
const boxes: HTMLElement[] = [];
const fitted: SpecContainer[] = [];
for (const c of spec?.containers ?? []) {
const list = (state[c.id] ??= c.required ? [{}] : []);
if (fit(c, list)) fitted.push(c);
shown(c, list).forEach((values, index) => boxes.push(instanceBox(c, values, index)));
if (c.required || (c.max && list.length >= c.max) || hooks.count?.(c) !== undefined) continue;
const add = document.createElement("button");
add.type = "button";
add.className = "b05-route__irregular-btn b05-structure__spec-add";
add.textContent = `+ ${containerTitle(c, names, groupNames[c.link])}`;
add.title = "추가";
add.dataset.specAdd = c.id;
add.addEventListener("click", () => {
list.push(fresh(c));
paint();
hooks.onChange?.(c, c.items[0]);
});
boxes.push(add);
}
root.replaceChildren(...boxes);
// 개수가 밖에서 바뀌었으면 값 변경으로 알림(불러오기 때는 안 함)
if (!quiet) fitted.forEach((c) => hooks.onChange?.(c, c.items[0]));
// 상자를 새로 세움 — 고른 상자 강조를 다시 얹을 곳(B06 · 54-30 · 시험 흉내 DOM 은 없음)
root.dispatchEvent?.(new Event("specpaint", { bubbles: true }));
}
return {
root,
write(next, options, nextNames = {}, nextGroups = {}, nextDefaults = {}) {
spec = next;
defaults = nextDefaults;
names = nextNames;
groupNames = nextGroups;
state = readState(next, options);
recent.clear();
paint();
},
read: () => (spec ? writeOptions(spec, state) : {}),
state: () => state,
setValue(containerId, itemId, value) {
const values = state[containerId]?.[0];
if (!values) return;
values[itemId] = value;
paint();
},
slot: slotOf,
paintLinks() {
const now = links?.get() ?? {};
rows.forEach((row) => row.set(now[row.key] ?? null));
},
refresh: () => paint(),
recount: () => paint(false),
};
}
+200
View File
@@ -0,0 +1,200 @@
/* =============================================================================
* design_structure_pipe.ts
* 횡단배수 › 배관 명세 — 사용자 구조물 표 01(`docs/raw/구조물정의_표/01_횡단배수_배관.md`) 그대로.
*
* 컨테이너 다섯: 관(필수) · 관 보호공(유입)(필수) · 관 보호공(유출)(필수) · 흙막이(선택 · 개수 = 유출
* 「추가 기슭막이(단)」 · 54-1) · 도수로/돌붙임(선택 · 여러 개). 집수정 = 길이 · 전 · 후 없음(54-1).
* 구조 · 정본 = 이 명세 · 이름만 정의(M02)에서 바꿈.
* 저장 키 = pipe_points.json 옛 키 그대로(B06 횡단 · B07 · B08 이 읽는 자리) — 흙막이 값은 옛 「기슭막이」
* (`inlet_type` · `*_revet_*`)에 둠. 새 키 = 집수정 높이 · 선택 컨테이너(`soil_add_{n}_*` · `chute_add_{n}_*`).
* 정함(PLAN 52): 유출 형태 = 흙막이 6가지 · 도수로/돌붙임 = 구조만 · 길이 = 전 + 후 맞물림.
* 계산(관 길이 · 높이 안내)은 `design_structure_pipe_calc`.
* import = 같은 폴더 명세뿐 — 시험이 이 폴더 파일만 옮겨 돌림.
* ========================================================================== */
import type { SpecChoice, SpecItem, StructureSpec } from "./design_structure_spec";
import { BOX_SPEC } from "./design_structure_box";
import { FORD_SPEC } from "./design_structure_ford";
import { FORD_PAVEMENT_SPEC } from "./design_structure_ford_pavement";
import { ETC_SPEC, PAVEMENT_SPEC } from "./design_structure_road";
const SOIL = "기슭막이"; // 저장 값(옛 키 그대로) — 화면 이름은 흙막이
const BASIN = "집수정";
const SOIL_FORMS: SpecChoice[] = [
{ value: "돌쌓기(찰)", label: "돌 쌓기(찰)" },
{ value: "돌쌓기(메)", label: "돌 쌓기(메)" },
{ value: "콘크리트", label: "콘크리트" },
{ value: "돌망태", label: "돌망태" },
{ value: "통나무·목재틀", label: "통나무/목재틀" },
{ value: "바자", label: "바자" },
];
const BASIN_FORMS: SpecChoice[] = [
{ value: "I", label: "I형" },
{ value: "L", label: "L형" },
{ value: "U", label: "ㄷ형" },
];
/** 추가 흙막이 기본값(54-36 · 사면안정 흙막이 정의 기본값과 같음) — 필수 보호공 기본값은 정의 파일. */
const SOIL_ADD_DEFAULTS: Record<string, string> = {
form: "돌쌓기(찰)",
length: "10",
height: "1.5",
before: "5",
after: "5",
};
/** 형태 · 길이 · 높이 · 전 · 후 — 필수 보호공은 구조 갈래마다 옛 키 · 선택 흙막이는 인스턴스 키. */
function guardItems(keys?: Record<string, Record<string, string>>): SpecItem[] {
const by = (field: string, choices?: Record<string, SpecChoice[]>) =>
keys
? {
item: "structure",
map: Object.fromEntries(
// 키 없는 갈래 = 그 구조에 없는 칸(집수정 길이 · 전 · 후) — 가림
Object.entries(keys)
.filter(([, k]) => k[field])
.map(([structure, k]) => [
structure,
{ key: k[field], choices: choices?.[structure] },
]),
),
}
: undefined;
const items: SpecItem[] = [
{
id: "form",
label: "형태",
kind: "select",
choices: SOIL_FORMS,
by: by("form", { [BASIN]: BASIN_FORMS, [SOIL]: SOIL_FORMS }),
},
{ id: "length", label: "길이 (m)", kind: "number", split: "length", step: 1, by: by("length") },
{ id: "height", label: "높이 (m)", kind: "number", step: 0.1, by: by("height") },
{
id: "before",
label: "기준측점 전 (m)",
kind: "number",
split: "before",
step: 0.5,
by: by("before"),
},
{
id: "after",
label: "기준측점 후 (m)",
kind: "number",
split: "after",
step: 0.5,
by: by("after"),
},
];
return keys ? items : items.map((item) => ({ ...item, default: SOIL_ADD_DEFAULTS[item.id] }));
}
const revetKeys = (side: "inlet" | "outlet"): Record<string, string> => ({
form: `${side}_revet_form`,
length: `${side}_revet_length_m`,
height: `${side}_revet_height_m`,
before: `${side}_revet_before_m`,
after: `${side}_revet_after_m`,
});
export const PIPE_SPEC: StructureSpec = {
typeId: "pipe",
containers: [
{
id: "pipe",
title: "관",
required: true,
link: "grv6lny", // 정의 그룹 「관」(46장) — 집계표 잇기 자리 그대로
items: [
{
id: "diameter",
label: "관경",
kind: "select",
key: "pipe_diameter_mm",
asNumber: true,
choices: ["800", "1000", "1200", "1500"].map((v) => ({ value: v, label: v })),
},
{ id: "length", label: "관 길이 (m)", kind: "auto" },
],
},
{
id: "inlet",
title: "관 보호공 (유입)",
required: true,
link: "gnbf9m9",
items: [
{
id: "structure",
label: "구조",
kind: "select",
key: "inlet_type",
choices: [
{ value: BASIN, label: "집수정" },
{ value: SOIL, label: "흙막이", also: { inlet_structure: "revet" } },
],
},
...guardItems({
[BASIN]: { form: "inlet_structure", height: "inlet_basin_height_m" },
[SOIL]: revetKeys("inlet"),
}),
],
},
{
id: "outlet",
title: "관 보호공 (유출)",
required: true,
link: "g9lq9uk",
items: [
{
id: "structure",
label: "구조",
kind: "select",
key: "outlet_type",
choices: [{ value: SOIL, label: "흙막이" }],
},
...guardItems({ [SOIL]: revetKeys("outlet") }),
],
},
{
id: "soil_add",
title: "흙막이",
required: false,
prefix: "soil_add",
link: "gsoiladd",
// 사면안정 흙막이(표 09 · 54-26)와 같은 칸 — 형태 6 · 길이 · 높이 · 전 · 후 · 구조 고르기 없음(54-30)
items: guardItems(),
},
{
id: "chute_add",
title: "도수로/돌붙임",
required: false,
prefix: "chute_add",
link: "gchuteadd",
max: 1, // 하나만(54-48) — 옛 둘 이상은 보이되 [추가]만 숨김
items: [
{
id: "structure",
label: "구조",
kind: "select",
choices: [
{ value: "도수로", label: "도수로" },
{ value: "돌붙임", label: "돌붙임" },
],
},
],
},
],
// 표 01 에 없는 옛 칸 — 화면에서 빼고 값은 남김(지난 정의 값)
retired: ["pipe_kind", "wing_wall_type", "inlet_basin_form", "inlet_basin_material"],
};
/** 명세로 그리는 종류 — 종류 키 → 명세(표가 오는 대로 더함). */
export const STRUCTURE_SPECS: Readonly<Record<string, StructureSpec>> = {
pipe: PIPE_SPEC,
box_culvert: BOX_SPEC,
ford_bridge: FORD_SPEC,
ford_pavement: FORD_PAVEMENT_SPEC,
pavement_concrete: PAVEMENT_SPEC,
etc: ETC_SPEC,
};
@@ -0,0 +1,155 @@
/* =============================================================================
* design_structure_pipe_calc.ts
* 배관 명세 계산 — 관 길이(자동) · 보호공 높이 안내. 계산 자리 = ② TS 를 서버 Node 로:
* 관 길이는 횡단 기하 `computeStoredLayouts`(B06 · 서버 Node 진입점이 같은 함수로 `pipe_length_m` 를
* 셈 · 시험 test_b06_pipe_length) 그대로 — 여기서 새로 셈하지 않음 · 화면에 보이기만(저장 안 함).
* 높이 = 손 입력 · 횡단도 조정 높이는 B06 `withSpecDefaults` 가 같은 키(`*_revet_height_m`)에 실음 ·
* 빈 칸 안내 = 정의 기본값 · 집수정 모양 기본 = 횡단 기하 `DEFAULT_BASIN_SHAPE`(54-36).
* 흙막이 개수 = 주인 측점 유출 「추가 기슭막이(단)」(횡단 설계 patch `extra_wall_counts` · 54-1) 중 지형이 세운 단(54-10) ·
* 쓰기는 횡단 보기 단 수 제어로만(`setPipeExtraCount` · 54-27).
* ========================================================================== */
import type { CrossSection } from "../../B06_Section/B06_Section_Api_Fetch";
import { computeStoredLayouts } from "../../B06_Section/B06_Section_Structure_Layouts";
export { DEFAULT_BASIN_SHAPE } from "../../B06_Section/B06_Section_UI_Cross_Culvert_Basin";
import { PIPE_MATCH_M } from "./design_selection";
/** 횡단 측점 목록을 대는 곳 — 횡단 보기가 자료를 받으면 걸어 둠(종단만 연 동안은 없음). */
let sectionsSource: (() => readonly CrossSection[] | null) | null = null;
export function setPipeSectionsSource(source: () => readonly CrossSection[] | null): void {
sectionsSource = source;
}
/** 유출 단 수를 대는 곳 — 횡단 보기의 세션 값 우선(`countFor`) · 없으면 정본 patch. */
let extraCountSource: ((section: CrossSection) => number) | null = null;
export function setPipeExtraCountSource(source: (section: CrossSection) => number): void {
extraCountSource = source;
}
/** 유출 단 수를 쓰는 곳 — 횡단 보기의 단 수 제어(54-27) · 종단 보기는 횡단 보기를 숨긴 채 세워 씀. */
let extraCountSink: ((section: CrossSection, count: number) => void) | null = null;
let crossOpener: (() => Promise<void>) | null = null;
export function setPipeExtraCountSink(sink: (section: CrossSection, count: number) => void): void {
extraCountSink = sink;
}
export function setPipeCrossOpener(opener: () => Promise<void>): void {
crossOpener = opener;
}
/** 좌측 「추가 흙막이(단)」 → 주인 측점 유출 단 수(B06 횡단 조정과 같은 저장 자리 · 54-27). */
export async function setPipeExtraCount(chainageM: number | null, count: number): Promise<void> {
if (!extraCountSink) await crossOpener?.();
const found = ownerSection(chainageM);
if (found) extraCountSink?.(found.owner, count);
}
/** 유입 형식을 대는 곳 — 횡단 보기의 세션 값 우선(`valueFor`) · 없으면 정본 patch(54-13). */
type InletChoice = NonNullable<CrossSection["design"]>["inlet_structure"];
let inletSource: ((section: CrossSection) => InletChoice) | null = null;
export function setPipeInletSource(source: (section: CrossSection) => InletChoice): void {
inletSource = source;
}
/** 그 관의 주인 측점(관 자리에서 가장 가까운 측점) — 횡단 자료가 없으면 null. */
function ownerSection(
chainageM: number | null,
): { owner: CrossSection; sections: readonly CrossSection[] } | null {
const sections = sectionsSource?.() ?? null;
if (chainageM === null || !sections?.length) return null;
const holders = sections.filter(
(s) => Math.abs((s.culvert?.chainage_m ?? Infinity) - chainageM) < PIPE_MATCH_M,
);
if (!holders.length) return null;
const owner = holders.reduce((a, b) =>
Math.abs(b.chainage_m - chainageM) < Math.abs(a.chainage_m - chainageM) ? b : a,
);
return { owner, sections };
}
/** 관 길이(m) — 주인 측점 횡단 기하 값 · 못 세우면 저장된 `pipe_length_m` · 그것도 없으면 null. */
export function pipeLengthM(chainageM: number | null): number | null {
const found = ownerSection(chainageM);
if (!found) return null;
const { owner, sections } = found;
const drawn = computeStoredLayouts(owner, sections)?.culvert?.pipe?.lengthM;
const length = typeof drawn === "number" && drawn > 0 ? drawn : owner.design?.pipe_length_m;
return typeof length === "number" && length > 0 ? length : null;
}
/** 흙막이 개수 = 주인 측점 유출 「추가 기슭막이(단)」 중 지형이 세운 단(54-10) — 횡단 자료가 없으면
* null(모름). 저장 단 수가 더 커도 넘친 단은 컨테이너를 안 세움(값은 파일에 그대로). */
export function pipeExtraCount(chainageM: number | null): number | null {
const found = ownerSection(chainageM);
if (!found) return null;
const { owner, sections } = found;
const outlet = extraCountSource?.(owner) ?? owner.design?.extra_wall_counts?.outlet ?? 0;
if (!outlet || !owner.design) return outlet;
const counts = { basin: 0, ...owner.design.extra_wall_counts, outlet };
const probe = { ...owner, design: { ...owner.design, extra_wall_counts: counts } };
return computeStoredLayouts(probe, sections)?.culvert?.extraWalls.length ?? outlet;
}
/** 그림이 쓰는 유입 · 유출 값(54-13) — 집수정 모양(없으면 null = 흙막이 벽) · 벽 형태(유입 · 유출 ·
* 흙막이 n). 폼 빈 · 자동 칸에 보여 주기만. 횡단 자료가 없으면 null(모름). */
export function pipeDrawn(chainageM: number | null): {
basin: string | null;
forms: Record<string, string | null>;
extras: Array<string | null>;
} | null {
const found = ownerSection(chainageM);
const design = found?.owner.design;
if (!found || !design) return null;
const { owner, sections } = found;
const outlet = extraCountSource?.(owner) ?? design.extra_wall_counts?.outlet ?? 0;
const counts = { basin: 0, ...design.extra_wall_counts, outlet };
const inlet = inletSource?.(owner) ?? design.inlet_structure;
const probe = {
...owner,
design: { ...design, extra_wall_counts: counts, inlet_structure: inlet },
};
const layout = computeStoredLayouts(probe, sections)?.culvert;
if (!layout) return null;
const formOf = (role: string) => layout.walls.find((w) => w.role === role)?.form ?? null;
return {
basin: layout.basin?.shape ?? null,
forms: { inlet: formOf("inlet"), outlet: formOf("outlet") },
extras: layout.extraWalls.map((w) => w.form),
};
}
/** 관 보호공 [연동] · [경사](54-30) — null = 그 쪽을 쓸 수 없음(벽이 서는 옆 측점 없음 · 구간 없음). */
export interface PipeRevetChoice {
linked: boolean | null;
grade: boolean | null;
}
/** 읽고 쓰는 곳 — 횡단 보기의 연동 제어(`revetLink` · 옛 저장 자리)가 걸어 둠. */
interface RevetChoiceBridge {
read: (owner: CrossSection, sections: readonly CrossSection[]) => PipeRevetChoice;
write: (
owner: CrossSection,
sections: readonly CrossSection[],
kind: "link" | "grade",
on: boolean,
) => void;
}
let revetChoice: RevetChoiceBridge | null = null;
export function setPipeRevetChoiceBridge(bridge: RevetChoiceBridge): void {
revetChoice = bridge;
}
/** 그 관의 [연동] · [경사] 지금 값 — 횡단 자료가 없으면 null(모름). */
export function pipeRevetChoice(chainageM: number | null): PipeRevetChoice | null {
const found = ownerSection(chainageM);
return found && revetChoice ? revetChoice.read(found.owner, found.sections) : null;
}
/** 좌측 [연동] · [경사] → 횡단 연동 제어(종단 보기는 횡단 보기를 숨긴 채 세워 씀 · 54-27 과 같은 길). */
export async function setPipeRevetChoice(
chainageM: number | null,
kind: "link" | "grade",
on: boolean,
): Promise<void> {
if (!revetChoice) await crossOpener?.();
const found = ownerSection(chainageM);
if (found) revetChoice?.write(found.owner, found.sections, kind, on);
}
@@ -0,0 +1,63 @@
/* =============================================================================
* design_structure_road.ts
* 노면공 › 콘크리트 포장 명세 — 사용자 구조물 표 08(`docs/raw/구조물정의_표/08_사토장_토취장_노면공_기타.md`).
*
* 기준 측점(패널 위치 칸) + 필수 컨테이너 「상세 내용」 한 벌 = 포장사양 고르기 · 높이(m) 손 입력.
* 구간 길이 · 전 · 후는 정의 옵션 칸 그대로(구간 배치) · 표에 없는 옛 상세 칸은 화면에서 빼고 값은 남김.
* 저장 = structures.json `options` — 새 키 `pave_spec` · `height_m`.
* 기타(52-14) = 기준 측점 + 상세 종류 이름(정의 옵션 칸 `name`) + 선택 컨테이너 「상세 내용」(비고 글) ·
* 저장 키 `etc_detail_{n}_note` · 잇기 `getcdetail{n}`.
* import 없음 — 시험이 이 파일만 옮겨 돌림.
* ========================================================================== */
import type { SpecChoice, StructureSpec } from "./design_structure_spec";
/** 포장사양 선택지 — 표의 나머지 값은 사용자 답 뒤 여기에만 더함. */
export const PAVE_SPEC_CHOICES: SpecChoice[] = [{ value: "콘크리트", label: "콘크리트" }];
export const PAVEMENT_SPEC: StructureSpec = {
typeId: "pavement_concrete",
containers: [
{
id: "detail",
title: "상세 내용",
required: true,
link: "gpavedetail",
items: [
{
id: "spec",
label: "포장사양",
kind: "select",
key: "pave_spec",
choices: PAVE_SPEC_CHOICES,
},
{ id: "height", label: "높이 (m)", kind: "number", key: "height_m", step: 0.05 },
],
},
],
// 표 08 에 없는 옛 상세 칸 — 화면에서 빼고 값은 남김(지난 정의 값)
retired: [
"thickness_cm",
"width_m",
"widening_area_m2",
"joint_spacing_m",
"separation_sheet",
"wire_mesh",
],
};
export const ETC_SPEC: StructureSpec = {
typeId: "etc",
containers: [
{
id: "detail",
title: "상세 내용",
required: false,
prefix: "etc_detail",
link: "getcdetail",
max: 1,
items: [{ id: "note", label: "비고", kind: "text" }],
},
],
retired: [],
};
+252
View File
@@ -0,0 +1,252 @@
/* =============================================================================
* design_structure_spec.ts
* 구조물 명세 공용 틀(PLAN 52) — 화면 요소 없는 순수 규칙. 사용자 구조물 표 한 장 = 명세 한 벌.
*
* · 종류 = 기본 옵션(기준 측점 No + 거리 · 패널 위치 칸이 받음) + 컨테이너[] + 항목[]
* · 컨테이너 = 제목 · 필수(늘 한 벌) / 선택([추가] · [빼기] · 여러 개 · `max` 면 그 수까지)
* · 항목 꼴 = 고르기 · 숫자 · 글(손 입력 · 길이 상한 `TEXT_MAX`) · 자동(계산이 채움 · 저장 안 함) ·
* 맞물림(길이 = 전 + 후)
* · 상위 값에 따른 선택지 · 저장 키 = `by`(같은 컨테이너 안 상위 항목 값 → 갈래)
* · 저장 = 정본 자리 옵션 그대로(관이면 pipe_points.json `options`) — 필수 컨테이너는 항목 `key` ·
* 선택 컨테이너는 인스턴스마다 `{prefix}_{n}_{항목}`(n 은 1부터)
* · 구조물 조합 잇기(`group_items`) 키 = 필수는 `link`(정의 그룹 id) · 선택은 `{link}{n}`
* · 이름 = 정의 `종류.{종류}.이름` 이 있으면 그것(M02 바꿈) · 그룹 이름 · 없으면 명세 글
* import 없음 — 시험이 이 파일만 옮겨 돌림.
* ========================================================================== */
export interface SpecChoice {
value: string;
label: string;
/** 이 값을 고르면 함께 적는 옵션(하류가 읽는 옛 칸 · 예: 흙막이 = inlet_structure revet). */
also?: Record<string, string>;
}
/** 상위 값 하나에 걸린 갈래 — 저장 키 · 선택지. */
export interface SpecBranch {
key: string;
choices?: SpecChoice[];
}
export type SplitRole = "length" | "before" | "after";
export interface SpecItem {
id: string;
label: string;
kind: "select" | "number" | "text" | "auto";
/** 저장 키(필수 컨테이너 · `by` 없을 때). */
key?: string;
choices?: SpecChoice[];
/** 같은 컨테이너 상위 항목 값 → 갈래. 갈래가 없으면(상위 비었음) 칸을 가림. */
by?: { item: string; map: Record<string, SpecBranch> };
/** 길이 = 전 + 후 맞물림 몫. */
split?: SplitRole;
/** 고르기 값을 수로 저장(관경 등 옛 저장이 수). */
asNumber?: boolean;
step?: number;
/** 기본값 — 선택 컨테이너가 새로 설 때 칸에 실제 값으로 · 빈 칸 안내 「값 (기본)」(54-36). */
default?: string;
/** 빈 칸 안내 — 함수면 지금 값으로 셈. */
hint?: string | ((values: Record<string, string>) => string);
}
export interface SpecContainer {
id: string;
title: string;
required: boolean;
/** 선택 컨테이너 저장 키 머리 — `{prefix}_{n}_{항목}`. */
prefix?: string;
/** 선택 컨테이너 개수 상한 — 차면 [추가] 숨김(옛 저장이 넘쳐도 다 보임). 없으면 여러 개. */
max?: number;
/** 구조물 조합 잇기 키 — 필수는 정의 그룹 id 그대로 · 선택은 뒤에 n. */
link: string;
items: SpecItem[];
}
export interface StructureSpec {
typeId: string;
containers: SpecContainer[];
/** 명세가 화면에서 뺀 옛 키 — 값은 그대로 남고 「지난 정의 값」으로 보임. */
retired: string[];
}
/** 글 항목 길이 상한(자) — 칸 · 저장이 함께 자름. */
export const TEXT_MAX = 100;
/** 컨테이너 인스턴스 한 벌 값 `{항목 id: 글}`. */
export type Instance = Record<string, string>;
export type SpecState = Record<string, Instance[]>;
/** 항목의 지금 갈래 — `by` 없으면 항목 자체. 상위가 비었으면 null(가림 · 저장 안 함). */
export function branchOf(item: SpecItem, values: Instance): SpecBranch | null {
if (!item.by)
return item.key || item.choices ? { key: item.key ?? "", choices: item.choices } : null;
return item.by.map[values[item.by.item] ?? ""] ?? null;
}
const instanceKey = (c: SpecContainer, n: number, item: SpecItem): string =>
`${c.prefix}_${n}_${item.id}`;
/** 항목 저장 키 — 자동 항목 · 갈래 없음 = null. */
export function keyOf(
c: SpecContainer,
item: SpecItem,
n: number,
values: Instance,
): string | null {
if (item.kind === "auto") return null;
if (!c.required) return instanceKey(c, n, item);
return branchOf(item, values)?.key || null;
}
/** 지금 고를 수 있는 값 — 갈래 선택지가 앞섬. */
export function choicesOf(item: SpecItem, values: Instance): SpecChoice[] {
return branchOf(item, values)?.choices ?? item.choices ?? [];
}
/** 인스턴스 잇기 키 — 필수 = 그룹 id · 선택 = `{link}{n}`. */
export const linkOf = (c: SpecContainer, n: number): string =>
c.required ? c.link : `${c.link}${n}`;
const text = (value: unknown): string =>
value === undefined || value === null ? "" : String(value);
/** 옵션 → 컨테이너 값. 필수는 한 벌(상위 항목 먼저 읽어 갈래 키를 앎) · 선택은 저장된 n 차례대로. */
export function readState(
spec: StructureSpec,
options: Record<string, string | number>,
): SpecState {
const state: SpecState = {};
for (const c of spec.containers) {
if (c.required) {
const values: Instance = {};
const plain = c.items.filter((item) => !item.by);
for (const item of [...plain, ...c.items.filter((item) => item.by)]) {
const key = keyOf(c, item, 1, values);
if (key) values[item.id] = text(options[key]);
}
state[c.id] = [values];
continue;
}
const head = new RegExp(`^${c.prefix}_(\\d+)_`);
const ns = [
...new Set(
Object.keys(options)
.map((k) => head.exec(k)?.[1])
.filter((n): n is string => !!n)
.map(Number),
),
].sort((a, b) => a - b);
state[c.id] = ns.map((n) =>
Object.fromEntries(c.items.map((item) => [item.id, text(options[instanceKey(c, n, item)])])),
);
}
return state;
}
/** 컨테이너 값 → 옵션(빈 칸 뺌 · 숫자 칸은 수 · 선택 컨테이너는 차례대로 1 부터 다시 매김 ·
* 다 빈 선택 인스턴스는 첫 칸을 빈 글로 남겨 자리를 지킴 — 잇기 · 집계 줄 · 다시 열기). */
export function writeOptions(
spec: StructureSpec,
state: SpecState,
): Record<string, string | number> {
const out: Record<string, string | number> = {};
for (const c of spec.containers) {
(state[c.id] ?? []).forEach((values, index) => {
const before = Object.keys(out).length;
for (const item of c.items) {
const key = keyOf(c, item, index + 1, values);
const raw = (values[item.id] ?? "").trim();
if (!key || raw === "") continue;
if (item.kind === "number" || item.asNumber) {
const n = Number(raw);
if (Number.isFinite(n)) out[key] = Math.round(n * 100) / 100;
continue;
}
out[key] = item.kind === "text" ? raw.slice(0, TEXT_MAX) : raw;
if (c.required)
Object.assign(out, choicesOf(item, values).find((ch) => ch.value === raw)?.also);
}
const first = c.items.find((item) => item.kind !== "auto");
if (!c.required && first && Object.keys(out).length === before)
out[instanceKey(c, index + 1, first)] = "";
});
}
return out;
}
/** 명세가 다루는 키 전부(필수 갈래 · also 포함) + 선택 컨테이너 머리 — 지난 정의 값 판정 · 저장 병합. */
export function specKeys(spec: StructureSpec): { keys: string[]; prefixes: string[] } {
const keys = new Set<string>();
const prefixes: string[] = [];
for (const c of spec.containers) {
if (!c.required) {
prefixes.push(`${c.prefix}_`);
continue;
}
for (const item of c.items) {
const branches = item.by ? Object.values(item.by.map) : [branchOf(item, {})];
for (const branch of branches) {
if (branch?.key) keys.add(branch.key);
for (const ch of branch?.choices ?? item.choices ?? [])
Object.keys(ch.also ?? {}).forEach((k) => keys.add(k));
}
}
}
return { keys: [...keys], prefixes };
}
/**
* 길이 = 전 + 후 맞물림 — 마지막에 고친 둘을 지키고 나머지 하나를 셈(정함 52).
* `recent` = 고친 차례(최근이 앞) · 둘이 안 차면 길이 → 전 → 후 차례로 채움. 지킬 둘 중 빈 칸이 있으면 안 셈.
*/
export function solveSplit(
values: Partial<Record<SplitRole, string>>,
recent: SplitRole[],
): Partial<Record<SplitRole, string>> {
const keep = [...new Set([...recent, "length", "before", "after"] as SplitRole[])].slice(0, 2);
const num = (role: SplitRole): number | null => {
const raw = (values[role] ?? "").trim();
const n = Number(raw);
return raw !== "" && Number.isFinite(n) ? n : null;
};
const [a, b] = keep.map(num);
if (a === null || b === null) return values;
const free = (["length", "before", "after"] as SplitRole[]).find((r) => !keep.includes(r))!;
const got = { length: num("length"), before: num("before"), after: num("after") };
const result =
free === "length"
? (got.before ?? 0) + (got.after ?? 0)
: Math.max((got.length ?? 0) - (free === "before" ? (got.after ?? 0) : (got.before ?? 0)), 0);
return { ...values, [free]: String(Math.round(result * 100) / 100) };
}
/** 이름 바꿈 표(정의 `종류.{종류}.이름`) — 키 `{컨테이너}` · `{컨테이너}.{항목}` · `{컨테이너}.{항목}={값}`. */
export type SpecNames = Record<string, string>;
export const containerTitle = (c: SpecContainer, names: SpecNames, groupName?: string): string =>
names[c.id] ?? groupName ?? c.title;
export const itemLabel = (c: SpecContainer, item: SpecItem, names: SpecNames): string =>
names[`${c.id}.${item.id}`] ?? item.label;
export const choiceLabel = (
c: SpecContainer,
item: SpecItem,
ch: SpecChoice,
names: SpecNames,
): string => names[`${c.id}.${item.id}=${ch.value}`] ?? ch.label;
/** 명세의 이름 키 전부(정의 파일에 올릴 표) — `{키: 명세 글}`. */
export function nameTable(spec: StructureSpec): SpecNames {
const out: SpecNames = {};
for (const c of spec.containers) {
if (!c.required) out[c.id] = c.title; // 필수 컨테이너 이름 = 정의 그룹 이름(M02 그룹 표에서 바꿈)
for (const item of c.items) {
out[`${c.id}.${item.id}`] = item.label;
const all = [
...(item.choices ?? []),
...Object.values(item.by?.map ?? {}).flatMap((b) => b.choices ?? []),
];
for (const ch of all) out[`${c.id}.${item.id}=${ch.value}`] = ch.label;
}
}
return out;
}
+89 -3
View File
@@ -41,7 +41,7 @@ import { NO_SELECTION, PIPE_MATCH_M, selectDesign } from "./design_selection";
import { readPendingPipes } from "../../B05_Profile/B05_Profile_Api_Pipes_Draft";
import { applyStructurePick } from "../../B06_Section/B06_Section_UI_Page_Structure_Pick";
import { createSectionView } from "../../B06_Section/B06_Section_UI_Section_View";
import { revetWallSpec } from "../../B06_Section/B06_Section_UI_Cross_Culvert_Const";
import { revetFormOf, revetWallSpec } from "../../B06_Section/B06_Section_UI_Cross_Culvert_Const";
import {
applyPipeOptionsToCache,
replayDraftPipeOptions,
@@ -73,6 +73,15 @@ import {
createStandardSlot,
} from "../../B06_Section/B06_Section_UI_Page_Panel";
import type { DesignPageHost } from "./design_page";
import {
pipeExtraCount,
setPipeExtraCountSink,
setPipeExtraCountSource,
setPipeInletSource,
setPipeRevetChoiceBridge,
setPipeSectionsSource,
} from "./design_structure_pipe_calc";
import { pipeRevetChoiceBridge } from "../../B06_Section/B06_Section_UI_Page_Link_Session";
import {
bindDesignView,
bindPipeOptions,
@@ -94,6 +103,8 @@ export async function mountCrossView(
const projectId = shared.projectId || null;
let currentRouteId: number | null = null;
let sectionDetail: SectionDetailResponse | null = null;
// 배관 명세 관 길이(자동) = 이 횡단 자료의 기하(PLAN 52-1)
setPipeSectionsSource(() => sectionDetail?.cross_sections ?? null);
let stationInterval: number | undefined;
// 표준 횡단면 설정 패널 자리. context 로드 후 config 기본값으로 채운다.
@@ -124,6 +135,7 @@ export async function mountCrossView(
((structures: StructureInstance[], types: StructureType[]) => void) | null = null;
/** 관 목록 초안을 고치면 한 벌 배수유역도가 그 초안으로 다시 선다(잇단 조작은 한 번). */
let pipeReloadTimer = 0;
let wallAdjustTimer = 0;
const structuresPanel = createB06StructuresPanel({
projectId,
shared,
@@ -149,6 +161,7 @@ export async function mountCrossView(
// 조작(조정창 높이)이 있을 때만 — 없으면 그려진 높이는 관경 기준 제안이라 옵션에 안 적음
// (2026-09-14 브레인 판정 ④ 「기본값을 몰래 확정으로 안 바꿈」).
if (adjust?.h == null) return null;
if (role !== "inlet" && role !== "outlet") return adjust.h; // 다단 = 기하가 되받은 적용 높이(54-10)
return revetWallSpec(spec, adjust, culvert.hidden_pipe === true, culvert.diameter_m)
.pureHeight;
},
@@ -161,6 +174,7 @@ export async function mountCrossView(
const spec = role === "outlet" ? culvert.outlet : culvert.inlet;
const adjust = stationControls.revetOffset.adjustFor(owner, role);
if (!adjust?.m) return null; // 조작한 형태만 — 기본 형태는 제안(판정 ④)
if (role !== "inlet" && role !== "outlet") return revetFormOf(adjust.m); // 다단(54-10)
return revetWallSpec(spec, adjust, culvert.hidden_pipe === true, culvert.diameter_m).form;
},
// 좌·우 이름표 — +offset이 좌측이고 유입 벽은 오르막(계류) 쪽에 선다.
@@ -176,6 +190,8 @@ export async function mountCrossView(
focusChainage: (chainageM) => {
if (!isWallSelecting()) focusStationAt(chainageM);
},
releaseCard: () => releaseCross(),
markStructure: (structureId) => sectionView.selectMark(structureId),
applyPipeOptions: (chainageM, patch) =>
applyPipeOptionsToCache(pipeOptionsContext, chainageM, patch),
});
@@ -199,11 +215,15 @@ export async function mountCrossView(
view: () => sectionView,
});
let structuresRefreshSeq = 0;
/** 구조물(C군 벽)이 바뀌면 횡단 제원이 달라진다 — 초안을 얹고 다시 그린다. */
async function refreshDetailForStructures(): Promise<void> {
if (!projectId || currentRouteId === null) return;
const seq = ++structuresRefreshSeq; // 잇단 조작 — 최신 요청만 그림(54-4)
try {
sectionDetail = await loadSectionDetail(projectId, currentRouteId);
const fresh = await loadSectionDetail(projectId, currentRouteId);
if (seq !== structuresRefreshSeq) return;
sectionDetail = fresh;
// 면적을 **먼저** 다시 얹는다 — 유토곡선은 카드보다 앞서 계산되므로, 카드 렌더가
// 고치는 것만으로는 곡선이 옛 면적으로 남는다(2026-09-06 실측).
if (sectionDetail) {
@@ -277,7 +297,26 @@ export async function mountCrossView(
ensureSampledWidth,
projectId: () => projectId,
onSaveError: (message) => showToast(`배수관 구간값 저장 실패 — ${message}`, "error"),
onExtraCount: () => structuresPanel.facility.recount(),
// 흙막이 자리를 옮기면 관 길이가 바뀜 — 좌측 「관 길이 (m)」 다시(54-28) · 끌기 · 되받기는 한 번으로 모음
onWallAdjust: () => {
window.clearTimeout(wallAdjustTimer);
wallAdjustTimer = window.setTimeout(() => structuresPanel.facility.recount(), 120);
},
});
// 배관 흙막이 개수 = 유출 단 수(54-1) — 세션 값 우선
setPipeExtraCountSource((section) => stationControls.extraWalls.countFor(section, "outlet"));
// 좌측 「추가 흙막이(단)」도 같은 단 수 제어로(54-27) — 사라지는 단을 고른 중이면 유출 벽으로 옮김
setPipeExtraCountSink((owner, count) => {
const picked = stationControls.revetOffset.highlightFor(owner) ?? "";
if (/^extra\d+$/.test(picked) && Number(picked.slice(5)) >= count)
stationControls.revetOffset.select(owner.chainage_m, "outlet");
stationControls.extraWalls.setCount(owner.chainage_m, count, "outlet");
});
// 폼이 보이는 유입 그림 값(54-13) — 세션 형식 우선
setPipeInletSource((section) => stationControls.inletStructure.valueFor(section));
// 좌측 관 보호공 [연동] · [경사] = 옛 연동 제어 그대로(54-30)
setPipeRevetChoiceBridge(pipeRevetChoiceBridge(stationControls.revetLink));
const sectionView = createSectionView(
(chainageM, change) => {
@@ -313,6 +352,7 @@ export async function mountCrossView(
moveStructure: (structureId, toChainageM) => {
structuresPanel.moveStructureTo(structureId, toChainageM);
},
selectStructure: (structureId) => structuresPanel.selectStructure(structureId),
});
// 폼 → 횡단 캐시 반영은 따로 뗀 모듈이 맡는다(2026-09-02 분리).
const pipeOptionsContext: PipeOptionsContext = {
@@ -320,6 +360,8 @@ export async function mountCrossView(
ford: stationControls.ford,
box: stationControls.box,
revetOffset: stationControls.revetOffset,
structureSpan: stationControls.structureSpan,
soilTiers: pipeExtraCount,
overrideOptions: (chainageM, values) => structuresPanel.overrideOptions(chainageM, values),
refreshCard: (chainageM) => sectionView.refreshCard(chainageM),
};
@@ -334,6 +376,9 @@ export async function mountCrossView(
partKey: key,
from: "b06",
}),
(chainageM) => sectionView.refreshCard(chainageM),
// 지금 보기의 목록 고름 길 — 횡단 = 측점 카드 · 종단 = 측점선 · 알약(54-47)
(chainageM) => shared.bindings[shared.view()]?.structures?.onPipeSelect?.(chainageM),
);
// 횡단도(카드) 자체를 골라도 그 측점 구조물 정보를 폼에 올린다(2026-08-29 사용자).
// 연동으로 옆에서 넘어온 카드는 **소유 측점** 시설을 보여 준다.
@@ -350,6 +395,11 @@ export async function mountCrossView(
const opened = structuresPanel.showAtChainage(owner?.chainage_m ?? target.chainage_m);
// 카드만 고른 것도 남긴다 — 종단 보기로 가면 그 시설이 그대로 열린다.
if (!isWallSelecting()) selectDesign(projectId, opened, { from: "b06" });
// 카드 고름은 그 카드 측점선으로 알약을 맞춤 — 일반 측점 구조물 · 옆 측점 이음 카드면
// 알약이 꺼지므로 연 것으로 다시 세움(관 알약 id = pipe-측점 · 53-1)
const pipeAt = structuresPanel.currentChainage();
const mark = opened.structureId ?? (pipeAt === null ? null : `pipe-${pipeAt.toFixed(2)}`);
if (mark) sectionView.selectMark(mark);
structureSelection.syncInletStructure();
// 카드만 고른 경우엔 구조물(벽·구체) 선택을 비운다 — 조정창이 저절로 뜨면 안 된다
// (2026-08-29 사용자). 벽을 찍어 카드가 딸려 선택된 경우는 건드리지 않는다.
@@ -423,7 +473,16 @@ export async function mountCrossView(
handoff,
sectionDetail,
{
focusStation: (stationId) => sectionView.focusStation(stationId),
// 넘겨받은 구조물 id 가 그 측점 관보다 먼저다(52-15).
focusStation: (stationId) => {
structuresPanel.prefer(handoff?.structureId ?? null);
sectionView.focusStation(stationId);
structuresPanel.prefer(null);
// 그 카드가 이미 골라져 있으면 카드 고름이 안 돌아 폼이 옛 것으로 남음 — id 로 직접 엶(53-1)
const sid = handoff?.structureId;
if (sid && structuresPanel.getStructures().some((entry) => entry.structure_id === sid))
structuresPanel.selectStructure(sid);
},
refreshCard: (chainageM) => sectionView.refreshCard(chainageM),
revetSelect: (chainageM, key) => stationControls.revetOffset.select(chainageM, key),
fordSelect: (chainageM, role) => stationControls.ford.select(chainageM, role),
@@ -434,6 +493,27 @@ export async function mountCrossView(
if (applied) appliedPick = signature;
}
/** 고름을 다 풂(54-38) — 카드 · 벽 · 세월교 · BOX 강조 · 넘김 되얹기 표시 · 선택 칸. */
function releaseCross(): void {
const { revetOffset, ford, box } = stationControls;
const lit = (sectionDetail?.cross_sections ?? []).filter(
(s) =>
revetOffset.highlightFor(s) ||
ford.selectedFor(s.chainage_m) ||
box.selectedFor(s.chainage_m),
);
for (const s of lit) {
if (revetOffset.selectedFor(s)) revetOffset.select(s.chainage_m, null);
if (ford.selectedFor(s.chainage_m)) ford.select(s.chainage_m, null);
if (box.selectedFor(s.chainage_m)) box.select(s.chainage_m, null);
}
structuresPanel.releasePipe();
sectionView.focusStation(null);
sectionView.refreshCards(lit.map((s) => s.chainage_m));
appliedPick = null;
selectDesign(projectId, NO_SELECTION, { from: "b06" });
}
function renderSectionDetail(): void {
if (!sectionDetail) return;
showSectionView();
@@ -482,11 +562,16 @@ export async function mountCrossView(
// 계획고를 가게에서 다시 읽어 폼 · 카드 · 종단도를 그린다. 떠나면 카드 칸 관찰을 뗀다.
host.onShow(() => {
if (currentRouteId === null) return;
// 떠난 사이 종단 보기가 폼을 다른 것으로 바꿨을 수 있음 — 같은 넘김값도 다시 적용(53-1)
appliedPick = null;
// 종단 보기에서 고름을 풀었으면 횡단 강조도 풂(54-38)
if (!readStructurePick(projectId)) releaseCross();
void structuresPanel.load().then(restoreStructurePick);
void refreshDetailForStructures().then(() => reconcileStaleDesigns());
});
host.onDispose(() => {
window.clearTimeout(pipeReloadTimer);
window.clearTimeout(wallAdjustTimer);
sectionView.dispose();
});
@@ -539,6 +624,7 @@ export async function mountCrossView(
}
// 공유 캐시 — 종단 보기가 이미 받아 뒀으면 같은 객체를 즉시 재사용한다.
sectionDetail = await loadSectionDetail(projectId, context.route_id);
structuresPanel.facility.recount(); // 단 수는 횡단 자료로 셈 — 흙막이 상자 · 목록 램프 다시(54-15)
// 구조물 초안(저장 안 한 벽)은 저장소가 이미 얹어 준다. 면적만 여기서 다시 얹으면
// 첫 화면의 카드·유토곡선이 초안 기준으로 선다(2026-09-06 실측).
if (sectionDetail) {
+19 -5
View File
@@ -31,7 +31,7 @@ import {
restoreStructurePick,
wireStructurePick,
} from "../../B05_Profile/B05_Profile_UI_Structure_Pick_Session";
import { NO_SELECTION, nearestWithin, selectDesign } from "./design_selection";
import { NO_SELECTION, PIPE_MATCH_M, nearestWithin, selectDesign } from "./design_selection";
import type { DesignPageHost } from "./design_page";
import {
bindDesignView,
@@ -65,11 +65,11 @@ import {
} from "../../B05_Profile/B05_Profile_UI_Corridor";
import {
profileSaveParts,
solveRouteAction,
type PageActionContext,
} from "../../B05_Profile/B05_Profile_UI_Page_Actions";
import { createLatestSource, panelValuesOf } from "../../B05_Profile/B05_Profile_UI_Page_Latest";
import { stationLinesOf } from "../../B05_Profile/B05_Profile_UI_Page_Stations";
import { setPipeCrossOpener, setPipeSectionsSource } from "./design_structure_pipe_calc";
import type { RouteProfilePanelCallbacks } from "../../B05_Profile/B05_Profile_UI_Profile_Panel_Types";
import "../../B05_Profile/B05_Profile_UI_Style.css";
// 700줄 제한으로 잘라낸 조각 — 본체 **다음에** 불러야 캐스케이드 순서가 같다(2026-09-04).
@@ -123,6 +123,15 @@ export async function mountProfileView(
profilePanel.setMinCoverPipes(pipes);
restorePick(); // 관 목록이 실린 뒤라야 폼이 그 시설을 찾는다.
};
/** 측점선 강조 — 측점선이 없는 관 시설(물넘이포장 · 비정규 측점 아님)은 알약을 id 로 켬(53-2). */
const selectGraphAt = (id: string | null, chainageM: number | null): void => {
const bare =
id === null && chainageM !== null
? lastPipes?.find((pipe) => Math.abs(pipe.chainage_m - chainageM) < PIPE_MATCH_M)
: undefined;
if (bare) profilePanel.setSelectedStructure(`pipe-${bare.chainage_m.toFixed(2)}`);
else profilePanel.setSelectedStation(id);
};
// 종단도 한 벌 — 종단 보기가 보일 때 받는 알림만 건다(계획서 24-3b).
const profilePanel = createRouteProfilePanel(
shared,
@@ -185,6 +194,10 @@ export async function mountProfileView(
let latest: RouteLatestResponse | null = null;
let roadWidths = DEFAULT_ROAD_WIDTHS;
let currentSectionDetail: SectionDetailResponse | null = null;
// 배관 관 길이 · 흙막이 개수(54-1) — 종단 보기도 같은 횡단 자료로(B05 = B06)
setPipeSectionsSource(() => currentSectionDetail?.cross_sections ?? null);
// 좌측 단 수를 바꾸면 횡단 보기를 숨긴 채 세워 같은 단 수 제어로 씀(54-27)
setPipeCrossOpener(() => shared.ensureView("cross"));
/** [예상형상] 표시 상태 — 측점 바를 계획고 위로 올릴지 판단한다(패널 기본 ON). */
let corridorVisible = true;
let routeReady = false;
@@ -205,7 +218,7 @@ export async function mountProfileView(
selectionSyncing = value;
},
selectMarker: (id) => viewer.markers.selectStation(id),
selectGraph: (id) => profilePanel.setSelectedStation(id),
selectGraph: (id, chainageM) => selectGraphAt(id, chainageM ?? null),
selectSidebar: (chainageM) => panel.structures.selectPipeByChainage(chainageM),
selectBasin: (chainageM) => profilePanel.drainage.selectBasinByChainage(chainageM),
selectPipeForm: (chainageM) => profilePanel.drainage.selectPipeAtChainage(chainageM),
@@ -226,7 +239,6 @@ export async function mountProfileView(
const panel = createRoutePanel(
{
onSolve: () => void solveRouteAction(actionContext),
// 계획노선 편집 — 모달 [확인]에서 서버가 배수유역부터 다시 계산하므로, 끝나면
// 옛 노선 기준 캐시를 버리고 페이지를 새로 세운다([초기화]와 같은 뒷정리).
onEditPlannedRoute: () =>
@@ -299,10 +311,11 @@ export async function mountProfileView(
: nearestWithin(bridge.irregularStations(), chainage, (entry) => entry.chainage_m);
const id = station ? irregularStationId(station.id) : null;
viewer.markers.selectStation(id);
profilePanel.setSelectedStation(id);
selectGraphAt(id, chainage);
syncBasinHighlight(id);
// 배수유역 마커 선택 + 부속 옵션 폼도 연다(2026-08-17 전역 선택 동기화).
profilePanel.drainage.selectPipeAtChainage(chainage);
viewer.structurePick.selectAtChainage(chainage); // 3D 도 따라옴(53-2)
} finally {
selectionSyncing = false;
}
@@ -315,6 +328,7 @@ export async function mountProfileView(
selectionSyncing = true;
try {
profilePanel.setSelectedStructure(structure?.structure_id ?? null);
viewer.structurePick.selectAtChainage(structure ? structureAnchorM(structure) : null);
} finally {
selectionSyncing = false;
}
@@ -195,3 +195,72 @@
transform: translate(-100%, 0);
pointer-events: none;
}
/* 칸을 골랐을 때 그 칸의 알약 — 굵은 테두리 + 바깥 고리(칸이 바뀐 첫 그림만 한 번 반짝) */
.ss-link.is-here {
outline: 2px solid var(--color-accent);
outline-offset: 2px;
font-weight: 600;
}
.ss-link.is-pop {
animation: ss-link-pop 1.2s ease-out 1 both;
}
@keyframes ss-link-pop {
0%,
40%,
80% {
box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-accent) 55%, transparent);
}
20%,
60%,
100% {
box-shadow: 0 0 0 0 transparent;
}
}
/* 일위대가에 없는 알약 — ⚠ + 점선 붉은 테두리 + [×] */
.ss-link.is-orphan {
border: 1px dashed var(--color-danger);
color: var(--color-danger);
}
.ss-link__x {
margin-left: 2px;
padding: 0 4px;
border-radius: 50%;
font-weight: 700;
cursor: pointer;
}
.ss-link__x:hover {
background: color-mix(in srgb, var(--color-danger) 20%, transparent);
}
.ss-link-cell.is-orphan {
outline: 1px dashed var(--color-danger);
outline-offset: -2px;
}
/* 보낸 범위(도면 표) — 점선 테두리(채움 없음) + 왼위 이름표 */
.ss-link-range {
position: absolute;
z-index: 3;
box-sizing: border-box;
border: 2px dashed var(--color-accent);
pointer-events: none;
}
.ss-link-range__tag {
position: absolute;
left: -2px;
bottom: 100%;
padding: 0 4px;
border-radius: 3px 3px 0 0;
background: var(--color-accent);
color: var(--color-canvas);
font-size: 10px;
line-height: 14px;
white-space: nowrap;
}
+69 -7
View File
@@ -15,7 +15,7 @@
import "./spreadsheet_links.css";
import { createMapContextMenu } from "@ui/ui_template_context_menu";
import { el, showToast } from "@ui/ui_template_elements";
import { parseA1, quoteSheet, toA1 } from "./spreadsheet_address";
import { inRange, parseA1, parseRange, quoteSheet, toA1 } from "./spreadsheet_address";
import { applyCommand } from "./spreadsheet_commands";
import { askShare } from "./spreadsheet_link_ask";
import { linkHues } from "./spreadsheet_link_color";
@@ -53,6 +53,11 @@ export interface LinkOptions {
onItemsChange?: (항목: LinkItem[]) => void;
/** 자재DB 찾기(빈 글 = 처음 목록) — 자재 모드만 */
자재찾기?: (글: string) => Promise<LinkMaterial[]>;
/** 입력 모드 — 호스트가 항목 목록을 믿을 수 있게 받았음(받기 실패 · 빈 목록 구분) · true 일 때만
* 목록에 없는 연결 알약에 ⚠ + [×] */
확정?: boolean;
/** 다른 곳으로 보낸 칸 범위 표시(예: 도면 표) — 시트 id · 범위 · 이름표 · 마우스 올림 글 */
표시범위?: { 시트: string; 범위: string; 이름: string; 설명?: string }[];
}
export interface Links extends PartHandle {
@@ -74,6 +79,8 @@ const TEXT = {
fail: "자재 목록을 못 받음",
picked: "칸을 고른 뒤 새 알약을 누르면 연결",
dup: "이미 목록에 있는 자재",
orphan: "일위대가에 없는 알약 — 연결을 풀면 [저장] 때 남음",
orphanX: "연결 풀기",
};
type RowCol = Extract<Command, { 종류: "행넣기" | "행지우기" | "열넣기" | "열지우기" }>;
@@ -146,6 +153,8 @@ export function mountLinks(
let dragging: LinkItem | null = null;
const dropMark = el("div", { className: "ss-link-drop" });
let pick: HTMLElement | null = null;
/** 마지막으로 강조를 판정한 칸(시트 id!칸) — 바뀔 때만 반짝 · 스크롤 */
let lastAt = "";
/** 키 → 연결(시트 · 줄) */
function found(): Map<string, { sheet: Sheet; link: CellLink }> {
@@ -204,6 +213,8 @@ export function mountLinks(
item: LinkItem,
hit: { sheet: Sheet; link: CellLink } | undefined,
hue: number | undefined,
orphan: boolean,
here: string,
) {
const where = hit
? hit.sheet.id === ctx.selection.시트
@@ -211,15 +222,30 @@ export function mountLinks(
: `${quoteSheet(hit.sheet.이름)}!${hit.link.칸}`
: "";
const b = el("button", {
className: hit ? "ss-link is-linked" : "ss-link",
attrs: { type: "button", title: hit ? TEXT.linked : TEXT.free, "data-key": item.키 },
className: `ss-link${hit ? " is-linked" : ""}${orphan ? " is-orphan" : ""}${
here ? ` is-here${here === "new" ? " is-pop" : ""}` : ""
}`,
attrs: {
type: "button",
title: orphan ? TEXT.orphan : hit ? TEXT.linked : TEXT.free,
"data-key": item.키,
},
children: [
el("span", { text: item.이름 }),
el("span", { text: orphan ? `⚠ ${item.이름}` : item.이름 }),
...(item.단위 ? [el("small", { text: item.단위 })] : []),
...(where ? [el("code", { text: where })] : []),
],
});
if (hue !== undefined) b.style.setProperty("--ss-link-h", String(hue));
if (orphan && !ctx.readOnly) {
const x = el("span", {
className: "ss-link__x",
text: "×",
attrs: { role: "button", title: TEXT.orphanX },
});
x.addEventListener("click", (e) => (e.stopPropagation(), unlink(), back()));
b.append(x);
}
b.draggable = !ctx.readOnly;
b.addEventListener("dragstart", (e) => {
dragging = item;
@@ -233,13 +259,13 @@ export function mountLinks(
// 초점은 격자에 둠 — 끌 수 있는 알약은 막으면 끌기가 안 돼 그대로(누른 뒤 `back` 이 격자로 돌림)
if (!b.draggable) b.addEventListener("mousedown", (e) => e.preventDefault());
b.addEventListener("click", () => (hit ? goTo(hit.sheet, hit.link.칸) : void link(item)));
const unlink = (): void => {
function unlink(): void {
if (hit)
put(
hit.sheet,
(hit.sheet.연결 ?? []).filter((l) => l.키 !== item.키),
);
};
}
b.addEventListener("contextmenu", (e) => {
e.preventDefault();
const inList = opts?.모드 === "자재" && !item.고정 && items.some((i) => i.키 === item.키);
@@ -307,7 +333,17 @@ export function mountLinks(
: { 키: link.키, 이름: link.이름 ?? link.키, 단위: link.단위 },
);
const hues = linkHues(map.keys());
const pills = shown.map((item) => pill(item, map.get(item.키), hues.get(item.키)));
const listed = new Set(items.map((i) => i.키));
const sure = opts.모드 === "입력" && opts.확정 === true;
// 칸을 고르면 그 칸에 이은 알약 강조 — 칸이 바뀐 첫 그림만 한 번 반짝("new")
const at = `${ctx.selection.시트}!${toA1(ctx.selection.활성.r, ctx.selection.활성.c)}`;
const fresh = at !== lastAt;
lastAt = at;
const pills = shown.map((item) => {
const hit = map.get(item.키);
const here = hit && `${hit.sheet.id}!${hit.link.칸}` === at ? (fresh ? "new" : "same") : "";
return pill(item, hit, hues.get(item.키), sure && !!hit && !listed.has(item.키), here);
});
if (opts.모드 === "자재" && opts.자재찾기 && !ctx.readOnly) {
const more = el("button", {
className: "ss-link ss-link--add",
@@ -318,6 +354,8 @@ export function mountLinks(
pills.push(more);
}
bar.replaceChildren(...pills);
if (fresh)
bar.querySelector(".is-here")?.scrollIntoView?.({ block: "nearest", inline: "nearest" });
}
/** 이은 칸 — 알약 색 옅은 배경 + 왼아래 작은 세모 · 칸이 든 판 층에 얹어 스크롤을 따라감 */
@@ -325,6 +363,8 @@ export function mountLinks(
for (const d of dots) d.remove();
dots = [];
const hues = linkHues(found().keys());
const listed = new Set(items.map((i) => i.키));
const sure = opts?.모드 === "입력" && opts.확정 === true;
// 칸마다 이은 알약(이은 차례) — 색 = 먼저 이은 알약 · 둘 넘으면 수
const byCell = new Map<string, CellLink[]>();
for (const l of ctx.sheet().연결 ?? []) byCell.set(l.칸, [...(byCell.get(l.칸) ?? []), l]);
@@ -340,6 +380,7 @@ export function mountLinks(
dot.style.left = `${box.x}px`;
dot.style.top = `${box.y + box.h - 7}px`;
const marks = [tint, dot];
if (sure && !listed.has(first.키)) tint.classList.add("is-orphan");
if (list.length > 1) {
const count = el("div", { className: "ss-link-count", text: String(list.length) });
count.style.left = `${box.x + box.w}px`;
@@ -350,6 +391,22 @@ export function mountLinks(
layer.append(...marks);
dots.push(...marks);
}
// 보낸 범위(도면 표 등) — 채움 없는 점선 테두리 + 왼위 이름표(알약 색 채움과 안 겹침)
for (const mark of opts?.표시범위 ?? []) {
const g = mark.시트 === ctx.sheet().id ? parseRange(mark.범위) : null;
if (!g) continue;
const { layer, box } = slot(ctx, g.r0, g.c0);
const end = slot(ctx, g.r1, g.c1).box;
if (!box.w || !box.h) continue;
const frame = el("div", {
className: "ss-link-range",
attrs: { "data-range": mark.범위 },
children: [el("span", { className: "ss-link-range__tag", text: mark.이름 })],
});
frame.style.cssText = `left:${box.x}px;top:${box.y}px;width:${Math.max(box.w, end.x + end.w - box.x)}px;height:${Math.max(box.h, end.y + end.h - box.y)}px`;
layer.append(frame);
dots.push(frame);
}
}
/** 칸에 마우스를 올리면 이은 알약 이름들(격자 title) — 이은 칸이 아니면 지움 */
@@ -360,6 +417,11 @@ export function mountLinks(
const names = a1
? (ctx.sheet().연결 ?? []).filter((l) => l.칸 === a1).map((l) => l.이름 ?? l.키)
: [];
if (hit && hit.r >= 0 && hit.c >= 0)
for (const m of opts?.표시범위 ?? []) {
const g = m.시트 === ctx.sheet().id ? parseRange(m.범위) : null;
if (g && inRange(g, hit.r, hit.c)) names.push(m.설명 ?? m.이름);
}
if (names.length) ctx.grid.root.title = names.join(" · ");
else if (tipped) ctx.grid.root.removeAttribute("title");
tipped = names.length > 0;
+15 -1
View File
@@ -3,6 +3,7 @@
from __future__ import annotations
import json
import re
import shutil
from datetime import datetime, timedelta
from typing import Any
@@ -547,10 +548,23 @@ async def get_user_ui_prefs(user_id: int) -> dict[str, Any]:
return raw if isinstance(raw, dict) else {}
_UUID_IN_KEY = re.compile(r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}")
async def save_user_ui_prefs(user_id: int, prefs: dict[str, Any]) -> None:
"""화면 취향을 통째로 덮어쓴다 — 사용자당 한 줄."""
"""화면 취향을 통째로 덮어쓴다 — 사용자당 한 줄.
지워진 프로젝트 id 가 박힌 키는 버림 — 브라우저 사본이 옛 키를 다시 올리지 못하게.
"""
pool = get_db_pool()
async with pool.acquire() as connection, connection.cursor() as cursor:
keyed = {key: m.group(0) for key in prefs if (m := _UUID_IN_KEY.search(key))}
if keyed:
ids = sorted(set(keyed.values()))
holders = ", ".join(["%s"] * len(ids))
await cursor.execute(f"SELECT id FROM projects WHERE id IN ({holders})", ids)
live = {row[0] for row in await cursor.fetchall()}
prefs = {k: v for k, v in prefs.items() if k not in keyed or keyed[k] in live}
await cursor.execute(
"""INSERT INTO user_ui_prefs (user_id, prefs) VALUES (%s, %s)
ON DUPLICATE KEY UPDATE prefs = VALUES(prefs)""",
+3 -1
View File
@@ -20,6 +20,7 @@ import {
showToast,
} from "@ui/ui_template_elements";
import { createGeneralLayout } from "@ui/ui_template_general_layout";
import { createHelpButton } from "@ui/ui_template_help";
import { isBlank } from "@util/common_util_validate";
import { fetchCompanyMembers, fetchDashboardMe } from "../B01_Dashboard/B01_Dashboard_Api_Fetch";
import { createNameComposer, type NameParts } from "./B02_ProjRegister_UI_Name";
@@ -299,7 +300,8 @@ export function renderB02ProjRegister(root: HTMLElement): void {
// 제목 크기·여백을 쓰고, 버튼 줄은 `ui-general-block__actions` 로 세운다.
const actions = document.createElement("div");
actions.className = "ui-general-block__actions b02-proj__actions";
actions.append(cancelBtn, submitBtn);
// 좌측 패널이 없어 [?](54-2)는 아래 단추 줄 맨 앞
actions.append(createHelpButton(), cancelBtn, submitBtn);
const card = createCard({ body: [grid, actions], raised: true });
const layout = createGeneralLayout({
pageClass: "b02-proj",
+8 -67
View File
@@ -1,77 +1,18 @@
/* =============================================================================
* B03_FileInput_UI_Guide.ts
* 파일 입력 좌측 안내 패널 (2026-09-03 사용자 지시).
* 파일 입력 좌측 패널 (2026-09-03 사용자 지시).
*
* 종전에는 고르는 방법·필요한 파일 목록이 **선택 영역과 카드 안에** 길게 들어가 있어
* 카드 한 장이 220px씩 차지했다. 안내는 한 번 읽으면 되는 것이라 다른 단계(B04·B05)와
* 같은 자리 — 공용 오버레이의 좌측 패널(`createWorkflowOverlays.optionsContent`) — 로
* 옮기고, 본문은 고르는 자리만 남긴다.
*
* 패널 양식은 **B04~B07과 같은 공용 양식**을 그대로 쓴다(2026-09-03 사용자 지시):
* 패널 루트 `{page}__form`, 문단은 `ui-collapsible ui-sidebar-section` + 제목에
* `ui-collapsible__title`. 제목 행을 누르면 접히는 동작·캐럿·외곽선이 전부 공용 것이다.
* 안내 글(필요한 파일 · 고르는 방법 · 알아 둘 것)은 [?] 설명서 `resources/help/B03/*.md` 로
* 옮김(54-2). 패널에는 현황 배너와 아래 단추 줄([?] 자리)만 남김.
* ========================================================================== */
import { attachCollapsible } from "@ui/ui_template_collapsible";
import { ui_locales, currentLanguageIndex } from "@ui/ui_template_locale";
function L(key: keyof typeof ui_locales): string {
return ui_locales[key][currentLanguageIndex];
}
/** 안내 문단 하나 — 공용 접기 컨테이너(B06 `buildGroup`과 같은 조립). */
function section(
titleKey: keyof typeof ui_locales,
itemKeys: (keyof typeof ui_locales)[],
): HTMLElement {
const group = document.createElement("section");
group.className = "b03-file__guide-group ui-collapsible ui-sidebar-section";
const title = document.createElement("h3");
title.className = "b03-file__guide-legend ui-collapsible__title";
title.textContent = L(titleKey);
const list = document.createElement("ul");
list.className = "b03-file__guide-list";
for (const key of itemKeys) {
const item = document.createElement("li");
item.textContent = L(key);
list.append(item);
}
group.append(title, list);
return group;
}
/**
* 좌측 패널 본문 — 필요한 파일 · 고르는 방법 · 알아 둘 것.
*
* `statusNote`(재접속 현황 배너)는 「고르는 방법」 끝에 붙는다 — 프로젝트가 이미 완료라
* 다시 올리면 교체된다는 안내라서, 고르기 전에 읽을 것들과 같은 자리에 둔다
* (2026-09-03 사용자 지시).
*/
/** 좌측 패널 본문 — `statusNote`(재접속 현황 배너) + 아래 단추 줄(공용 [?] 가 붙음). */
export function createInputGuide(statusNote?: HTMLElement): HTMLElement {
const guide = document.createElement("div");
guide.className = "b03-file__form";
const howTo = section("B03_Guide_How_Title", [
"B03_Guide_How_Drop",
"B03_Guide_How_Card",
"B03_Guide_How_Temp",
]);
if (statusNote) howTo.append(statusNote);
guide.append(
section("B03_Guide_Files_Title", [
"B03_Guide_Files_Route",
"B03_Guide_Files_Terrain",
"B03_Guide_Files_Optional",
]),
howTo,
section("B03_Guide_Notes_Title", [
"B03_Guide_Notes_Replace",
"B03_Guide_Notes_Crs",
"B03_Guide_Notes_LasFree",
]),
);
attachCollapsible(guide);
const actions = document.createElement("div");
actions.className = "ui-sidebar-actions";
if (statusNote) guide.append(statusNote);
guide.append(actions);
return guide;
}
+1 -34
View File
@@ -310,10 +310,7 @@
}
}
/* --- 좌측 안내 패널 (2026-09-03) — 본문에서 뺀 설명이 사는 자리.
양식은 B04~B07 좌측 패널과 **같은 공용 양식**이다: 루트 `__form`, 문단은
`ui-collapsible ui-sidebar-section`(외곽선·접힘·캐럿은 공용 CSS 몫), 제목은
`__group-legend` 크기. 여기서는 값만 맞추고 새로 만들지 않는다. --- */
/* --- 좌측 패널 — 현황 배너 + 아래 단추 줄(안내 글은 [?] 설명서로 옮김 · 54-2) --- */
.b03-file__form {
display: flex;
flex-direction: column;
@@ -321,36 +318,6 @@
padding: var(--spacing-16);
}
.b03-file__guide-group {
display: flex;
flex-direction: column;
gap: var(--spacing-8);
margin: 0;
padding: var(--spacing-16);
border-radius: var(--radius-cards);
background-color: var(--color-surface-raised);
}
.b03-file__guide-legend {
margin: 0;
padding: 0 var(--spacing-8);
font-size: var(--text-caption);
font-weight: var(--font-weight-medium);
color: var(--color-text-secondary);
}
/* 글자 크기·색도 공용 양식 그대로 — B04 좌측 패널 본문(`b04-surface__check`)과 같은
`--text-body-sm` · `--color-text-body`(2026-09-03 사용자 지시: 양식 = 글자 크기 포함). */
.b03-file__guide-list {
margin: 0;
padding-left: var(--spacing-16);
display: flex;
flex-direction: column;
gap: var(--spacing-4);
font-size: var(--text-body-sm);
color: var(--color-text-body);
}
.b03-file__group {
display: flex;
flex-direction: column;
@@ -97,6 +97,9 @@ def _apply_new_defaults(points: list[PipePoint]) -> None:
for field in definition.options:
if field.key not in options and field.default not in (None, ""):
options[field.key] = field.default
# 집수정 모양도 실제 값으로(54-39 · 54-36 기본 L형 — 화면 짝 `DEFAULT_BASIN_SHAPE`)
if options.get("inlet_type") == "집수정":
options.setdefault("inlet_structure", "L")
point.options = options or None
+27 -2
View File
@@ -14,6 +14,13 @@
import { readState, writeState } from "../A00_Common/b_page_state";
import type { GroupItems, SummaryItem } from "../common_util/common_util_summary_item";
import { API_BASE_URL, API_TIMEOUT_MS } from "@config/config_frontend";
import {
type DefinedRule,
type DefinedShape,
type DefinedSpot,
type StructureDefinition,
withDefinition,
} from "./B05_Profile_UI_Structures_Define";
/** 배치형태 — 점형(측점 1개) / 구간형(시~종점) / 부지형(위치+면적). */
export type StructurePlacement = "point" | "interval" | "site";
@@ -27,7 +34,7 @@ export interface StructureOptionField {
default: string | number | null;
/** 미확정 항목(기본값 없음) — 사용자가 값을 넣어야 저장된다. */
required?: boolean;
/** 거짓이면 폼에 **회색으로** 그려지고 못 고른다 — 칸은 남기되 잠그는 자리. */
/** 거짓 = 「안 씀」(48 정의 틀 3장) — 폼에 안 그림 · 옛 값은 그대로 남음. */
enabled?: boolean;
/** 입력 시점 — B05는 유무·종류·위치만 받고 상세 치수(detail)는 B06/B07에서 받는다
* (2026-08-17 사용자 확정). detail이면 required여도 B05 폼에 그리지 않는다. */
@@ -79,6 +86,18 @@ export interface StructureType {
enabled: boolean;
/** 옵션 그룹(M02 PLAN 46) — 폼의 보조 컨테이너(제목 = name) · 안의 옵션 키 · 빈 그룹도 됨. */
groups?: StructureOptionGroup[];
/** 구조물군 이름(48 정의 `구조물군`) — 없으면 화면 기본 이름. */
group_name?: string;
/** 기준 측점 칸 보임(48 정의 `종류.기준측점`) — false 일 때만 가림. */
show_anchor?: boolean;
/** 손코딩 특수 동작 이름(48 정의 `종류.동작`) — 그 동작이 붙은 칸 · 폼을 그대로 살림. */
behaviors?: string[];
/** 옵션 키 → 배치 칸(48 정의 `배치`). */
spots?: Record<string, DefinedSpot> | null;
/** 상위 → 하위 규칙(48 정의 `규칙` 중 이 종류 것). */
rules?: DefinedRule[] | null;
/** 구조물 명세 이름 바꿈(52 정의 `종류.이름` · `{컨테이너}[.{항목}[={값}]]: 이름`). */
spec_names?: Record<string, string>;
}
/** 옵션 그룹 한 개 — 서버가 M02 「구조물 옵션 보이기」 그룹 표로 채움. */
@@ -86,6 +105,8 @@ export interface StructureOptionGroup {
id: string;
name: string;
options: string[];
/** 그룹이 받을 형상 칸(48 정의 그룹 `형상`) — 길이 · 높이 · 전 · 후 받기 켬끔 + 뜻. */
shape?: DefinedShape;
}
export interface StructureInstance {
@@ -181,10 +202,14 @@ let typesCache: Promise<StructureType[]> | null = null;
*/
export function fetchStructureTypes(includeDisabled = false): Promise<StructureType[]> {
if (!typesCache) {
// 구조물 정의(48) 덧칸 — 못 받으면 옛 화면 그대로(정의 없음 = 지금 차례 · 2열)
const definition = requestJson<StructureDefinition>("/m02/structure-definition", {
method: "GET",
}).catch(() => null);
typesCache = requestJson<StructureTypesResponse>("/projects/structure-types", {
method: "GET",
})
.then((payload) => payload.types)
.then(async (payload) => withDefinition(payload.types, await definition))
.catch((error) => {
typesCache = null; // 실패한 약속을 남겨 두면 다시 시도할 수 없다.
throw error;
+54 -11
View File
@@ -8,6 +8,7 @@ longitudinal/, 각 횡단은 cross_sections/ 아래 파일로 저장한다. DB
import json
import logging
import re
from dataclasses import replace
from pathlib import Path
from typing import Any
@@ -33,6 +34,7 @@ from common_util.common_util_drainage_pipes import (
PIPE_FACILITY_REVET,
PipePoint,
load_pipe_points_file,
parse_pipe_points,
pipe_anchor_clearances,
route_signature,
)
@@ -205,6 +207,56 @@ def _load_pipe_points(project_root: Path, polyline: list[list[float]]) -> list[P
return points
def pipe_station_label(pipe: PipePoint, types: dict[str, Any]) -> str | None:
"""관 지점 측점 라벨 — 배관 = 「관종 D관경」 · 그 밖 = 종류 이름 · 물넘이포장 = 없음."""
if pipe.facility == PIPE_FACILITY_FORD_PAVEMENT:
return None
if pipe.facility == PIPE_FACILITY_PIPE:
values = pipe.options or {}
kind = str(values.get("pipe_kind") or PIPE_DEFAULT_TYPE)
diameter = int(float(values.get("pipe_diameter_mm") or PIPE_DEFAULT_DIAMETER_MM))
return f"{kind} D{diameter}"
definition = types.get(pipe.facility)
return definition.name if definition is not None else None
def relabel_pipe_stations(project_root: Path, cross_sections: list[dict[str, Any]]) -> None:
"""횡단 측점 라벨을 **지금 관 지점 종류**로 맞춘다(54-4).
라벨은 측점 생성 때 적혀 파일에 남는다 — 저장으로 종류만 바꾸면(배관 → BOX암거) 측점은
다시 안 만들어져 카드 제목이 옛 종류로 남는다. 관 지점 라벨(종류 이름 · 「관종 D관경」)인
측점만 고치고 다른 구조물 라벨은 건드리지 않는다.
"""
path = (
project_root
/ "B04_PreProcess"
/ DRAINAGE_CACHE_DIRNAME
/ DRAINAGE_EDITS_DIRNAME
/ DRAINAGE_PIPE_POINTS_FILENAME
)
try:
points = parse_pipe_points(json.loads(path.read_text(encoding="utf-8")).get("points"))
except (OSError, ValueError, AttributeError):
return
types = structure_type_map()
pipe_names = {definition.name for definition in types.values() if definition.managed_by}
for section in cross_sections:
label = section.get("structure")
if not isinstance(label, str) or not (
label in pipe_names or re.fullmatch(r"\S+ D\d+", label)
):
continue
chainage = float(section.get("chainage_m") or 0.0)
pipe = next((p for p in points if abs(p.chainage_m - chainage) < 0.02), None)
if pipe is None:
continue
fresh = pipe_station_label(pipe, types)
if fresh is None:
section.pop("structure", None)
else:
section["structure"] = fresh
def resolve_extra_stations(
project_root: Path, pipes: list[PipePoint]
) -> tuple[tuple[float, str], ...]:
@@ -224,18 +276,9 @@ def resolve_extra_stations(
types = structure_type_map()
derived: list[tuple[float, str]] = []
for pipe in pipes:
if pipe.facility == PIPE_FACILITY_FORD_PAVEMENT:
label = pipe_station_label(pipe, types)
if label is None:
continue
if pipe.facility == PIPE_FACILITY_PIPE:
values = pipe.options or {}
kind = str(values.get("pipe_kind") or PIPE_DEFAULT_TYPE)
diameter = int(float(values.get("pipe_diameter_mm") or PIPE_DEFAULT_DIAMETER_MM))
label = f"{kind} D{diameter}"
else:
definition = types.get(pipe.facility)
if definition is None:
continue
label = definition.name
# 독립 기슭막이는 구간(시작~종료)이라 **시작·기준·종료** 세 측점을 심는다 —
# 길수록 횡단도가 여러 장 나온다(구 D군 구간형과 같은 규칙). 나머지 관 시설은
# 기준 한 곳(관이 노선을 가로지르는 점형).
@@ -20,6 +20,7 @@ from B05_Profile.B05_Profile_Engine_Solver import (
_cost_surface_signature,
_load_or_build_cost_surface,
)
from common_util.common_util_surface_sampler import check_surface_keys
from config.config_system import (
SKELETON_MAIN_RIDGE_ACC_THRESHOLD_CELLS,
SKELETON_MAIN_VALLEY_ACC_THRESHOLD_CELLS,
@@ -277,6 +278,7 @@ def load_or_build_skeleton(
project_root: Path, filter_key: str, method: str, smooth: bool
) -> dict[str, Any]:
"""스켈레톤을 캐시에서 로드하거나 새로 계산해 저장한다."""
check_surface_keys(filter_key, method)
project_root = Path(project_root)
models_dir = project_root / _MODELS_SUBDIR
cache_dir = project_root / _ROUTE_CACHE_SUBDIR
+5
View File
@@ -19,6 +19,7 @@ from B05_Profile.B05_Profile_Engine_Geometry import (
resample_polyline_2d,
single_segment_dijkstra,
)
from common_util.common_util_surface_sampler import check_surface_keys
from config.config_system import (
FOREST_ROAD_MAX_GRADE,
FOREST_ROAD_MIN_CURVE_R_M,
@@ -45,6 +46,7 @@ _ROUTE_CACHE_SUBDIR = Path("B05_Profile") / "route"
def _load_dtm_grid(models_dir: Path, filter_key: str, smooth: bool):
"""필터의 정규 DTM 격자(x, y, z, valid_mask)를 로드한다."""
check_surface_keys(filter_key)
suffix = "_smooth" if smooth else ""
dtm_path = models_dir / f"dtm_{filter_key}{suffix}.npz"
if not dtm_path.exists():
@@ -70,6 +72,7 @@ def _sample_surface_on_grid(
dtm_z: np.ndarray,
) -> np.ndarray:
"""확정 지표면 모델의 표고를 DTM 격자에 샘플링한다(실패 시 DTM으로 폴백)."""
check_surface_keys(filter_key, method)
if method == "dtm":
return dtm_z
@@ -145,6 +148,7 @@ def _sample_surface_on_grid(
def _source_npz_paths(models_dir: Path, filter_key: str, method: str, smooth: bool) -> list[Path]:
"""비용면이 의존하는 소스 모델 파일(존재하는 것만, 안정 순서)."""
check_surface_keys(filter_key, method)
suffix = "_smooth" if smooth else ""
candidates = [
models_dir / f"dtm_{filter_key}{suffix}.npz",
@@ -211,6 +215,7 @@ def _load_or_build_cost_surface(
project_root: Path, models_dir: Path, filter_key: str, method: str, smooth: bool
):
"""비용면을 반환한다(서명 일치 시 캐시 재사용, 아니면 재빌드·재캐시)."""
check_surface_keys(filter_key, method)
cache_dir = project_root / _ROUTE_CACHE_SUBDIR
suffix = "_smooth" if smooth else ""
cache_path = cache_dir / f"cost_surface_{filter_key}_{method}{suffix}.npz"
+7 -4
View File
@@ -4,6 +4,7 @@ from typing import Any, Literal
from pydantic import BaseModel, ConfigDict, Field, model_validator
from common_util.common_util_surface_sampler import SurfaceFilter, SurfaceMethod
from config.config_system import (
GRADE_MAIN_DIRECTIONS,
GRADE_TERRAIN_TYPES,
@@ -63,8 +64,10 @@ class RouteSolveRequest(BaseModel):
model_config = ConfigDict(extra="forbid")
filter_key: str = Field(description="지면 필터 키 (grid_min_z/csf/pmf)")
method: str = Field(default="dtm", description="지표면 표현 (dtm/tin/nurbs/implicit/meshfree)")
filter_key: SurfaceFilter = Field(description="지면 필터 키 (grid_min_z/csf/pmf)")
method: SurfaceMethod = Field(
default="dtm", description="지표면 표현 (dtm/tin/nurbs/implicit/meshfree)"
)
smooth: bool = Field(default=False)
surface_model_id: int | None = Field(default=None, description="기반 지표면 모델 id")
algorithm: str = Field(
@@ -269,8 +272,8 @@ class RouteConfirmRequest(BaseModel):
model_config = ConfigDict(extra="forbid")
filter_key: str | None = None
method: str | None = None
filter_key: SurfaceFilter | None = None
method: SurfaceMethod | None = None
smooth: bool = False
surface_model_id: int | None = None
irregular_stations: list[IrregularStationInput] = Field(default_factory=list)
@@ -12,7 +12,11 @@ import os
import uuid
from typing import Any, Iterable
from B05_Profile.B05_Profile_Structures_Schema import StructureInstance, structure_type_map
from B05_Profile.B05_Profile_Structures_Schema import (
StructureInstance,
definition_version,
structure_type_map,
)
from common_util.common_util_json import atomic_write_json
from M02_MasterTemplete.StructOptions.M02_SO_Options import hidden_keys
@@ -125,6 +129,8 @@ def save_structures(
"revision": revision,
"structures": [item.model_dump(mode="json") for item in items],
"migrated_legacy": sorted(history),
# 저장 때 구조물 정의 판(PLAN 48-1) — 뒤에 정의가 바뀌어도 이 값이 어느 정의로 적혔는지 앎
"definition_version": definition_version(),
}
atomic_write_json(structures_file_path(project_root), payload)
return revision
@@ -192,12 +198,15 @@ def _validate_options(item: StructureInstance, definition, hidden: set[str] = fr
for key, value in item.options.items():
option = allowed.get(key)
if option is None:
raise ValueError(f"{definition.name}에 정의되지 않은 옵션입니다: {key}")
# 지금 정의에 없는 키 = 지난 정의 값 — 버리지 않고 그대로 남김(PLAN 48-0 ② · 오류 없음)
continue
if option.input == "number":
if isinstance(value, bool) or not isinstance(value, (int, float)):
raise ValueError(f"{definition.name}의 {option.label}은(는) 숫자여야 합니다.")
if not (value == value and abs(value) != float("inf")) or value < 0:
raise ValueError(f"{definition.name}의 {option.label}은(는) 0 이상이어야 합니다.")
elif option.input == "bool" and not isinstance(value, bool):
raise ValueError(f"{definition.name}의 {option.label}은(는) 예 · 아니오여야 합니다.")
elif option.input == "select" and option.choices and str(value) not in option.choices:
raise ValueError(f"{definition.name}의 {option.label} 값이 선택지에 없습니다: {value}")
for option in definition.options:
+63 -13
View File
@@ -1,13 +1,15 @@
"""B05 구조물 타입 레지스트리·인스턴스 검증 모델.
구조물 타입 정의는 코드가 아니라 데이터(`B05_Profile_Structure_Types.json`)다. 리스트가
바뀌어도 코드를 고치지 않도록 분리했고, 프론트는 `GET /structure-types`로 같은 정본을 받는다.
구조물 타입 정의는 코드가 아니라 데이터(M02 마스터 `resources/master_template/구조물정의.json`
`types` · PLAN 48-1)다. 리스트가 바뀌어도 코드를 고치지 않도록 분리했고, 프론트는
`GET /structure-types`로 같은 정본을 받는다. 정의 틀 = `docs/raw/M02_구조물옵션정의/정의_틀.md`.
인스턴스 정본은 `B05_Profile/route/structures.json` **하나뿐**이다(2026-08-16 사용자 확정).
DB에는 참조 메타만 남긴다 — 두 곳에 같은 값을 두면 어긋난 쪽이 화면에 뜬다(관 매설 지점의
"복원 유령" 전례).
"""
import copy
import json
import os
from functools import lru_cache
@@ -21,8 +23,12 @@ from common_util.common_util_summary_item import parse_group_items, parse_summar
STRUCTURE_PLACEMENTS = ("point", "interval", "site")
STRUCTURE_SIDES = ("left", "right", "center", "cross")
_REGISTRY_PATH = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "B05_Profile_Structure_Types.json"
# 시험은 사본으로 바꿈 — 읽기 캐시는 (경로 · 고친 시각 · 크기)로 갈려 저장 즉시 새로 읽음
DEFINITION_PATH = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
"resources",
"master_template",
"구조물정의.json",
)
Placement = Literal["point", "interval", "site"]
@@ -35,7 +41,7 @@ class StructureOptionField(BaseModel):
key: str
label: str
input: Literal["select", "number", "text"]
input: Literal["select", "number", "text", "bool"]
choices: list[str] = Field(default_factory=list)
unit: str | None = None
default: Any = None
@@ -99,14 +105,37 @@ class StructureType(BaseModel):
enabled: bool = True
@lru_cache(maxsize=1)
def load_structure_types() -> tuple[StructureType, ...]:
"""레지스트리 정본을 읽어 타입 목록을 돌려준다(프로세스 수명 동안 1회 로드)."""
with open(_REGISTRY_PATH, encoding="utf-8") as handle:
payload = json.load(handle)
def _stamp() -> tuple[str, int, int]:
stat = os.stat(DEFINITION_PATH)
return DEFINITION_PATH, stat.st_mtime_ns, stat.st_size
@lru_cache(maxsize=4)
def _read_definition(path: str, _mtime: int, _size: int) -> dict[str, Any]:
with open(path, encoding="utf-8") as handle:
return json.load(handle)
@lru_cache(maxsize=4)
def _read_types(path: str, mtime: int, size: int) -> tuple[StructureType, ...]:
payload = _read_definition(path, mtime, size)
return tuple(StructureType.model_validate(item) for item in payload["types"])
def load_definition() -> dict[str, Any]:
"""구조물 정의 한 벌(사본) — `{판, types, 표시, 그룹, 종류, 배치, 규칙, 동작, …}`."""
return copy.deepcopy(_read_definition(*_stamp()))
def definition_version() -> int:
return int(_read_definition(*_stamp()).get("판", 1))
def load_structure_types() -> tuple[StructureType, ...]:
"""정의 정본을 읽어 타입 목록을 돌려준다(파일이 바뀔 때만 다시 읽음)."""
return _read_types(*_stamp())
def structure_type_map() -> dict[str, StructureType]:
return {item.type_id: item for item in load_structure_types()}
@@ -132,8 +161,11 @@ def station_planting_labels() -> set[str]:
def registry_schema_version() -> int:
with open(_REGISTRY_PATH, encoding="utf-8") as handle:
return int(json.load(handle).get("schema_version", 1))
return int(_read_definition(*_stamp()).get("schema_version", 1))
#: 구조물 id 모양 — 복사본 폴더 이름(`M02_Item_Snapshot.FOLDER_PATTERN`)이 되므로 경로 글자 금지
STRUCTURE_ID_RULE = r"[0-9A-Za-z][0-9A-Za-z_-]*"
class StructureInstance(BaseModel):
@@ -145,7 +177,7 @@ class StructureInstance(BaseModel):
model_config = ConfigDict(extra="forbid")
structure_id: str | None = None
structure_id: str | None = Field(default=None, pattern=rf"^{STRUCTURE_ID_RULE}$", max_length=64)
type_id: str
placement: Placement
chainage_m: float | None = Field(default=None, ge=0)
@@ -173,6 +205,24 @@ class StructureInstance(BaseModel):
def validate_group_items(cls, value: Any) -> dict[str, Any] | None:
return parse_group_items(value)
@model_validator(mode="before")
@classmethod
def follow_site_definition(cls, data: Any) -> Any:
"""정의가 부지형인데 옛 구간형으로 적힌 저장분(사토장 · PLAN 54-7) — 기준 측점 하나로 읽음.
기준 측점이 없으면 옛 기준 → 시작 차례. 파일의 옛 값은 [저장] 전까지 그대로.
"""
if not isinstance(data, dict) or data.get("placement") != "interval":
return data
definition = structure_type_map().get(str(data.get("type_id")))
if definition is None or definition.placement != "site":
return data
chainage = data.get("chainage_m")
if chainage is None:
chainage = data.get("start_m")
rest = {key: value for key, value in data.items() if key not in ("start_m", "end_m")}
return {**rest, "placement": "site", "chainage_m": chainage}
@model_validator(mode="after")
def validate_placement_fields(self) -> "StructureInstance":
if self.placement == "interval":
@@ -88,6 +88,7 @@ export function structureHashParts(section: CrossSection): Array<string | number
spec.basin_length_m ?? "",
spec.basin_before_m ?? "",
spec.basin_after_m ?? "",
spec.basin_height_m ?? "",
].join(",");
const basin = section.design?.basin_adjust;
const revet = section.design?.revet_adjust;
+265 -279
View File
@@ -7,10 +7,9 @@
* 시설 종류는 구조물 배치의 "종류" 드롭다운이, 위치(시작·기준·종료 측점)는 위치
* 칸이 담당하므로 여기에는 부속 옵션 필드만 있다.
*
* 배관 부속(2026-08-17 UI 개편): 관종·관경(기본 1000) 한 행 + 유입구·유출구
* 소그룹. 유입구는 집수정/기슭막이 택일이고, 유출구는 기슭막이뿐이다(현재 다른
* 선택지 없음). 기슭막이 조각은 형태·길이·높이·바닥 보호공을 한 벌로 묶어
* 유입·유출·독립 구조물(D4 기슭막이)이 **같은 인터페이스**를 쓴다.
* 배관 부속(PLAN 52-1): 사용자 구조물 표 01 명세 폼(`A00_Common/design/design_structure_pipe`)
* — 관 · 관 보호공(유입 · 유출) · 흙막이 추가 · 도수로/돌붙임 컨테이너. 저장 키는 옛 키 그대로 ·
* 옛 관종 · 날개벽 · 집수정 형식 칸은 화면에서 빠지고 값은 남음(지난 정의 값).
*
* 보호공(2026-08-17 사용자 지시): 구 "돌붙임 있음/없음 + 표면처리(찰/메)" 두 축을
* `돌붙임(찰)·돌붙임(메)·도수로` 한 축으로 합쳤다. 도수로·산비탈수로(B4)는 유출부에서
@@ -19,11 +18,9 @@
* 유입·유출 길이가 정해지면 위치 칸(시작·종료 측점)을 기준 − 유입 ~ 기준 + 유출로
* 자동 채운다. 형식·치수 제원은 B06/B07 필수 승격 대상이라 보이되 비필수다.
*
* BOX암거(2026-08-17 사용자 확정): 본체는 실무 관측 규격 2.0×2.0·3.0×3.0을 프리셋
* 셀렉트로 받고(기본 2.0×2.0), 그 밖의 규격만 "사용자 지정"으로 폭·높이를 직접
* 받는다 — 저장 키는 어느 쪽이든 body_width_m·body_height_m 숫자 그대로다.
* 날개벽은 유입·유출이 같은 조각(createWingFields)을 쓰고 설치 있음·짧은쪽 높이
* 1m·길이 2m·각도 45°가 기본이며, 설치를 "없음"으로 바꾸면 제원 칸이 접힌다.
* BOX암거 = 사용자 구조물 표 02 명세(PLAN 52-2 · `design_structure_box`) — 본체 규격 ·
* 유입 · 유출 구조. 저장 키는 body_width_m·body_height_m 숫자 · wing_in·wing_out 그대로.
* 날개벽 조각(createWingFields)은 숨김 — B06 조정 행 자리만 BOX · 세월교 명세 유입 · 유출 칸으로 옮겨 붙음.
*
* 짝: 시설 속성 붙이기 `carryIndices` ↔ 서버 `common_util/common_util_drainage_pipes.py`
* `carry_indices` — 같은 규칙(허용 오차 안 · 한 원본 한 번) · 거울 시험 test_b05_facility_carry.
@@ -36,35 +33,44 @@ import type {
} from "../B04_PreProcess/B04_PreProcess_Api_Fetch";
import {
BOX_SIZE_CUSTOM,
BOX_SIZE_PRESETS,
createBasinSplitFields,
createRevetmentFields,
createRevetSideGroup,
createWingFields,
grid,
group,
INLET_KINDS,
INLET_REVET_KEYS,
inletKindOf,
type InletStructureKind,
labeled,
numberInput,
optionalSelect,
OUTLET_REVET_KEYS,
putNumber,
stepper,
WING_IN_KEYS,
WING_OUT_KEYS,
} from "./B05_Profile_UI_Drainage_Facility_Fields";
import { pipeWallMinHeightM } from "../common_util/common_util_culvert_sets";
import { revetChoiceRow } from "./B05_Profile_UI_Drainage_Revet_Choice";
import { optionDefaults } from "./B05_Profile_UI_Structures_Fields";
import { createSpecForm, type SpecLinks } from "../A00_Common/design/design_structure_form";
import { PIPE_SPEC } from "../A00_Common/design/design_structure_pipe";
import {
BOX_SPEC,
bodyOf,
bodyOptions,
boxOptionsIn,
} from "../A00_Common/design/design_structure_box";
import { FORD_SPEC, withLegacyGuards } from "../A00_Common/design/design_structure_ford";
import { fordHeightM } from "../A00_Common/design/design_structure_ford_calc";
import {
pipeDrawn,
pipeExtraCount,
pipeLengthM,
setPipeExtraCount,
} from "../A00_Common/design/design_structure_pipe_calc";
import {
hasLinks,
linkFields,
type GroupItems,
type SummaryItem,
} from "../common_util/common_util_summary_item";
import { createFordFields } from "./B05_Profile_UI_Drainage_Facility_Ford";
import { FORD_PAVEMENT_SPEC } from "../A00_Common/design/design_structure_ford_pavement";
import { createHiddenOptions } from "./B05_Profile_UI_Drainage_Facility_Hidden";
export type { InletStructureKind }; // 목록은 700줄 한계로 `_Fields` 로 옮김 — 부르던 곳은 그대로
@@ -206,7 +212,21 @@ export interface FacilityOptionsForm {
options?: Record<string, string | number>,
/** 담당 유역의 설계유량(㎥/s) — 물넘이·세월교 개략 단면의 입력. 없으면 안내만. */
designFlow?: number | null,
/** 종류 정의 — 배관 명세 이름 바꿈(`spec_names`) · 그룹 이름(PLAN 52). */
definition?: {
spec_names?: Record<string, string>;
groups?: Array<{ id: string; name: string }>;
/** 옵션 정의 기본값 — 필수 상자 빈 고르기 칸이 받는 값(54-43). */
options?: Array<{ key: string; default: string | number | null }>;
} | null,
) => void;
/** 배관 명세 컨테이너 「구조물 조합」 잇기 자리 — 폼이 패널 그룹 값에 이음(PLAN 52-1). */
bindLinks: (links: SpecLinks) => void;
paintLinks: () => void;
/** 고른 관 측점 — 관 길이(자동) 계산에 씀. */
setChainage: (chainageM: number | null) => void;
/** 횡단 「추가 기슭막이(단)」이 바뀜 — 배관 흙막이 컨테이너 수를 다시 맞춤(54-1 · B06 이 부름). */
recount: () => void;
/** 현재 필드 값을 시설 옵션으로 읽는다(빈 값 생략). 숨긴 칸은 폼이 받은 옛 값 그대로. */
readOptions: () => Record<string, string | number>;
/** 「구조물 옵션 보이기」에서 끈 레지스트리 옵션 키 — 그 칸을 가린다(값은 옛 값 보존).
@@ -244,87 +264,129 @@ export function createFacilityOptionsForm(
root.className = "b05-drainage__facility";
root.hidden = true;
// ── 배관 본체 — 관종 > 관경 한 행(2026-08-17 사용자 지시 4) ──────────────
// 기본값(관종 파형강관 · 관경 1000 · 등록부)은 시설이 생길 때 칸에 실제 값으로 들어옴(PLAN 46-7).
const pipeMaterial = optionalSelect("— 안 정함 —", ["흄관", "VR관", "파형강관"]);
const pipeDiameter = document.createElement("select");
pipeDiameter.replaceChildren(
new Option("— 안 정함 —", ""),
...["800", "1000", "1200", "1500"].map((size) => new Option(`Ø${size}`, size)),
// ── 배관 = 사용자 구조물 표 01 명세(PLAN 52-1) — 컨테이너 다섯 · 옛 관종 · 날개벽 칸은 뺌(지난 정의 값) ──
let linkSource: SpecLinks | null = null;
let chainage: number | null = null;
const specLinks: SpecLinks = {
get: () => linkSource?.get() ?? {},
pick: (key) => linkSource?.pick(key),
clear: (key) => linkSource?.clear(key),
set: (key, item) => linkSource?.set(key, item),
};
// 기본값은 새 시설 칸에 실제 값으로만(54-39) — 빈 칸에 「(기본)」 꼬리 · 안내 없음
// 유입 「자동(규칙)」 = 기슭막이 + 유입 형식 auto(옛 값 · 정의 기본) — 그림은 지형 규칙이 집수정 · 흙막이를
// 정함. 사용자가 유입 구조를 고를 때까지 저장도 그대로(흙막이 고름의 형식 revet 을 안 적음)
let inletAuto: { structure?: string | number } | null = null;
const inletIsAuto = (): boolean =>
!!inletAuto && pipeForm.state().inlet?.[0]?.structure === "기슭막이";
// 그림 계산은 한 번 그릴 동안 한 번만(칸마다 부름)
let drawnMemo: ReturnType<typeof pipeDrawn> | undefined;
const drawnNow = (): ReturnType<typeof pipeDrawn> => {
if (drawnMemo === undefined) {
drawnMemo = pipeDrawn(chainage);
queueMicrotask(() => (drawnMemo = undefined));
}
return drawnMemo;
};
// 유출 「추가 흙막이(단)」(54-27) — 값 = 횡단 조정 단 수(같은 저장 자리) · 흙막이 상자 수가 따라감
const tiersInput = numberInput("1", "0");
tiersInput.max = "9";
const tiersRow = labeled("추가 흙막이(단)", stepper(tiersInput, 1, 0));
tiersRow.dataset.specItem = "outlet.tiers";
tiersRow
.querySelectorAll("button")
.forEach((b, i) => (b.title = `1단 ${i ? "늘리기" : "줄이기"}`));
const paintTiers = (values: Record<string, string>): HTMLElement => {
const count = pipeExtraCount(chainage);
tiersInput.value = count === null ? "" : String(count);
tiersInput.disabled = count === null;
tiersRow.hidden = !!values.structure && values.structure !== "기슭막이";
return tiersRow;
};
tiersInput.addEventListener("change", () => {
const count = Math.max(0, Math.min(9, Math.round(Number(tiersInput.value) || 0)));
// 지형이 못 세운 단은 횡단 기하가 자름 — 끝난 뒤 세운 만큼으로 다시 그림
void setPipeExtraCount(chainage, count).then(() => pipeForm.recount());
});
const inletChoice = revetChoiceRow(
() => chainage,
() => pipeForm.refresh(),
);
// 관보호공 날개벽 — **개소당 원단위**가 형식마다 붙박이라 고르는 칸이 있어야 물량이 선다
// (2026-09-09, 계획서 4-13 · 소광리 원본 탭 다섯). 비우면 날개벽을 안 센다.
const wingWall = optionalSelect("안 놓음", ["A-TYPE", "C-TYPE", "A-TYPE+집수정"]);
const pipeRow = grid(
labeled("관종", pipeMaterial, "pipe_kind"),
labeled("관경", pipeDiameter, "pipe_diameter_mm"),
const outletChoice = revetChoiceRow(
() => chainage,
() => pipeForm.refresh(),
);
const wingRow = grid(labeled("관보호공 날개벽", wingWall, "wing_wall_type"));
const pipeForm = createSpecForm(specLinks, {
// 관 보호공 [연동] · [경사](54-30) — 유입 · 유출 상자 각각 한 줄(같은 값) · 길이 있는 흙막이만(54-40 · 집수정 · 안 고름은 숨김)
fields: (c, values) =>
c.id === "outlet"
? [paintTiers(values), outletChoice.paint(values.structure !== "기슭막이")]
: c.id === "inlet"
? [inletChoice.paint(values.structure !== "기슭막이")]
: c.id === "soil_add" // 추가 흙막이 상자도 같은 줄(54-36 · 상자마다 한 줄 · 같은 값)
? [
revetChoiceRow(
() => chainage,
() => pipeForm.refresh(),
).paint(false),
]
: [],
shown: (c, item) => {
if (c.id === "inlet" && item.id === "structure" && inletIsAuto()) {
const drawn = drawnNow();
return drawn
? { value: drawn.basin ? "집수정" : "기슭막이", tag: "자동" }
: { value: "", tag: "자동(지형 규칙)" };
}
// 빈 고르기 칸 = 「선택 안 함」 그대로(54-39 · 기본값 꼬리 없음)
return null;
},
auto: (_c, item) => {
if (item.id !== "length") return "";
const length = pipeLengthM(chainage);
return length === null ? "횡단 설계 뒤 셈" : String(Math.round(length));
},
// 흙막이 개수 = 유출 「추가 기슭막이(단)」(54-1)
count: (c) => (c.id === "soil_add" ? pipeExtraCount(chainage) : undefined),
onChange: (c, item) => {
if (c.id === "inlet" && item.id === "structure") inletAuto = null;
if (c.id === "inlet" && (item.id === "structure" || item.id === "form"))
inletStructureHandler?.(inletStructureOf());
emit();
// 고른 뒤 그림이 바뀜 — 자동 표시를 새 그림으로 다시 그림(54-13)
if (c.id === "inlet") {
drawnMemo = undefined;
pipeForm.refresh();
}
},
});
// 조정창에서 옮겨 오는 행(단 수·옵션)이 붙을 자리 — 유입 · 유출 컨테이너 끝(2026-08-29 지시 4)
const inletSlot = pipeForm.slot("inlet");
const outletSlot = pipeForm.slot("outlet");
/** 유입 보호공 구조 → B06 유입측 형식 값(조정창과 같은 값). */
const inletStructureOf = (): InletStructureKind => {
const inlet = pipeForm.state().inlet?.[0] ?? {};
if (inlet.structure === "기슭막이") return "revet";
return inlet.structure === "집수정" && ["I", "L", "U"].includes(inlet.form ?? "")
? (inlet.form as InletStructureKind)
: "auto";
};
// ── 유입구 — 집수정 또는 기슭막이 택일(사용자 지시 5~9) ─────────────────
const inletGroup = group("유입구");
// 「안 정함」이면 기슭막이 칸을 보이되 값은 안 실음.
const inletType = document.createElement("select");
inletType.replaceChildren(
new Option("— 안 정함 —", ""),
...INLET_KINDS.map((kind) => new Option(kind.label, kind.label)),
);
const basinForm = optionalSelect("선택", [
"동물이동형",
"□형(기본형)",
"돌집수정 ㄴ형",
"돌집수정 ㄷ형",
]);
// 집수정도 재질·표면처리를 형태 한 축으로 합친다(사용자 지시 1).
const basinMaterial = optionalSelect("선택", [
"콘크리트",
"조립식 주철맨홀",
"돌쌓기(찰)",
"돌쌓기(메)",
]);
const basinMaterialField = labeled("형태", basinMaterial, "inlet_basin_material");
// 집수정 종방향 길이 — 3D 예상형상용, 전후 동일 배분·기본 2m(2026-08-23 사용자).
const basinLength = numberInput("0.1", "0");
// 기준측점 전 · 후 — 옛 횡단 조정창에만 있던 칸을 폼으로(계획서 24-4a).
const basinSplit = createBasinSplitFields(basinLength);
basinSplit.onChange(() => emit());
const basinRows = [
grid(
labeled("형식", basinForm, "inlet_basin_form"),
labeled("길이 (m)", stepper(basinLength, 1), "inlet_basin_length_m"),
),
basinSplit.row,
];
const height = (): string =>
String(pipeWallMinHeightM(Number(pipeDiameter.value || "1000") / 1000));
const inletRevet = createRevetmentFields(INLET_REVET_KEYS, { height });
// 첫 행 = [구조][형태] — 구조에 따라 집수정 형태와 기슭막이 형태가 갈아 끼워진다
// (2026-08-17 사용자 지시 3).
// 조정창에서 옮겨 오는 행(단 수·옵션)이 붙을 자리(2026-08-29 사용자 지시 4).
// 비어 있으면 아무 자리도 차지하지 않는다.
const inletSlot = document.createElement("div");
inletSlot.className = "b05-structure__adjust-slot";
const outletSlot = inletSlot.cloneNode() as HTMLDivElement;
inletGroup.body.append(
grid(
labeled("구조", inletType, ["inlet_type", "inlet_structure"]),
basinMaterialField,
inletRevet.formField,
),
...basinRows,
...inletRevet.rows,
inletSlot,
);
// ── 유출구 — 구조 선택지는 기슭막이뿐이지만 양식을 맞춘다(사용자 지시 2·4) ──
const outletGroup = group("유출구");
const outletType = optionalSelect("— 안 정함 —", ["기슭막이"]);
const outletRevet = createRevetmentFields(OUTLET_REVET_KEYS, { height });
outletGroup.body.append(
grid(labeled("구조", outletType, "outlet_type"), outletRevet.formField),
...outletRevet.rows,
outletSlot,
);
// ── 세월교 = 사용자 구조물 표 04 명세(PLAN 52-4) — 세월교 · 유입 구조 · 유출 구조 ──
// 월류 높이 = 월류 폭과 연동(폭을 바꾸면 필요 수심으로 채움 · 그 아래는 안 받음 · `design_structure_ford_calc`)
let fordFlow: number | null = null;
const fordNeed = (): number | null =>
fordHeightM(fordFlow, Number(fordForm.state().ford?.[0]?.width ?? ""));
const fordForm = createSpecForm(specLinks, {
onChange: (c, item) => {
const need = c.id === "ford" ? fordNeed() : null;
const height = fordForm.state().ford?.[0]?.height ?? "";
const low = height !== "" && !(Number(height) >= (need ?? 0));
if (need !== null && (item.id === "width" || (item.id === "height" && low)))
fordForm.setValue("ford", "height", need.toFixed(2));
emit();
},
});
// ── 추가 기슭막이(다단) — 횡단도에서 다단 벽을 고를 때만 뜬다(2026-08-30 사용자
// 지시 4). 유입구·유출구와 같은 양식이되, 값은 조정창 사본의 행이 그대로 옮겨 온다
@@ -340,7 +402,9 @@ export function createFacilityOptionsForm(
// 나눈다(2026-08-30 사용자). 설치 측이 한쪽이면 그 칸만 뜬다.
// 좌·우가 저장 채널(유입/유출) 중 어느 쪽인지는 측점 지형이 정하므로 이름표만
// 바꿔 단다(`setRevetSideLabels`) — 값은 언제나 그 채널 키로 오간다.
const revetSide = optionalSelect("— 안 정함 —", ["양쪽", "좌", "우"]);
// 설치 측 = 필수 칸 — 빈 보기 없음(54-43 · 빈 옛 값 = 양쪽)
const revetSide = document.createElement("select");
revetSide.replaceChildren(...["양쪽", "좌", "우"].map((v) => new Option(v, v)));
const revetTopRow = grid(labeled("설치 측", revetSide, "side"));
const revetInlet = createRevetSideGroup(INLET_REVET_KEYS);
const revetOutlet = createRevetSideGroup(OUTLET_REVET_KEYS);
@@ -376,67 +440,33 @@ export function createFacilityOptionsForm(
return merged;
};
// ── BOX암거 — 본체 규격(프리셋 + 사용자 지정)·날개벽(유입·유출 개별) ────
// 폭·높이 자유 입력은 "사용자 지정"을 골랐을 때만 펼친다(2026-08-17 사용자 확정).
const boxSize = optionalSelect("— 안 정함 —", [
...BOX_SIZE_PRESETS.map(([label]) => label),
BOX_SIZE_CUSTOM,
]);
const boxWidth = numberInput("0.1", "0");
const boxHeight = numberInput("0.1", "0");
const boxCustomRow = grid(
labeled("본체 폭 (m)", boxWidth, "body_width_m"),
labeled("본체 높이 (m)", boxHeight, "body_height_m"),
);
const boxWrap = document.createElement("div");
boxWrap.append(
grid(labeled("본체 규격 (m)", boxSize, ["body_width_m", "body_height_m"])),
boxCustomRow,
);
// ── BOX암거 = 사용자 구조물 표 02 명세(PLAN 52-2) — 본체 · 유입 구조 · 유출 구조 ──
const boxForm = createSpecForm(specLinks, { onChange: () => emit() });
// 날개벽 칸 — 세월교 · BOX 가 같은 조각을 쓰던 자리 · 조정 행은 명세 유입 · 유출 칸으로 옮겨 붙음
const wingInFields = createWingFields("날개벽(유입)", WING_IN_KEYS);
const wingOutFields = createWingFields("날개벽(유출)", WING_OUT_KEYS);
const wingInHome = wingInFields.slot.parentElement!;
const wingOutHome = wingOutFields.slot.parentElement!;
const hiddenOptions = createHiddenOptions(root);
/** 고른 프리셋을 폭·높이 칸에 실어 둔다 — 저장도, "사용자 지정"으로 바꿨을 때의
* 출발값도 이 두 칸이 정본이다. 사용자 지정 상태에서는 손대지 않는다. */
function syncBoxSize(): void {
const preset = BOX_SIZE_PRESETS.find(([label]) => label === boxSize.value);
if (preset) {
boxWidth.value = String(preset[1]);
boxHeight.value = String(preset[2]);
}
// 「안 정함」도 폭·높이 칸을 접음 — 값이 없는 상태 그대로.
boxCustomRow.hidden = boxSize.value !== BOX_SIZE_CUSTOM;
}
// ── 물넘이 포장 = 사용자 구조물 표 03 명세(PLAN 52-3) — 경사각도 · 도수로/돌붙임 ·
// 옛 월류 폭 · 높이 · 바닥 경사 · 두께 · 길이 칸은 뺌(지난 정의 값) ──
const paveForm = createSpecForm(specLinks, { onChange: () => emit() });
// ── 물넘이·세월교 — 월류 폭·높이·경사·두께·길이·련 수(`_Ford`).
// 기본값(등록부)은 시설이 생길 때 칸에 실제 값으로 들어옴 — 제안값 단추 없음(PLAN 46-7).
const ford = createFordFields(() => emit());
// 10-A ⑲ 저장 규칙을 폼 머리에 드러냄 — 병합은 `_Drainage_Facility_Merge`(2026-09-14 브레인 판정).
const saveNote = document.createElement("p");
saveNote.className = "b05-structure__owner-note";
saveNote.textContent =
"[저장]은 이 폼에 있는 칸만 바꿈 — 폼에 없는 칸(집계표·구조물도로 적은 값)은 그대로 둠 · 시설 종류를 바꾸면 새로 씀";
// 10-A ⑲ 저장 규칙 글은 [?] 설명서 `구조물_<시설>.md` 로 옮김(54-2) — 병합은 `_Drainage_Facility_Merge`.
// 세월교·물넘이 항목은 **관종·관경 바로 다음**에 둔다(2026-08-30 사용자 지시 2) —
// 월류 폭·높이 → 바닥 경사 → 수량 → 개략 단면 결과. 다른 시설에서는 전부 숨는다.
root.append(
saveNote,
pipeRow,
wingRow,
ford.widthRow,
ford.slopeRow,
ford.countRow,
ford.summary,
inletGroup.root,
outletGroup.root,
pipeForm.root,
fordForm.root,
paveForm.root,
extraGroup.root,
revetTopRow,
revetInlet.root,
revetOutlet.root,
boxWrap,
boxForm.root,
wingInFields.root,
wingOutFields.root,
);
@@ -448,23 +478,17 @@ export function createFacilityOptionsForm(
if (current === null) return;
const isPipe = current === "pipe";
const isBox = current === "box_culvert";
// 관종·관경은 배수관과 세월교가 공유한다.
pipeRow.hidden = !isPipe && current !== "ford_bridge";
// 관보호공 날개벽 원단위는 **배수관 Ø800·Ø1000** 것뿐이다 — 다른 시설에서는 숨긴다.
wingRow.hidden = !isPipe;
inletGroup.root.hidden = !isPipe;
outletGroup.root.hidden = !isPipe;
boxWrap.hidden = !isBox;
// 날개벽은 BOX암거와 세월교가 같은 옵션 한 벌을 쓴다(2026-08-25 사용자 확정).
const hasWing = isBox || current === "ford_bridge";
wingInFields.root.hidden = !hasWing;
wingOutFields.root.hidden = !hasWing;
const isFord = current === "ford_pavement" || current === "ford_bridge";
ford.countRow.hidden = current !== "ford_bridge";
ford.widthRow.hidden = !isFord;
// 바닥 경사는 물넘이포장만 쓴다 — 세월교는 구체 위 노면이라 파임이 없다.
ford.slopeRow.hidden = current !== "ford_pavement";
ford.summary.hidden = !isFord;
const isBridge = current === "ford_bridge";
pipeForm.root.hidden = !isPipe;
boxForm.root.hidden = !isBox;
fordForm.root.hidden = !isBridge;
// 날개벽 칸 = 옛 자리 — BOX(52-2) · 세월교(52-4)는 명세 유입 · 유출 구조 컨테이너 · B06 조정 행 자리만 그 컨테이너 끝으로
const spec = isBox ? boxForm : isBridge ? fordForm : null;
wingInFields.root.hidden = true;
wingOutFields.root.hidden = true;
(spec ? spec.slot("inlet") : wingInHome).append(wingInFields.slot);
(spec ? spec.slot("outlet") : wingOutHome).append(wingOutFields.slot);
paveForm.root.hidden = current !== "ford_pavement";
const isRevet = current === "revetment";
revetTopRow.hidden = !isRevet;
// 설치 측이 한쪽이면 그쪽 칸만 남긴다 — 이름표는 측점이 정한 좌·우다(안 정함 = 양쪽처럼 보임).
@@ -476,23 +500,6 @@ export function createFacilityOptionsForm(
// 추가 기슭막이 칸은 **내용이 있을 때만** 선다 — 고른 다단 벽의 행이 여기 오면 뜨고,
// 선택이 풀리면 스스로 사라진다.
extraGroup.root.hidden = extraSlot.childElementCount === 0;
if (isFord) ford.sync();
if (isBox) syncBoxSize();
if (hasWing) {
wingInFields.syncVisibility();
wingOutFields.syncVisibility();
}
if (isPipe) {
// 유입구 구조에 따라 집수정 칸과 기슭막이 칸을 갈아 끼운다(사용자 지시 6~8).
// 병합 목록이라 판정은 라벨이 아니라 매핑된 정본 종류로 한다(2026-08-29).
const kind = inletKindOf(inletType.value);
const basin = kind.type === "집수정";
const revet = kind.type === "기슭막이";
basinRows.forEach((row) => (row.hidden = !basin));
basinMaterialField.hidden = !basin;
inletRevet.formField.hidden = !revet;
inletRevet.rows.forEach((row) => (row.hidden = !revet));
}
}
function emit(): void {
@@ -500,30 +507,15 @@ export function createFacilityOptionsForm(
callbacks.onChange?.();
}
[inletType, outletType, wingWall, basinForm, basinMaterial, basinLength].forEach((input) =>
input.addEventListener("change", emit),
);
inletRevet.onChange(emit);
outletRevet.onChange(emit);
revetInlet.fields.onChange(emit);
revetOutlet.fields.onChange(emit);
revetSide.addEventListener("change", emit);
[
pipeMaterial,
pipeDiameter,
boxSize,
boxWidth,
boxHeight,
...wingInFields.inputs,
...wingOutFields.inputs,
...ford.inputs,
].forEach((input) => input.addEventListener("change", emit));
[...wingInFields.inputs, ...wingOutFields.inputs].forEach((input) =>
input.addEventListener("change", emit),
);
/** 유입구 구조 변경 수신자(B06 유입측 형식 제어). B05는 비워 둔다. */
let inletStructureHandler: ((value: InletStructureKind) => void) | null = null;
inletType.addEventListener("change", () =>
inletStructureHandler?.(inletKindOf(inletType.value).structure),
);
return {
root,
@@ -538,26 +530,47 @@ export function createFacilityOptionsForm(
revetSideLabels = labels;
syncVisibility();
},
inletStructure: () => inletKindOf(inletType.value).structure,
inletStructure: inletStructureOf,
setInletStructure(value) {
// 지금 고른 정본 종류(기슭막이/집수정)는 지키고 형식만 맞춘다.
const type = inletKindOf(inletType.value).type;
const hit =
INLET_KINDS.find((kind) => kind.type === type && kind.structure === value) ??
INLET_KINDS.find((kind) => kind.structure === value);
if (hit) inletType.value = hit.label;
// 조정창 형식 → 유입 보호공 구조 · 형태(자동 = 고른 구조는 지키고 형태만 비움)
if (value === "revet") {
inletAuto = null;
pipeForm.setValue("inlet", "structure", "기슭막이");
} else if (value !== "auto") pipeForm.setValue("inlet", "structure", "집수정");
if (value !== "revet" && pipeForm.state().inlet?.[0]?.structure === "집수정")
pipeForm.setValue("inlet", "form", value === "auto" ? "" : value);
syncVisibility();
},
bindLinks(links) {
linkSource = links;
pipeForm.paintLinks();
boxForm.paintLinks();
fordForm.paintLinks();
paveForm.paintLinks();
},
paintLinks: () => {
pipeForm.paintLinks();
boxForm.paintLinks();
fordForm.paintLinks();
paveForm.paintLinks();
},
setChainage(chainageM) {
chainage = chainageM;
if (current === "pipe") pipeForm.refresh();
},
recount() {
if (current === "pipe") pipeForm.recount();
},
onInletStructureChange(handler) {
inletStructureHandler = handler;
},
setHiddenOptions(facility, registryKeys) {
hiddenOptions.set(facility, registryKeys);
},
setFacility(facility, options = {}, designFlow = null) {
setFacility(facility, options = {}, designFlow = null, definition = null) {
current = facility;
hiddenOptions.remember(options);
ford.setDesignFlow(designFlow ?? null);
fordFlow = designFlow ?? null;
if (facility === null) {
syncVisibility();
return;
@@ -565,97 +578,70 @@ export function createFacilityOptionsForm(
const text = (key: string): string =>
options[key] !== undefined ? String(options[key]) : "";
// 받은 값만 칸에 — 없으면 「안 정함」(새 시설은 부르는 쪽이 등록부 기본값을 실어 줌 · 46-7).
pipeMaterial.value = text("pipe_kind");
pipeDiameter.value = text("pipe_diameter_mm");
// 병합 목록: 저장된 정본 둘(inlet_type·inlet_structure)로 라벨을 되찾는다.
const savedType = text("inlet_type");
const savedStructure = text("inlet_structure");
inletType.value = savedType
? (
INLET_KINDS.find(
(kind) =>
kind.type === savedType && (!savedStructure || kind.structure === savedStructure),
) ?? inletKindOf(savedType)
).label
: "";
outletType.value = text("outlet_type");
wingWall.value = text("wing_wall_type");
basinForm.value = text("inlet_basin_form");
basinMaterial.value = text("inlet_basin_material");
basinLength.value = text("inlet_basin_length_m");
basinSplit.write(options);
inletRevet.write(options);
outletRevet.write(options);
// 저장된 폭·높이가 프리셋과 맞으면 그 프리셋을, 아니면 "사용자 지정"을 고른다.
// 값이 없으면 「안 정함」.
const savedWidth = Number.parseFloat(text("body_width_m"));
const savedHeight = Number.parseFloat(text("body_height_m"));
const hasSaved =
Number.isFinite(savedWidth) &&
savedWidth > 0 &&
Number.isFinite(savedHeight) &&
savedHeight > 0;
const preset = hasSaved
? BOX_SIZE_PRESETS.find(
([, width, height]) =>
Math.abs(width - savedWidth) < 0.05 && Math.abs(height - savedHeight) < 0.05,
)
: undefined;
boxSize.value = hasSaved ? (preset?.[0] ?? BOX_SIZE_CUSTOM) : "";
boxWidth.value = hasSaved ? String(savedWidth) : "";
boxHeight.value = hasSaved ? String(savedHeight) : "";
const groups = Object.fromEntries((definition?.groups ?? []).map((g) => [g.id, g.name]));
const names = definition?.spec_names ?? {};
// 필수 상자 빈 고르기 칸이 받는 정의 기본값(54-43) — 옛 키는 열 때와 같은 길로 바꿈
const defaults = optionDefaults(definition?.options ?? []);
if (facility === "pipe") {
// 정의 파일의 옛 이름 「흙막이 추가」 — 명세 이름 「흙막이」가 앞섬(54-1)
const { soil_add: _old, ...pipeNames } = names;
const kind = options.inlet_structure;
inletAuto =
options.inlet_type === "기슭막이" &&
!["revet", "I", "L", "U"].includes(String(kind ?? ""))
? { structure: kind }
: null;
pipeForm.write(PIPE_SPEC, options, pipeNames, groups, defaults);
}
if (facility === "box_culvert") {
// 본체 규격은 저장 안 함 — 폭 · 높이로 되찾음 · 옛 설치 「있음」 = 날개벽
boxForm.write(BOX_SPEC, boxOptionsIn(options), names, groups, boxOptionsIn(defaults));
for (const [id, value] of Object.entries(bodyOf(options)))
boxForm.setValue("body", id, value);
}
if (facility === "ford_bridge")
fordForm.write(
FORD_SPEC,
withLegacyGuards(options),
names,
groups,
withLegacyGuards(defaults),
);
if (facility === "ford_pavement")
paveForm.write(FORD_PAVEMENT_SPEC, options, names, groups, defaults);
wingInFields.write(options);
wingOutFields.write(options);
if (facility === "ford_pavement" || facility === "ford_bridge") ford.write(facility, options);
revetSide.value = text("side");
revetSide.value = text("side") || "양쪽";
const spread = legacyRevetOptions(options);
// 빈 형태 = 정의 기본값(54-43 · 필수 칸)
for (const key of [INLET_REVET_KEYS.form, OUTLET_REVET_KEYS.form])
if (!spread[key] && defaults.form) spread[key] = defaults.form;
revetInlet.fields.write(spread);
revetOutlet.fields.write(spread);
syncVisibility();
},
setDesignFlow(designFlow) {
ford.setDesignFlow(designFlow ?? null);
fordFlow = designFlow ?? null;
if (current === "ford_bridge") fordForm.refresh(); // 높이 안내
syncVisibility();
},
readOptions() {
const options: Record<string, string | number> = {};
// 고른 칸만 싣는다 — 「안 정함」은 빈 값(기본값을 몰래 확정으로 안 바꿈).
const putPipe = (): void => {
if (pipeDiameter.value) options.pipe_diameter_mm = Number(pipeDiameter.value);
if (pipeMaterial.value) options.pipe_kind = pipeMaterial.value;
};
if (current === "pipe") {
putPipe();
const inletKind = inletKindOf(inletType.value);
if (wingWall.value) options.wing_wall_type = wingWall.value;
// B06 유입측 형식(조정창과 같은 값) — 병합 드롭다운이 함께 정한다(2026-08-29).
if (inletType.value) {
options.inlet_type = inletKind.type;
options.inlet_structure = inletKind.structure;
Object.assign(options, pipeForm.read()); // 명세 컨테이너 값 = 옛 키 그대로(PLAN 52-1)
// 자동(규칙)은 고를 때까지 그대로 — 보여 주기만으로 파일이 안 바뀜(54-13)
if (inletIsAuto()) {
if (inletAuto!.structure === undefined) delete options.inlet_structure;
else options.inlet_structure = inletAuto!.structure;
}
if (inletKind.type === "집수정") {
if (basinForm.value) options.inlet_basin_form = basinForm.value;
if (basinMaterial.value) options.inlet_basin_material = basinMaterial.value;
putNumber(options, "inlet_basin_length_m", basinLength.value);
basinSplit.read(options);
} else {
inletRevet.read(options);
}
if (outletType.value) options.outlet_type = outletType.value;
outletRevet.read(options);
} else if (current === "box_culvert") {
// 프리셋을 골랐든 사용자 지정을 적었든 정본은 폭·높이 두 칸이다.
putNumber(options, "body_width_m", boxWidth.value);
putNumber(options, "body_height_m", boxHeight.value);
wingInFields.read(options);
wingOutFields.read(options);
// 정본은 폭 · 높이 두 칸 — 규격이면 규격 수 · 사용자 입력이면 명세 숫자 칸(PLAN 52-2)
Object.assign(options, boxForm.read(), bodyOptions(boxForm.state().body?.[0]));
} else if (current === "ford_pavement") {
ford.read(current, options);
Object.assign(options, paveForm.read()); // 표 03 명세 값 · 옛 월류 · 경사 · 두께 · 길이는 병합이 이어 붙임(52-3)
} else if (current === "ford_bridge") {
putPipe();
ford.read(current, options);
wingInFields.read(options);
wingOutFields.read(options);
Object.assign(options, fordForm.read()); // 표 04 명세 값 · 옛 관종 · 날개벽 치수는 병합이 이어 붙임(52-4)
} else if (current === "revetment") {
if (revetSide.value) options.side = revetSide.value;
// 단 수는 폼이 갖지 않는다 — 횡단 설계 patch(extra_wall_counts)가 정본이고
@@ -9,7 +9,6 @@
* ========================================================================== */
import { FORD_MANNING_N, FORD_SLOPE } from "@config/config_frontend";
import revetmentSabang from "../resources/data_masonry/revetment_sabang_2026-01-01.json";
/* ── 유입구 구조 ──────────────────────────────────────────────────────────── */
@@ -160,16 +159,13 @@ export function putNumber(target: Record<string, string | number>, key: string,
if (Number.isFinite(value) && value > 0) target[key] = Number(value.toFixed(1));
}
/** 선택지 셀렉트 — **맨 앞에 빈 보기(「안 정함」)** 를 둠. 첫 보기를 미리 고르지 않음
/** 선택지 셀렉트 — **맨 앞에 빈 보기(빈 글 · 54-43)** 를 둠. 첫 보기를 미리 고르지 않음
* (2026-09-14 브레인 판정 · 옛 2026-08-17 「빈 항목 두지 않음」 걷음) — 고른 적 없는 첫 값이 저장돼
* 확정으로 굳지 않게. 기본값이 있는 칸은 부르는 쪽이 값을 넣음(그것은 따로 차례). */
export function optionalSelect(
blankLabel: string,
choices: ReadonlyArray<string>,
): HTMLSelectElement {
export function optionalSelect(choices: ReadonlyArray<string>): HTMLSelectElement {
const element = document.createElement("select");
element.replaceChildren(
new Option(blankLabel, ""),
new Option("", ""),
...choices.map((choice) => new Option(choice, choice)),
);
return element;
@@ -212,13 +208,6 @@ export interface RevetmentKeys {
after?: string;
}
/** 높이 칸 안내 — 관 벽은 비우면 관경 기준 최소 높이(엔진 `pipe_wall_min_height_m` · 함수로 받아
* 볼 때마다 셈) · 빈 글이면 「설계자 입력」. 형태 · 길이 · 전후 기본값은 등록부가 시설이 생길 때
* 칸에 실제 값으로 넣음(PLAN 46-7 · 제안값 단추 없음). */
export interface RevetmentDefaults {
height: string | (() => string);
}
export const INLET_REVET_KEYS: RevetmentKeys = {
form: "inlet_revet_form",
length: "inlet_revet_length_m",
@@ -245,39 +234,18 @@ export interface RevetSideGroup {
slot: HTMLElement;
}
/** 독립 기슭막이 치수 근거 줄 — `revetment_sabang_*.json` 한 벌(B08 사유와 같은 파일 · 쪽·줄 번호).
* ⚠ 파일 판이 바뀌면 이 import 도 옮길 것 — 시험(`test_b05_revetment_sabang_basis`)이 최신 판을 대조. */
function sabangBasisLines(): string[] {
const { items, scope } = revetmentSabang;
const span = (values: number[], unit = ""): string => `${values[0]}~${values[1]}${unit}`;
return [
`높이 — ${items.height.rule}(${items.height.source}) · ${items.height.input}`,
`계획비탈 1:${span(items.face_slope.standard_ratio)}(${items.face_slope.source}) — 제안값은 품셈 표준경사`,
`둑마루 두께 ${span(items.crown_thickness.standard_m, "m")}(${items.crown_thickness.source}) — 콘크리트 기준 · 돌쌓기는 뒷길이 + 0.30 식`,
`뒷채움 조약돌 두께 — ${items.backfill_pebble.source}`,
scope,
];
}
export function createRevetSideGroup(keys: RevetmentKeys): RevetSideGroup {
const box = group("기슭막이");
const kind = document.createElement("select");
kind.replaceChildren(new Option("기슭막이", "기슭막이"));
// 높이는 기본값 없음 — 설계자 입력(계획홍수위 + 여유고 · 2026-09-14 브레인 판정).
const fields = createRevetmentFields(keys, { height: "" });
const basis = document.createElement("p");
basis.className = "b05-route__note";
basis.replaceChildren(
...sabangBasisLines().flatMap((line, index) =>
index ? [document.createElement("br"), line] : [line],
),
);
const fields = createRevetmentFields(keys);
// 치수 근거 글(사방기술교본)은 [?] 설명서 `구조물_기슭막이.md` 로 옮김(54-2)
const slot = document.createElement("div");
slot.className = "b05-structure__adjust-slot";
box.body.append(
grid(labeled("구조", kind), fields.formField),
...fields.rows,
basis,
// 단 수는 여기 두지 않는다 — 조정창에서 옮겨 오는 [추가 기슭막이(단)] 행과
// 같은 값이라 두 벌이면 헷갈린다(2026-08-30 사용자).
slot,
@@ -304,24 +272,13 @@ export interface RevetmentFields {
* (2026-08-17 사용자 지시 9·11). 재질과 표면처리는 "형태" 한 축(지시 1). 바닥
* 보호공(돌붙임) 한 벌은 뺐다 — 기슭막이는 사면 공정이라 그 아래 돌붙임이 붙을
* 자리가 아니다(2026-08-19 사용자 지시 1). */
export function createRevetmentFields(
keys: RevetmentKeys,
defaults: RevetmentDefaults,
): RevetmentFields {
const wallFloor = (): string =>
typeof defaults.height === "function" ? defaults.height() : defaults.height;
export function createRevetmentFields(keys: RevetmentKeys): RevetmentFields {
// 형태 = 필수 칸 — 빈 보기 없음(54-43 · 값은 부르는 쪽이 정의 기본값으로 채움)
const form = document.createElement("select");
form.replaceChildren(
new Option("— 안 정함 —", ""),
...REVET_FORMS.map((value) => new Option(value, value)),
);
form.replaceChildren(...REVET_FORMS.map((value) => new Option(value, value)));
const length = keys.length ? numberInput("0.1", "0") : null;
// 관 벽은 비우면 관경 기준 최소 높이로 섬(엔진) · 독립 기슭막이 높이는 「설계자 입력」.
const heightHint = (): string =>
wallFloor() ? `비우면 관경 기준 ${wallFloor()}` : "설계자 입력";
const height = numberInput("0.1", "0", heightHint());
// 관 벽 기준 높이는 관경을 따라감 — 칸을 볼 때마다 다시 셈.
height.addEventListener("focus", () => (height.placeholder = heightHint()));
// 빈 칸 = 그냥 빈 칸(54-43 · 자리표시 글 없음)
const height = numberInput("0.1", "0");
// 기준측점 전/후(2026-08-23 사용자) — 구조물 패널(D군)과 같은 연동:
// 전 + 후 = 길이, 나중에 고친 쪽이 살아남고 반대쪽이 재배분된다.
const before = keys.before && length ? numberInput("0.1", "0") : null;
@@ -364,9 +321,9 @@ export function createRevetmentFields(
const text = (key: string): string =>
options[key] !== undefined ? String(options[key]) : "";
form.value = text(keys.form);
if (form.selectedIndex < 0) form.selectedIndex = 0;
if (length && keys.length) length.value = text(keys.length);
height.value = text(keys.height);
height.placeholder = heightHint();
if (before && keys.before) before.value = text(keys.before);
if (after && keys.after) after.value = text(keys.after);
syncSplit("length");
@@ -461,18 +418,6 @@ export function createBasinSplitFields(length: HTMLInputElement): {
};
}
/* ── BOX암거 ────────────────────────────────────────────────────────────── */
/** 본체 규격 프리셋 — 실무 관측 규격이다(2026-08-17 사용자 확정). 그 밖의 규격은
* "사용자 지정"으로 폭·높이를 직접 받는다. 저장 키는 프리셋이든 자유 입력이든
* body_width_m·body_height_m 숫자 그대로다 — 프리셋 전용 키를 만들지 않아야
* 하류(B06 횡단도·수량)가 폭·높이만 읽고 끝난다. */
export const BOX_SIZE_PRESETS: ReadonlyArray<readonly [string, number, number]> = [
["2.0×2.0", 2, 2],
["3.0×3.0", 3, 3],
];
export const BOX_SIZE_CUSTOM = "사용자 지정";
/** 날개벽 옵션 키 묶음 — 유입·유출이 같은 조각을 쓰되 키만 다르다. */
interface WingKeys {
install: string;
@@ -510,7 +455,7 @@ interface WingFields {
* 설치 "없음"이면 제원 칸을 접는다(기슭막이 보호공 치수와 같은 패턴).
* 기본 제원(있음·1·2·45, 사용자 확정)은 등록부 기본값 — 시설이 생길 때 칸에 실제 값(PLAN 46-7). */
export function createWingFields(title: string, keys: WingKeys): WingFields {
const install = optionalSelect("— 안 정함 —", ["있음", "없음"]);
const install = optionalSelect(["있음", "없음"]);
const height = numberInput("0.1", "0");
const length = numberInput("0.1", "0");
const angle = numberInput("1", "0");
@@ -17,44 +17,46 @@
const revetKeys = (side: "inlet" | "outlet"): string[] =>
["form", "length_m", "height_m", "before_m", "after_m"].map((key) => `${side}_revet_${key}`);
const wingKeys = (side: "in" | "out"): string[] => [
`wing_${side}`,
`wing_${side}_height_m`,
`wing_${side}_length_m`,
`wing_${side}_angle_deg`,
];
/** 시설 종류별로 **폼이 적는 칸** — `createFacilityOptionsForm().readOptions()` 가 쓰는 키 전부. */
export const FORM_OPTION_KEYS: Readonly<Record<string, readonly string[]>> = {
// 배관 = 표 01 명세 키(PLAN 52-1 · `design_structure_pipe`) — 옛 관종 · 날개벽 · 집수정 형식은 폼에서
// 빠져 이어 붙임(지난 정의 값) · 선택 컨테이너 키는 `FORM_OPTION_PREFIXES`
pipe: [
"pipe_diameter_mm",
"pipe_kind",
"wing_wall_type",
"inlet_type",
"inlet_structure",
"inlet_basin_form",
"inlet_basin_material",
"inlet_basin_length_m",
"inlet_basin_before_m",
"inlet_basin_after_m",
// 집수정 길이 · 전 · 후는 폼에서 빠짐(54-1) — 옛 값 그대로 둠
"inlet_basin_height_m",
...revetKeys("inlet"),
"outlet_type",
...revetKeys("outlet"),
],
box_culvert: ["body_width_m", "body_height_m", ...wingKeys("in"), ...wingKeys("out")],
ford_pavement: ["ford_width_m", "ford_height_m", "ford_slope_pct", "thickness_cm", "length_m"],
// BOX = 표 02 명세 키(PLAN 52-2) — 옛 날개벽 치수는 폼에서 빠져 이어 붙임(지난 정의 값)
box_culvert: ["body_width_m", "body_height_m", "body_custom", "wing_in", "wing_out"],
// 물넘이 포장 = 표 03 명세 키(PLAN 52-3 · `design_structure_ford_pavement`) — 옛 월류 · 경사 · 두께 · 길이는
// 폼에서 빠져 이어 붙임 · 도수로/돌붙임 키는 `FORM_OPTION_PREFIXES`
ford_pavement: ["ford_slope_deg"],
// 세월교 = 표 04 명세 키(PLAN 52-4 · `design_structure_ford`) — 옛 관종 · 날개벽 치수는 폼에서 빠져 이어 붙임
ford_bridge: [
"pipe_kind",
"pipe_diameter_mm",
"pipe_count",
"ford_width_m",
"ford_height_m",
...wingKeys("in"),
...wingKeys("out"),
"inlet_type",
"outlet_type",
"wing_in",
"wing_out",
],
revetment: ["side", ...revetKeys("inlet"), ...revetKeys("outlet")],
};
/** 폼이 인스턴스 번호를 붙여 적는 키 머리(명세 선택 컨테이너 · `{머리}{n}_{항목}`) — 빼면 지워짐. */
export const FORM_OPTION_PREFIXES: Readonly<Record<string, readonly string[]>> = {
pipe: ["soil_add_", "chute_add_"],
ford_pavement: ["ford_chute_"],
};
/** 독립 기슭막이 레지스트리 키 → 폼은 유입·유출 두 채널 키로 적는다. */
const REVETMENT_FIELDS = ["form", "length_m", "height_m", "before_m", "after_m"];
@@ -95,7 +97,10 @@ export function mergeFacilityOptions<T extends MergeableAttributes>(
): T {
if (!previous || previous.facility !== next.facility) return next;
const managed = new Set(FORM_OPTION_KEYS[next.facility] ?? []);
const kept = Object.entries(previous.options ?? {}).filter(([key]) => !managed.has(key));
const heads = FORM_OPTION_PREFIXES[next.facility] ?? [];
const kept = Object.entries(previous.options ?? {}).filter(
([key]) => !managed.has(key) && !heads.some((head) => key.startsWith(head)),
);
const options = { ...Object.fromEntries(kept), ...(next.options ?? {}) };
const summary =
next.summary_item === undefined && previous.summary_item !== undefined
@@ -0,0 +1,55 @@
/* =============================================================================
* B05_Profile_UI_Drainage_Revet_Choice.ts
* 관 보호공 상자 안 [연동] · [경사] 한 줄(54-30) — 반 폭 단추 둘 · 쓸 수 있는 쪽만 누를 수 있음.
* 값 = 횡단 연동 제어 옛 자리(`revet_link_detached` · `revet_follow_grade` · `design_structure_pipe_calc`) ·
* 고르면 횡단 그림이 바로 따라감. 경사를 끄면(수평) 연동은 풀 수 없음(옛 규칙 그대로).
* ========================================================================== */
import { toggleButton } from "./B05_Profile_UI_Panel_Fields";
import {
pipeRevetChoice,
setPipeRevetChoice,
} from "../A00_Common/design/design_structure_pipe_calc";
const LINK_TITLE = "옆 측점 흙막이와 횡단 자리를 함께 씀 — 끄면 측점마다 따로 잡음";
const LINK_LOCKED = "경사를 끈(수평) 동안은 연동을 풀 수 없음";
const GRADE_TITLE = "종단경사 반영 — 끄면 연장 구간 내내 같은 높이(수평)";
/** 한 줄 — `paint` 가 지금 값 · 쓸 수 있는지를 다시 칠하고 줄을 돌려줌(폼 다시 그림마다). */
export function revetChoiceRow(
chainageOf: () => number | null,
/** 쓴 뒤 — 폼을 다시 그려 유입 · 유출 두 줄을 함께 칠함. */
written: () => void,
): {
paint: (hidden: boolean) => HTMLElement;
} {
const row = document.createElement("div"); // label 이 아님 — 이름표를 눌러 첫 단추가 눌리지 않게
row.className = "b05-route__field";
const caption = document.createElement("span");
caption.textContent = "옵션";
const pair = document.createElement("div");
pair.className = "b05-structure__half-pair";
const write = (kind: "link" | "grade", on: boolean): void =>
void setPipeRevetChoice(chainageOf(), kind, on).then(written);
const link = toggleButton("연동", true, (on) => write("link", on));
const grade = toggleButton("경사", true, (on) => write("grade", on));
grade.title = GRADE_TITLE;
pair.append(link, grade);
row.append(caption, pair);
const set = (button: HTMLButtonElement, value: boolean | null, locked: boolean): void => {
button.disabled = value === null || locked;
button.classList.toggle("is-active", value === true);
button.setAttribute("aria-pressed", String(value === true));
};
function paint(hidden: boolean): HTMLElement {
const now = pipeRevetChoice(chainageOf());
const locked = now?.grade === false;
set(link, now?.linked ?? null, locked);
link.title = locked ? LINK_LOCKED : LINK_TITLE;
set(grade, now?.grade ?? null, false);
row.hidden = hidden;
return row;
}
return { paint };
}
+2 -68
View File
@@ -1,21 +1,19 @@
/* =============================================================================
* B05_Profile_UI_Page_Actions.ts
* 종단 보기의 **버튼 동작** — [경로 계산] · [저장]·[확정]에 보태는 종단 보기 몫.
* 종단 보기의 **버튼 동작** — [저장]·[확정]에 보태는 종단 보기 몫. [경로 계산]은 `Old/` 로 옮김(54-24).
*
* 종단 보기 본체(`design_view_profile`)에서 떼어냈다(700줄 제한, 2026-09-02). 화면 조립·로딩
* 순서는 본체에 남고, 여기에는 영구저장소를 건드리는 갈래만 둔다(CLAUDE.md 5장: 세션에 쌓인
* 조작은 [저장]·[확정]에서만 정본으로 나간다). [초기화]는 한 벌(`design_reset`)이 한다.
* ========================================================================== */
import { hideLoadingOverlay, showLoadingOverlay, showToast } from "@ui/ui_template_elements";
import { confirmRoute, solveRoute, type RouteLatestResponse } from "./B05_Profile_Api_Fetch";
import { confirmRoute, type RouteLatestResponse } from "./B05_Profile_Api_Fetch";
import type { DesignViewSave } from "../A00_Common/design/design_shared";
import {
invalidateSectionDetail,
saveCachedCrossPatches,
} from "../B06_Section/B06_Section_Section_Store";
import { saveCorridorIfDirty } from "./B05_Profile_UI_Corridor";
import { circlePoint, routePoint } from "./B05_Profile_UI_Page_Helpers";
import type { createRoutePanel } from "./B05_Profile_UI_Panel";
import type { createRouteProfilePanel } from "./B05_Profile_UI_Profile_Panel";
import type { createStructuresBridge } from "./B05_Profile_UI_Page_Structures";
@@ -40,70 +38,6 @@ export interface PageActionContext {
restoreSections: (routeId: number) => Promise<void>;
}
/** [경로 계산] — 마커·패널 값으로 노선을 풀고 종횡단까지 다시 받는다. */
export async function solveRouteAction(ctx: PageActionContext): Promise<void> {
const latest = ctx.latest();
const confirmedSurface = ctx.confirmedSurface();
if (!confirmedSurface || !latest) return;
const points = ctx.viewer().markers.getPoints();
if (!points.bp || !points.ep) {
showToast("BP와 EP를 지형에 배치하세요.", "error");
return;
}
const values = ctx.panel().values();
showLoadingOverlay();
try {
const solved = await solveRoute(ctx.projectId, {
filter_key: latest.surface_params.source_filter,
method: latest.surface_params.method,
smooth: latest.surface_params.smooth,
surface_model_id: confirmedSurface.model_id ?? undefined,
algorithm: values.algorithm,
bp: routePoint(points.bp),
ep: routePoint(points.ep),
cp: points.cp.map(routePoint),
ap: points.ap.map(circlePoint),
fp: points.fp.map(circlePoint),
grade_class: values.gradeClass,
paved: values.paved,
min_curve_radius_m: values.minCurveRadius,
max_uphill_grade: values.maxUphillGrade,
max_downhill_grade: values.maxDownhillGrade,
min_uphill_grade: values.minUphillGrade,
min_downhill_grade: values.minDownhillGrade,
allow_avoid_pass_through: values.allowAvoidPassThrough,
station_interval_m: values.stationInterval,
cross_half_width_m: null,
cross_sample_interval_m: values.crossSampleInterval,
long_sample_interval_m: values.longSampleInterval,
terrain_type: values.terrainType,
design_speed_kph: values.designSpeed,
max_grade_pct: values.maxGradePct,
min_vertical_radius_m: values.minVerticalRadius,
min_tangent_length_m: values.minTangentLength,
start_elevation_offset_m: values.startElevationOffset,
end_elevation_offset_m: values.endElevationOffset,
enforce_pipe_clearance: values.enforcePipeClearance,
});
// 새 경로는 측점 구성이 달라지므로 이전 상단측 변경분을 폐기한다(자동 판정 재사용).
ctx.uphillOverrides.clear();
ctx.persistUphillOverrides();
ctx.renderLatest(await ctx.loadLatest(true));
await ctx.restoreSections(solved.route_id);
if (solved.cross_section_count === null) {
showToast("경로는 저장되었지만 종횡단 생성에 실패했습니다.", "error");
} else if (solved.grade_summary === null) {
showToast("경로·종횡단은 저장되었지만 계획선 산출에 실패했습니다.", "error");
} else {
showToast("최적 경로 계산이 완료되었습니다.", "success");
}
} catch (error) {
showToast(error instanceof Error ? error.message : "경로 계산에 실패했습니다.", "error");
} finally {
hideLoadingOverlay();
}
}
/** [저장] · [확정]에 종단 보기가 보태는 몫 — 차례는 저장 한 줄기(`saveDesign`)가 정하고
* 한 벌(`design_shared`)이 두 보기 몫을 모아 한 번에 보낸다(계획서 24-2a · 24-3b). 관(배수유역도) ·
* 계획고는 한 벌 종단도가 낸다. */
@@ -90,15 +90,6 @@ export function restorePoints(latest: RouteLatestResponse): RouteDesignPoints {
};
}
export function routePoint(point: PlacedRoutePoint): RoutePoint {
// 서버 스키마는 표고를 빼면 "모름"으로 받는다 — null은 undefined로 바꿔 보낸다.
return { x: point.x, y: point.y, z: point.z ?? undefined };
}
export function circlePoint(point: PlacedRoutePoint): CirclePoint {
return { ...routePoint(point), radius_m: point.radius_m ?? 25 };
}
/** 노선 폴리라인 위 chainage 지점의 (x, y) — 세그먼트 누적 길이로 정확히 되짚는다.
* 규칙 측점(20m 간격) 사이 직선보간은 곡선 구간에서 모서리를 잘라 3D 마커가 노선을
* 벗어난다(2026-08-19 사용자 보고 — 도엽 등고선 분석 좌표와 라이다 노선의 미세 차).
@@ -68,15 +68,7 @@ export function panelValuesOf(next: RouteLatestResponse): Partial<RoutePanelValu
const options = next.route_params?.options ?? {};
return {
contourInterval: next.surface_params.contour_interval_m,
algorithm: next.route_params?.algorithm as RoutePanelValues["algorithm"] | undefined,
gradeClass: options.grade_class as RoutePanelValues["gradeClass"] | undefined,
paved: options.paved as boolean | undefined,
minCurveRadius: options.min_curve_radius_m as number | undefined,
maxUphillGrade: options.max_uphill_grade as number | undefined,
maxDownhillGrade: options.max_downhill_grade as number | undefined,
minUphillGrade: options.min_uphill_grade as number | undefined,
minDownhillGrade: options.min_downhill_grade as number | undefined,
allowAvoidPassThrough: options.allow_avoid_pass_through as boolean | undefined,
stationInterval: next.route_params?.station_interval_m ?? undefined,
crossSampleInterval: next.route_params?.cross_sample_interval_m ?? undefined,
longSampleInterval: next.route_params?.long_sample_interval_m ?? undefined,
@@ -313,15 +313,14 @@ export function createStructuresBridge(deps: StructuresBridgeDeps) {
async function loadStructures(): Promise<void> {
try {
// 레지스트리는 **한 번만** 받고 쓰는 자리에 따라 나눈다(2026-09-07).
// · 추가 메뉴 — 켜진 종류만(B05 는 종전대로 여섯 군).
// · 알약 레인·군 판정 — **전부**. B06 에서 넣은 B군(측구·맹암거 등)은 레지스트리에서
// 꺼져 있는데, 켜진 것만 주면 이름·색·군을 못 찾아 종단에 「?」 회색 알약으로 뜬다.
// · 고르기 목록 — 켜진 종류만(B05 는 종전대로 여섯 군).
// · 목록 이름 · 폼 · 알약 레인 · 군 판정 — **전부**. B06 에서 넣은 B군(측구·맹암거 등)은
// 레지스트리에서 꺼져 있는데, 켜진 것만 주면 이름을 못 찾아 영문 키 · 「?」 알약으로 뜬다.
const [allTypes, stored] = await Promise.all([
fetchStructureTypes(true),
fetchStructures(deps.projectId),
]);
const menuTypes = allTypes.filter((type) => type.enabled);
deps.panel().structures.setTypes(menuTypes);
deps.panel().structures.setTypes(allTypes, (type) => type.enabled);
deps.profilePanel().setStructureTypes(allTypes);
// A군 판정에 쓸 타입 정보 — 횡단배수만 그래프 세로선·틸팅 대상이다.
structureTypeMap = new Map(
-36
View File
@@ -31,7 +31,6 @@ import { createViewControls } from "./B05_Profile_UI_Panel_View";
export type { RoutePanelValues } from "./B05_Profile_UI_Panel_Fields";
interface PanelCallbacks {
onSolve: () => void;
/** [계획노선 편집] — 큰 모달을 열어 노선을 고친다(계산은 모달 [확인]에서만 돈다). */
onEditPlannedRoute: () => void;
onContourApply: (interval: number) => void | Promise<void>;
@@ -78,7 +77,6 @@ export function createRoutePanel(callbacks: PanelCallbacks, shared: DesignPageSh
const { viewControls, setCorridorPending } = createViewControls(callbacks);
const settings = createSettingsPart(callbacks);
const route = createRoutePart(callbacks);
const { fields: routeFields } = route;
const {
contourInterval,
gradeClass,
@@ -93,16 +91,6 @@ export function createRoutePanel(callbacks: PanelCallbacks, shared: DesignPageSh
endElevationOffset,
enforcePipeClearance,
} = settings.fields;
const {
algorithm,
paved,
avoidPass,
minCurveRadius,
maxUphillGrade,
maxDownhillGrade,
minUphillGrade,
minDownhillGrade,
} = routeFields;
// 「구조물 배치」 — 두 보기가 같은 폼 한 벌을 쓴다(계획서 24-3b). 종단 보기가 보일 때 폼 알림을
// 받는 동작만 여기서 건다. 계곡 통과 시설(A군)은 관 지점 정본(배수유역도)과 연동한다.
@@ -120,15 +108,7 @@ export function createRoutePanel(callbacks: PanelCallbacks, shared: DesignPageSh
});
const inputElements = [
algorithm,
gradeClass,
paved,
avoidPass,
minCurveRadius,
maxUphillGrade,
maxDownhillGrade,
minUphillGrade,
minDownhillGrade,
crossSampleInterval,
longSampleInterval,
designSpeed,
@@ -160,15 +140,7 @@ export function createRoutePanel(callbacks: PanelCallbacks, shared: DesignPageSh
values(): RoutePanelValues {
return {
contourInterval: Number(contourInterval.value) || 1,
algorithm: algorithm.value as RoutePanelValues["algorithm"],
gradeClass: gradeClass.value as RoutePanelValues["gradeClass"],
paved: paved.checked,
minCurveRadius: parseOptional(minCurveRadius),
maxUphillGrade: parseOptional(maxUphillGrade),
maxDownhillGrade: parseOptional(maxDownhillGrade),
minUphillGrade: parseOptional(minUphillGrade),
minDownhillGrade: parseOptional(minDownhillGrade),
allowAvoidPassThrough: avoidPass.checked,
stationInterval: STATION_INTERVAL_M,
crossSampleInterval: parseOptional(crossSampleInterval),
longSampleInterval: parseOptional(longSampleInterval),
@@ -184,15 +156,7 @@ export function createRoutePanel(callbacks: PanelCallbacks, shared: DesignPageSh
},
restore(values: Partial<RoutePanelValues>) {
if (values.contourInterval != null) contourInterval.value = String(values.contourInterval);
if (values.algorithm) algorithm.value = values.algorithm;
if (values.gradeClass) gradeClass.value = values.gradeClass;
if (values.paved != null) paved.checked = values.paved;
if (values.minCurveRadius != null) minCurveRadius.value = String(values.minCurveRadius);
if (values.maxUphillGrade != null) maxUphillGrade.value = String(values.maxUphillGrade);
if (values.maxDownhillGrade != null) maxDownhillGrade.value = String(values.maxDownhillGrade);
if (values.minUphillGrade != null) minUphillGrade.value = String(values.minUphillGrade);
if (values.minDownhillGrade != null) minDownhillGrade.value = String(values.minDownhillGrade);
if (values.allowAvoidPassThrough != null) avoidPass.checked = values.allowAvoidPassThrough;
// stationInterval은 복원하지 않는다 — 20m 고정(2026-08-18).
if (values.crossSampleInterval != null)
crossSampleInterval.value = String(values.crossSampleInterval);
@@ -9,7 +9,6 @@ import { currentLanguageIndex, ui_locales } from "@ui/ui_template_locale";
export interface RoutePanelValues {
contourInterval: number;
algorithm: "dijkstra" | "ridge_valley";
/** 임도 종류 — 현행 3종(간선·산불진화·작업). branch(지선)는 폐지됐으나 기존
* 저장분 호환을 위해 값으로는 받는다(2026-08-19). 값의 원천은 프로젝트 등록
* 정보(projects.road_type)이며 화면에서는 고르지 않는다. */
@@ -17,13 +16,6 @@ export interface RoutePanelValues {
/** 설계속도(km/h) — 임도는 속도를 낼 수 없는 노선이라 기본 20이다. 간선·산불진화만
* 20~40에서 고를 수 있고 작업임도는 20 고정(별표2, 2026-08-19 사용자 확정). */
designSpeed: 20 | 30 | 40;
paved: boolean;
minCurveRadius: number | null;
maxUphillGrade: number | null;
maxDownhillGrade: number | null;
minUphillGrade: number | null;
minDownhillGrade: number | null;
allowAvoidPassThrough: boolean;
stationInterval: number | null;
crossSampleInterval: number | null;
longSampleInterval: number | null;
+4 -76
View File
@@ -1,16 +1,14 @@
/* =============================================================================
* B05_Profile_UI_Panel_Route.ts
* 좌측 패널의 **노선 쪽 칸 재료** — 계획노선 편집 단추 · 경로 계산 설정(포인트 팔레트 · 알고리즘 ·
* 조건) · 선택 포인트 상세. 칸 틀은 `B05_Profile_UI_Panel_Sections.ts` 가 씌운다(등록부).
* 좌측 패널의 **노선 쪽 칸 재료** — 계획노선 편집 단추 · 선택 포인트 상세. 칸 틀은
* `B05_Profile_UI_Panel_Sections.ts` 가 씌운다(등록부). 「경로 계산 설정」은 `Old/` 로 옮김(54-24).
* `B05_Profile_UI_Panel.ts` 에서 떼어냈다(계획서 24-2b). 본문 로직과 수치는 그대로다.
* ========================================================================== */
import { createSelectField } from "@ui/ui_template_elements";
import type { PlacedRoutePoint, RoutePointKind } from "./B05_Profile_UI_Markers";
import { button, checkbox, numberField } from "./B05_Profile_UI_Panel_Fields";
import type { PlacedRoutePoint } from "./B05_Profile_UI_Markers";
import { button, numberField } from "./B05_Profile_UI_Panel_Fields";
export interface RoutePartCallbacks {
onSolve: () => void;
/** [계획노선 편집] — 큰 모달을 열어 노선을 고친다(계산은 모달 [확인]에서만 돈다). */
onEditPlannedRoute: () => void;
onMovePoint: () => void;
@@ -28,57 +26,6 @@ export function createRoutePart(callbacks: RoutePartCallbacks) {
plannedRouteBtn.title = "예상노선 위에서 계획노선을 고칩니다. [확인] 때만 다시 계산합니다.";
plannedRouteBtn.addEventListener("click", () => callbacks.onEditPlannedRoute());
const paletteGrid = document.createElement("div");
paletteGrid.className = "b05-route__palette";
const pointLabels: Record<RoutePointKind, string> = {
bp: "BP 시작점",
ep: "EP 종료점",
cp: "CP 경유점",
ap: "AP 회피구역",
fp: "FP 금지구역",
};
(Object.keys(pointLabels) as RoutePointKind[]).forEach((kind) => {
const chip = document.createElement("div");
chip.className = `b05-route__chip is-${kind}`;
chip.draggable = true;
chip.textContent = pointLabels[kind];
chip.addEventListener("dragstart", (event) => event.dataTransfer?.setData("pointType", kind));
paletteGrid.append(chip);
});
// 드롭다운은 공통 컴포넌트(createSelectField) 재사용. `.select`로 받아 이하 로직 불변.
const algorithmField = createSelectField({
label: "알고리즘",
options: [
{ value: "dijkstra", text: "Dijkstra" },
{ value: "ridge_valley", text: "능선·계곡" },
],
});
const algorithm = algorithmField.select;
const minCurveRadius = numberField("최소 곡선반경 (m)");
const maxUphillGrade = numberField("오르막 경사 상한 (%)");
const maxDownhillGrade = numberField("내리막 경사 상한 (%)");
const minUphillGrade = numberField("오르막 경사 하한 (%)");
const minDownhillGrade = numberField("내리막 경사 하한 (%)");
const paved = checkbox("포장 임도", false);
const avoidPass = checkbox("회피구역 통과 허용", false);
const details = document.createElement("details");
const summary = document.createElement("summary");
summary.textContent = "사용한 조건";
details.append(
summary,
minCurveRadius.wrapper,
maxUphillGrade.wrapper,
maxDownhillGrade.wrapper,
minUphillGrade.wrapper,
minDownhillGrade.wrapper,
);
// [최적 경로 계산] 입구는 2026-09-06 사용자 확정으로 화면에서 내렸다 — 평면만 보고
// 노선을 정하는 방식이라 실제 판단(평면·종단·횡단·유토곡선을 함께 봄)과 맞지 않는다.
// 코드·API 는 그대로 두고 버튼만 뺀다. 노선 변경은 계획노선 편집이 대신한다.
const solveButton = button("최적 경로 계산", callbacks.onSolve, "filled");
solveButton.hidden = true;
const selectedName = document.createElement("strong");
const radius = numberField("회피/금지 반경 (m)", "25");
radius.addEventListener("change", () => callbacks.onRadiusChange(Number(radius.value) || 1));
@@ -93,27 +40,8 @@ export function createRoutePart(callbacks: RoutePartCallbacks) {
return {
plannedRouteButton: plannedRouteBtn,
/** 「경로 계산 설정」 본문 — 화면 순서대로. */
calcNodes: [
paletteGrid,
algorithmField.root,
paved.wrapper,
avoidPass.wrapper,
details,
solveButton,
] as HTMLElement[],
/** 「선택 포인트 상세 설정」 본문 — 화면 순서대로. */
selectedNodes: [selectedName, radius.wrapper, selectedActions] as HTMLElement[],
fields: {
algorithm,
paved,
avoidPass,
minCurveRadius,
maxUphillGrade,
maxDownhillGrade,
minUphillGrade,
minDownhillGrade,
},
bindSelectedRoot(root: HTMLElement): void {
selectedRoot = root;
root.hidden = true;
+3 -20
View File
@@ -1,10 +1,10 @@
/* =============================================================================
* B05_Profile_UI_Panel_Sections.ts
* 종단 보기 좌측 패널의 **칸 정의**(등록부 `registerPanelSection`) — 페이지 설정 · 계획노선 ·
* 경로 계산 설정 · 선택 포인트 상세. 「구조물 배치」는 두 보기 공용이라 `design_sections.ts` 에 있다.
* 선택 포인트 상세. 「구조물 배치」는 두 보기 공용이라 `design_sections.ts` 에 있다.
*
* 칸 차례(2026-08-18 사용자 확정): 구조물 배치 > 페이지 설정 > 계획노선 > 경로 계산 설정(비활성)
* > 선택 포인트(평소 숨김) > 아래 고정 영역. 재료는 `_Panel_Settings` · `_Panel_Route` 가 만들어
* 칸 차례(2026-08-18 사용자 확정): 구조물 배치 > 페이지 설정 > 계획노선
* > 선택 포인트(평소 숨김) > 아래 고정 영역. 「경로 계산 설정」은 `Old/` 로 옮김(54-24). 재료는 `_Panel_Settings` · `_Panel_Route` 가 만들어
* `ctx.parts` 로 건넨다.
* ========================================================================== */
@@ -37,23 +37,6 @@ registerPanelSection({
},
});
registerPanelSection({
id: "route-calc",
title: "경로 계산 설정",
views: ["profile"],
order: 40,
build: (ctx, view) => {
const frame = createSectionFrame(view, "경로 계산 설정", true);
frame.body.append(...part<RoutePart>(ctx, "route").calcNodes);
// 경로 계산 설정 — 사용여부 미결정으로 조작 불가(숨기지 않는다, 2026-08-18 사용자
// 지시). inert가 본문 전체 입력·드래그를 막고, is-disabled가 흐림을 그린다.
// 제목 클릭(접기/펼치기)은 본문 밖이라 그대로 산다.
frame.root.classList.add("is-disabled");
frame.body.inert = true;
return frame.root;
},
});
registerPanelSection({
id: "selected-point",
title: "선택 포인트 상세 설정",
+23 -13
View File
@@ -33,19 +33,29 @@ export function createViewControls(callbacks: ViewControlCallbacks): {
(["iso", "top", "front", "side"] as const).forEach((preset) =>
viewButtons.append(button(preset.toUpperCase(), () => callbacks.onView(preset), "glass")),
);
// 직교/원근 전환(2026-09-04 사용자 지시) — 기본은 원근이고, 단추 글자는 **바뀔 쪽**을
// 가리킨다(누르면 그쪽으로 간다).
let projection: "perspective" | "ortho" = "perspective";
const projectionButton = button(
"직교로",
() => {
projection = projection === "perspective" ? "ortho" : "perspective";
projectionButton.textContent = projection === "perspective" ? "직교로" : "원근으로";
callbacks.onProjection(projection);
},
"glass",
);
viewButtons.append(projectionButton);
// 원근·직교 두 단추 — 지금 켜진 쪽을 강조한다. 기본은 직교(카메라 기본과 같음).
const projectionButtons = (
[
["perspective", "원근"],
["ortho", "직교"],
] as const
).map(([kind, label]) => {
const element = button(
label,
() => {
projectionButtons.forEach(({ kind: other, element: el }) => {
el.classList.toggle("is-active", other === kind);
el.setAttribute("aria-pressed", String(other === kind));
});
callbacks.onProjection(kind);
},
"glass",
);
element.classList.toggle("is-active", kind === "ortho");
element.setAttribute("aria-pressed", String(kind === "ortho"));
return { kind, element };
});
viewButtons.append(...projectionButtons.map(({ element }) => element));
const visibilityButtons = document.createElement("div");
visibilityButtons.className = "b05-route__view-group";
visibilityButtons.append(
@@ -18,7 +18,8 @@ export interface CrossPreviewContext {
detail: () => SectionDetailResponse | null;
routeId: () => number | null;
edits: () => AlignmentEdits;
debounceMs: number;
/** 부를 때마다 읽음 — 보기마다 다름. */
debounceMs: () => number;
/** 반영이 끝난 뒤 다시 그린다 — 다시 계산한 측점 누가거리를 넘긴다(횡단 카드 갱신용). */
onApplied: (updated: number[]) => void;
}
@@ -61,7 +62,7 @@ export function createCrossPreview(ctx: CrossPreviewContext): CrossPreview {
.catch(() => {
/* 프리뷰 실패는 무시 — 화면의 계획선은 그대로 두고 다음 편집에서 다시 시도한다. */
});
}, ctx.debounceMs);
}, ctx.debounceMs());
},
dispose() {
window.clearTimeout(timer);
@@ -52,6 +52,7 @@ import {
import { irregularStationId, type IrregularStation } from "./B05_Profile_UI_IrregularStations";
import { mountStructureMenu } from "./B05_Profile_UI_Profile_Structures";
import { buildStructureLane, STRUCTURE_LANE_HEIGHT_PX } from "./B05_Profile_UI_Structures_Marks";
import { pipeExtraCount } from "../A00_Common/design/design_structure_pipe_calc";
import type { StructureInstance, StructureType } from "./B05_Profile_Api_Structures";
import type { RouteProfilePanelCallbacks } from "./B05_Profile_UI_Profile_Panel";
@@ -335,6 +336,11 @@ export function renderProfile(ctx: ProfileRenderContext): void {
ctx.redraw();
},
onMove: (structureId, toChainage) => callbacks?.onStructureMarkMove?.(structureId, toChainage),
// 라벨 흙막이 상자 수 = 폼과 같은 유출 단 수(54-1 · 54-14)
containerCount: (structure) =>
structure.type_id === "pipe"
? (id) => (id === "soil_add" ? pipeExtraCount(structure.chainage_m ?? null) : undefined)
: undefined,
});
// 세로 창 갱신기 — 가로로 스크롤할 때마다 패널이 이것을 부른다. 도형은 그대로 두고
// 겹 하나의 변환만 갈아 끼우므로 매 프레임 불러도 된다(2026-09-04 사용자 확정).
@@ -17,6 +17,7 @@ import {
} from "./B05_Profile_UI_IrregularStations";
import { structureAnchorM, type StructureInstance } from "./B05_Profile_Api_Structures";
import { GROUP_LABELS } from "./B05_Profile_UI_Structures_Panel";
import { isPickHidden } from "./B05_Profile_UI_Structures_Panel_Types";
/** 우클릭 메뉴용 최소 타입 정보 — 사이드 「구조물 배치」 종류 목록과 같은 원천. */
export interface StructureMenuType {
@@ -32,10 +33,11 @@ export function structureGroupMenuItems(
types: ReadonlyArray<StructureMenuType>,
onPick: (typeId: string) => void,
): MapContextMenuItem[] {
const groups = [...new Set(types.map((type) => type.group))];
const pickable = types.filter((type) => !isPickHidden(type));
const groups = [...new Set(pickable.map((type) => type.group))];
return groups.map((group) => ({
label: GROUP_LABELS[group] ?? group,
children: types
children: pickable
.filter((type) => type.group === group)
.map((type): [string, () => void] => [type.name, () => onPick(type.type_id)]),
}));
@@ -142,12 +144,39 @@ export function structureIdAtStation(
if (!stationId.startsWith(prefix)) return null;
const station = stations.find((entry) => irregularStationId(entry.id) === stationId);
if (!station) return null;
const hit = structures.find(
const near = structures.filter(
(item) => Math.abs(structureAnchorM(item) - station.chainage_m) < SAME_CHAINAGE_M,
);
// 관 측점선의 짝은 관 알약(`pipe-*`)이다 — 같은 측점 다른 구조물(포장 등)을 켜면 그 알약을
// 누를 때 해제로 읽혀 안 골라졌다(52-15).
const hit = near.find((item) => String(item.structure_id ?? "").startsWith("pipe-")) ?? near[0];
return hit?.structure_id ?? null;
}
/** 측점선이 골라질 때 켤 알약 — 지금 고른 알약이 그 측점 자리면 그대로 둔다(같은 측점
* 여럿 · 24-6b). 규칙 측점(B06 카드)도 기준점 누가거리로 맞춰 본다 — 안 보면 카드가 켜지며
* 고른 구조물 알약이 꺼졌다(53-2). */
export function structureIdKeeping(
stationId: string | null,
selectedId: string | null,
stations: IrregularStation[],
structures: StructureInstance[],
detail: {
longitudinal: { stations: ReadonlyArray<{ station_id: string; chainage_m: number }> };
} | null,
): string | null {
const selected = structures.find((item) => item.structure_id === selectedId);
const at = detail?.longitudinal.stations.find(
(entry) => entry.station_id === stationId,
)?.chainage_m;
const keeps =
stationId !== null &&
!!selected &&
(stationIdAtStructure(selectedId, stations, structures) === stationId ||
(at !== undefined && Math.abs(structureAnchorM(selected) - at) < SAME_CHAINAGE_M));
return keeps ? selectedId : structureIdAtStation(stationId, stations, structures);
}
/** 알약(구조물) id → 측점선 id. 세로선이 없는 구조물(A군 외)이면 null. */
export function stationIdAtStructure(
structureId: string | null,
+3 -3
View File
@@ -23,8 +23,8 @@ export interface SelectionSyncPorts {
setSyncing: (value: boolean) => void;
/** 3D 뷰어 마커 선택. */
selectMarker: (stationId: string | null) => void;
/** 종단 그래프 세로선 선택. */
selectGraph: (stationId: string | null) => void;
/** 종단 그래프 세로선 선택 — 누가거리는 세로선 없는 시설(물넘이포장)의 알약을 켜는 데 씀. */
selectGraph: (stationId: string | null, chainageM?: number | null) => void;
/** 좌측 구조물 폼 선택(누가거리 기준). */
selectSidebar: (chainageM: number | null) => void;
/** 배수유역도 세부유역 강조(누가거리 기준). */
@@ -98,7 +98,7 @@ export function createSelectionSync(ports: SelectionSyncPorts): SelectionSync {
ports.setSyncing(true);
try {
ports.selectMarker(id);
ports.selectGraph(id);
ports.selectGraph(id, chainageM);
// 투영 측점이 아직 없어도(방금 넣은 임시 관 — 재계산 전) 누가거리는 그대로
// 넘긴다. null을 넘기면 사이드가 "해제"로 받아 임시 배치를 스스로 취소한다
// (2026-08-18 임시 배치 자기 삭제 버그).
@@ -88,7 +88,8 @@ export function restoreStructurePick(
selectStation(handoff.at);
// 구조물 id 가 적혀 있을 때만 구조물로 연다 — 관 목록이 아직 안 실렸을 때 측점만으로 구조물을
// 짐작하면 그 측점을 덮는 다른 구조물이 열린다(관은 목록이 실릴 때 위 `selectStation` 이 연다).
if (!structures.hasSelection() && handoff.structureId) {
// id 가 있으면 측점이 연 관보다 먼저다(resolveSelection ① · 53-1)
if (handoff.structureId) {
structures.selectAt({ chainageM: handoff.at, structureId: handoff.structureId });
}
return structures.hasSelection();
@@ -0,0 +1,131 @@
/* =============================================================================
* B05_Profile_UI_Structures_Balloon.ts
* 종단 구조물 알약 정보 라벨 줄(54-14) — 화면 요소 없는 순수 규칙. B05 · B06 알약 레인이 같이 씀.
*
* · 2행 — 1행 = 종류 이름(기타 = 손 이름) + 기준 측점(구간 = 시작 ~ 끝) · 2행 = 컨테이너마다 첫 옵션
* 값만 「 · 」 로 이음(제목 · 옵션 이름 없음 · 빈 값은 건너뜀) · 값이 하나도 없으면 1행만 · 메모 · 그 밖 옵션은 안 씀
* · 컨테이너 = 좌측 패널 폼과 같은 상자 — 명세 종류(`STRUCTURE_SPECS`)는 명세 컨테이너(선택 컨테이너는
* 인스턴스마다) · 그 밖 종류는 정의 옵션 그룹(`StructureType.groups`)
* · 첫 옵션 = 지금 보이는 첫 입력 칸(자동 칸 · 갈래가 없어 가린 칸 · 끈 칸은 건너뜀)
* · 값 `auto` = 「(자동)」 · 빈 값은 건너뜀(기본값으로 안 바꿈 · 기본값은 새 구조물 칸에 실제 값)
* ========================================================================== */
import type { StructureInstance, StructureType } from "./B05_Profile_Api_Structures";
import { STRUCTURE_SPECS } from "../A00_Common/design/design_structure_pipe";
import { bodyOf, boxOptionsIn } from "../A00_Common/design/design_structure_box";
import { withLegacyGuards } from "../A00_Common/design/design_structure_ford";
import {
branchOf,
choiceLabel,
choicesOf,
readState,
type Instance,
type SpecContainer,
type SpecItem,
type StructureSpec,
} from "../A00_Common/design/design_structure_spec";
const AUTO_MARK = "(자동)";
const SEP = " · ";
/** 선택 컨테이너 개수를 밖에서 정함(배관 흙막이 = 유출 단 수 · 폼 `hooks.count` 와 같은 값). */
export type ContainerCount = (containerId: string) => number | null | undefined;
/** 라벨 줄 — [이름 기준 측점, 컨테이너 값 이음?]. */
export function balloonLines(
structure: StructureInstance,
type: StructureType | undefined,
head: { name: string; position: string },
count?: ContainerCount,
): string[] {
const spec = STRUCTURE_SPECS[structure.type_id];
const values = (
spec ? specLines(spec, structure, type, count) : groupLines(structure.options ?? {}, type)
).filter(Boolean);
const first = `${head.name} ${head.position}`;
return values.length ? [first, values.join(SEP)] : [first];
}
/** 명세 컨테이너 값 — 폼(`Drainage_Facility.setFacility` · `paintStructureSpec`)과 같은 값 · 이름(빈 값 = ""). */
function specLines(
spec: StructureSpec,
structure: StructureInstance,
type: StructureType | undefined,
count?: ContainerCount,
): string[] {
let names = type?.spec_names ?? {};
if (structure.type_id === "pipe") {
// 정의 파일의 옛 이름 「흙막이 추가」 — 명세 이름 「흙막이」가 앞섬(54-1)
const { soil_add: _old, ...pipeNames } = names;
names = pipeNames;
}
const state = formState(spec, structure.type_id, structure.options ?? {});
return spec.containers.flatMap((c) =>
instancesOf(c, state[c.id] ?? [], count).map((values) => {
const item = c.items.find(
(entry) => entry.kind !== "auto" && (!entry.by || branchOf(entry, values)),
);
return item ? specValue(c, item, values, names) : "";
}),
);
}
/** 저장 값 → 폼 칸 값 — 폼(`Drainage_Facility.setFacility`)과 같은 손질(BOX 옛 설치 · 본체 규격 ·
* 세월교 옛 날개벽). */
function formState(
spec: StructureSpec,
typeId: string,
options: Record<string, string | number>,
): Record<string, Instance[]> {
const input =
typeId === "box_culvert"
? boxOptionsIn(options)
: typeId === "ford_bridge"
? withLegacyGuards(options)
: options;
const state = readState(spec, input);
// 본체 규격은 저장 안 함 — 폭 · 높이로 되찾음
if (typeId === "box_culvert") state.body = [{ ...state.body?.[0], ...bodyOf(options) }];
return state;
}
/** 보이는 인스턴스 — 필수 = 한 벌 · 선택 = 개수가 정해졌으면 그 수(모자라면 빈 인스턴스) · 아니면 저장된 것. */
function instancesOf(c: SpecContainer, list: Instance[], count?: ContainerCount): Instance[] {
if (c.required) return [list[0] ?? {}];
const n = count?.(c.id);
return n === undefined || n === null
? list
: Array.from({ length: n }, (_, index) => list[index] ?? {});
}
function specValue(
c: SpecContainer,
item: SpecItem,
values: Instance,
names: Record<string, string>,
): string {
const shown = (raw: string): string => {
const choice = choicesOf(item, values).find((ch) => ch.value === raw);
return choice ? choiceLabel(c, item, choice, names) : raw;
};
const raw = (values[item.id] ?? "").trim();
if (raw === "auto") return AUTO_MARK;
return raw ? shown(raw) : "";
}
/** 정의 옵션 그룹 값 — 그룹마다 첫 옵션(정의에 있고 켜진 칸 · 빈 값 = ""). */
function groupLines(
options: Record<string, string | number>,
type: StructureType | undefined,
): string[] {
const byKey = new Map((type?.options ?? []).map((option) => [option.key, option]));
return (type?.groups ?? []).map((group) => {
const option = group.options
.map((key) => byKey.get(key))
.find((entry) => entry && entry.visible !== false && entry.enabled !== false);
if (!option) return "";
const raw = options[option.key];
if (raw === "auto") return AUTO_MARK;
return raw !== undefined && raw !== "" ? `${raw}${option.unit ?? ""}` : "";
});
}
@@ -0,0 +1,239 @@
/* =============================================================================
* B05_Profile_UI_Structures_Define.ts
* 구조물 정의 → 「구조물 배치」 칸 모양 (PLAN 48-3 · 48-4) — 화면 요소 없는 순수 규칙.
*
* 정의(`resources/master_template/구조물정의.json` · GET /structure-types 가 실어 줌)를 읽어
* 칸 차례 · 격자 · 안 씀 · 규칙(상위 값 → 하위 선택지 · 보이기 · 기본값)을 낸다. 틀 =
* `docs/raw/M02_구조물옵션정의/정의_틀.md`. 선택지를 줄이면(숨김) 옛 값은 그 값만 남겨 보임.
* 그리기는 `_Structures_Panel_Options`(레지스트리 칸) · `_Structures_Define_Form`(시설 폼 칸).
* 값에 따른 계산 · 연동 제어는 여기 없음(48-5).
* import 없음 — 시험이 이 파일만 옮겨 돌림.
* ========================================================================== */
/** 정의가 옵션 하나에 실어 주는 몫 — 칸 그리기가 쓰는 것만. */
export interface DefinedOption {
key: string;
label: string;
input: string;
choices: string[];
default: string | number | null;
visible?: boolean;
/** 거짓 = 「안 씀」(정의 틀 3장) — 칸을 안 그림 · 옛 값은 그대로 남음. */
enabled?: boolean;
}
/** 상위 → 하위 규칙 한 줄(정의 `규칙`) — 상위 칸 값이 `만약.값들` 중 하나면 하위 칸에 `그러면` 을 씀. */
export interface DefinedRule {
종류?: string;
만약: { 옵션: string; 값들: Array<string | number> };
그러면: {
옵션: string;
/** 하위 칸 선택지를 이 목록으로 좁힘. */
선택지?: string[];
/** 하위 칸을 보이거나 가림. */
보이기?: boolean;
/** 상위 값이 바뀌어 이 줄이 걸리면 하위 칸 값을 이 값으로. */
기본값?: string | number | null;
};
}
/** 배치 격자 한 칸 — 정의 `배치` 의 `{줄, 칸, 너비}`(1부터). */
export interface DefinedSpot {
줄?: number;
칸?: number;
너비?: number;
}
export interface DefinedType {
options: DefinedOption[];
/** 종류 덧칸 — 기준 측점 칸 보임(기본 보임). */
show_anchor?: boolean;
/** 옵션 키 → 배치 칸. 비면 정의 옵션 차례대로 2열. */
spots?: Record<string, DefinedSpot> | null;
rules?: DefinedRule[] | null;
}
/** 칸 하나의 지금 모양 — 규칙을 건 뒤. */
export interface OptionState {
visible: boolean;
choices: string[];
}
const whole = (n: unknown): number | null =>
typeof n === "number" && Number.isInteger(n) && n >= 1 ? n : null;
/** 그릴 옵션 차례 — 배치가 있으면 (줄, 칸) 차례 · 없는 칸은 뒤에 정의 차례로. 안 씀 · 숨김은 뺌. */
export function orderedOptions<T extends DefinedOption>(type: {
options: T[];
spots?: Record<string, DefinedSpot> | null;
}): T[] {
const spots = type.spots ?? {};
const rank = (key: string): [number, number] => {
const spot = spots[key];
return [whole(spot?.줄) ?? Infinity, whole(spot?.칸) ?? Infinity];
};
return type.options
.map((option, index) => ({ option, index, at: rank(option.key) }))
.filter(({ option }) => option.enabled !== false && option.visible !== false)
.sort((a, b) => a.at[0] - b.at[0] || a.at[1] - b.at[1] || a.index - b.index)
.map(({ option }) => option);
}
/** 한 줄 칸 수 — 배치가 쓰는 가장 오른쪽 칸(1 ~ 6) · 배치 없으면 2. */
export function columnsOf(type: { spots?: Record<string, DefinedSpot> | null }): number {
let widest = 0;
for (const spot of Object.values(type.spots ?? {})) {
const col = whole(spot.칸) ?? 1;
widest = Math.max(widest, col + (whole(spot.너비) ?? 1) - 1);
}
return widest ? Math.min(Math.max(widest, 2), 6) : 2;
}
/** 칸 하나의 CSS 격자 자리 — 배치 없으면 null(흐름대로). */
export function gridPlace(
spot: DefinedSpot | undefined,
columns: number,
): { row: string; column: string } | null {
if (!spot) return null;
const row = whole(spot.줄);
const col = whole(spot.칸);
const span = Math.min(whole(spot.너비) ?? 1, columns);
return {
row: row ? String(row) : "",
column: col ? `${Math.min(col, columns)} / span ${span}` : `span ${span}`,
};
}
/** 기준 측점 칸을 보일지 — 정의가 끈 때만 가림. */
export function showsAnchor(type: { show_anchor?: boolean }): boolean {
return type.show_anchor !== false;
}
const same = (a: unknown, b: unknown): boolean => String(a ?? "") === String(b ?? "");
/** 규칙을 지금 값에 건 칸 모양 — 걸린 줄의 선택지 · 보이기가 정의 기본을 덮음(뒤 줄이 이김). */
export function ruleStates(
type: DefinedType,
values: Record<string, string | number | undefined>,
): Map<string, OptionState> {
const states = new Map<string, OptionState>();
for (const option of type.options)
states.set(option.key, { visible: true, choices: [...option.choices] });
for (const rule of type.rules ?? []) {
const state = states.get(rule.그러면.옵션);
// 가려진 상위 칸에 매인 줄은 안 걸림 — 가림이 사슬로 이어짐(정의 차례대로 적용)
if (!state || states.get(rule.만약.옵션)?.visible === false) continue;
if (!hits(rule, values)) continue;
const pick = rule.그러면.선택지;
if (pick) state.choices = pick.filter((c) => state.choices.includes(c));
if (typeof rule.그러면.보이기 === "boolean") state.visible = rule.그러면.보이기;
}
return states;
}
const hits = (rule: DefinedRule, values: Record<string, unknown>): boolean =>
rule.만약.값들.some((value) => same(value, values[rule.만약.옵션]));
/** 상위 값이 바뀌었을 때 하위 칸에 넣을 기본값 `{하위 키: 값}` — 걸린 줄 중 기본값이 있는 것만. */
export function ruleDefaults(
type: DefinedType,
parent: string,
values: Record<string, string | number | undefined>,
): Record<string, string | number> {
const out: Record<string, string | number> = {};
for (const rule of type.rules ?? []) {
const value = rule.그러면.기본값;
if (rule.만약.옵션 !== parent || value === undefined || value === null) continue;
if (hits(rule, values)) out[rule.그러면.옵션] = value;
}
return out;
}
/** 지금 정의에 없는 키의 값 — 「지난 정의 값」 읽기만 칸으로 보임. `known` = 폼이 아는 키 전부. */
export function staleValues(
values: Record<string, string | number> | undefined,
known: Iterable<string>,
): Array<[string, string | number]> {
const keys = new Set(known);
return Object.entries(values ?? {}).filter(([key]) => !keys.has(key));
}
/** 그룹 형상 칸(정의 틀 4장) — 길이 · 높이 · 기준 측점 전 · 후 마다 받기 켬끔 + 뜻. */
export type ShapeName = "길이" | "높이" | "전" | "후";
export const SHAPE_FIELDS: ReadonlyArray<{ name: ShapeName; suffix: string; label: string }> = [
{ name: "길이", suffix: "length_m", label: "길이 (m)" },
{ name: "높이", suffix: "height_m", label: "높이 (m)" },
{ name: "전", suffix: "before_m", label: "기준측점 전 (m)" },
{ name: "후", suffix: "after_m", label: "기준측점 후 (m)" },
];
export type DefinedShape = Partial<Record<ShapeName, { 받기?: boolean; 뜻?: string }>>;
/** 그룹 형상 값 저장 키 — 구조물 옵션에 `{그룹 id}__{칸}` 으로 둠. */
export const shapeKey = (groupId: string, suffix: string): string => `${groupId}__${suffix}`;
/** 그룹이 받는 형상 칸 — 받기 켠 것만 정해진 차례로. */
export function shapeFields(
shape: DefinedShape | undefined,
): Array<{ suffix: string; label: string; meaning: string }> {
return SHAPE_FIELDS.filter((f) => shape?.[f.name]?.받기 === true).map((f) => ({
suffix: f.suffix,
label: f.label,
meaning: shape?.[f.name]?.뜻 ?? "",
}));
}
/** 정의 한 벌(GET /m02/structure-definition) 중 화면이 쓰는 칸. */
export interface StructureDefinition {
판?: number;
구조물군?: Record<string, string>;
종류?: Record<string, { 기준측점?: boolean; 동작?: string[]; 이름?: Record<string, string> }>;
그룹?: Record<string, Array<{ id: string; 이름?: string; 형상?: DefinedShape }>>;
배치?: Record<string, Record<string, DefinedSpot>>;
규칙?: DefinedRule[];
}
/** 종류 목록에 정의 덧칸을 얹음 — 구조물군 이름 · 기준 측점 · 동작 · 배치 · 규칙 · 그룹 형상.
* 정의를 못 받았으면(null) 그대로 — 지금 화면과 같음. */
export function withDefinition<
T extends { type_id: string; group: string; groups?: Array<{ id: string }> },
>(types: T[], definition: StructureDefinition | null): T[] {
if (!definition) return types;
return types.map((type) => {
const kind = definition.종류?.[type.type_id] ?? {};
const shapes = new Map((definition.그룹?.[type.type_id] ?? []).map((g) => [g.id, g.형상]));
return {
...type,
group_name: definition.구조물군?.[type.group],
show_anchor: kind.기준측점,
behaviors: kind.동작 ?? [],
spec_names: kind.이름 ?? {},
spots: definition.배치?.[type.type_id] ?? null,
rules: (definition.규칙 ?? []).filter((rule) => rule.종류 === type.type_id),
...(type.groups
? { groups: type.groups.map((g) => ({ ...g, shape: shapes.get(g.id) })) }
: {}),
};
});
}
/** 대피로(표 07 · PLAN 52-7) — 옛 대피 종류는 고르기 목록에서 빼고 대피로 + 상세로 읽음.
* 옛 기록은 고치기 전까지 옛 종류 그대로(도면 · 집계 그대로) · 고치면 대피로로 저장 · 옛 칸 값은 남음. */
export const ROAD_TYPE = "evac_road";
export const ROAD_DETAILS: Readonly<Record<string, string>> = {
refuge: "대피소",
work_yard: "정차/작업장",
turnaround: "차돌림곳",
};
/** 고르기 목록에 낼 종류인지 — 옛 대피 종류만 뺌. */
export const pickable = (type: { type_id: string }): boolean => !ROAD_DETAILS[type.type_id];
/** 옛 대피 종류 기록 → 대피로 + 상세(옛 값 그대로 · 상세만 채움). 다른 기록은 그대로. */
export function asRoad<T extends { type_id: string; options?: Record<string, string | number> }>(
record: T,
): T {
const detail = ROAD_DETAILS[record.type_id];
return detail
? { ...record, type_id: ROAD_TYPE, options: { detail, ...record.options } }
: record;
}
@@ -0,0 +1,88 @@
/* =============================================================================
* B05_Profile_UI_Structures_Define_Form.ts
* 손코딩 시설 폼(동작 「계곡통과시설」)에 정의를 붙임(PLAN 48-3 · 48-4) — 숨긴 선택지 · 규칙.
*
* · 칸은 `labeled(..., 옵션키)` 가 붙인 `data-option-keys` 표식으로 찾음(키 하나인 칸만) · 찾는 자리 =
* 폼 본문 전체(그룹 상자로 옮겨 간 칸까지).
* · 칸 배치 · 이름은 손코딩 그대로(동작이 그림) — 안 씀은 끈 옵션과 같은 길(`_Drainage_Facility_Hidden`).
* · 선택지 = 정의 · 규칙 선택지 — 새 선택지는 보기를 더하고 밖 보기는 `hidden` 으로만 가림(옛 값은 그대로).
* 여러 키를 함께 적는 칸(유입구 구조 · 본체 규격)은 키 하나 표식이 아니라 안 건드림.
* · 규칙이 가린 칸 = `is-rule-hidden`(끈 옵션 표식 `is-option-hidden` 과 따로).
* ========================================================================== */
import type { StructureType } from "./B05_Profile_Api_Structures";
import { ruleDefaults, ruleStates } from "./B05_Profile_UI_Structures_Define";
import { isOptionVisible } from "./B05_Profile_UI_Structures_Summary";
/** 시설 폼이 가릴 옵션 키 — 「구조물 옵션 보이기」에서 끈 것 + 정의 「안 씀」. */
export function hiddenOptionKeys(type: StructureType | null): string[] {
return (type?.options ?? []).filter((o) => !isOptionVisible(o)).map((o) => o.key);
}
export interface FacilityDefinition {
/** 지금 종류 정의로 칸 모양을 맞춤 — 시설 폼을 채운 뒤마다 부름. */
apply: (type: StructureType | null) => void;
}
export function createFacilityDefinition(root: HTMLElement): FacilityDefinition {
let type: StructureType | null = null;
const wrapOf = (key: string): HTMLElement | null =>
[...root.querySelectorAll<HTMLElement>("[data-option-keys]")].find(
(node) => node.dataset.optionKeys === key,
) ?? null;
const controlOf = (key: string): HTMLInputElement | HTMLSelectElement | null =>
wrapOf(key)?.querySelector<HTMLInputElement | HTMLSelectElement>("select, input") ?? null;
const values = (): Record<string, string> =>
Object.fromEntries((type?.options ?? []).map((o) => [o.key, controlOf(o.key)?.value ?? ""]));
const paint = (): void => {
if (!type) return;
const states = ruleStates(type, values());
for (const option of type.options) {
const wrap = wrapOf(option.key);
const state = states.get(option.key);
if (!wrap || !state) continue;
wrap.classList.toggle("is-rule-hidden", !state.visible);
const control = controlOf(option.key);
if (!(control instanceof HTMLSelectElement)) continue;
// 정의에 새로 든 선택지는 보기를 더하고, 정의 · 규칙 밖 보기는 가림(빈 보기 · 지금 값은 그대로)
const have = new Set([...control.options].map((item) => item.value));
for (const choice of state.choices)
if (!have.has(choice))
control.add(new Option(type.spec_names?.[`${option.key}=${choice}`] ?? choice, choice));
for (const item of control.options) {
item.hidden =
!!item.value && !state.choices.includes(item.value) && item.value !== control.value;
}
}
};
// 상위 칸이 바뀌면 걸린 규칙의 기본값을 하위 칸에 넣고, 그 칸의 change 로 폼 반영(시설 폼 emit)을 잇는다.
root.addEventListener("change", (event) => {
if (!type) return;
const key = (event.target as HTMLElement).closest<HTMLElement>("[data-option-keys]")?.dataset
.optionKeys;
if (key) {
for (const [child, value] of Object.entries(ruleDefaults(type, key, values()))) {
const control = controlOf(child);
if (!control || control.value === String(value)) continue;
control.value = String(value);
control.dispatchEvent(new Event("change", { bubbles: true }));
}
}
paint();
});
return {
apply(next) {
type = next;
root
.querySelectorAll(".is-rule-hidden")
.forEach((node) => node.classList.remove("is-rule-hidden"));
root
.querySelectorAll<HTMLOptionElement>("option[hidden]:not([data-pick-hidden])")
.forEach((o) => (o.hidden = false));
paint();
},
};
}
+21 -18
View File
@@ -8,24 +8,15 @@
* ========================================================================== */
import { chainageToStation, stationToChainage } from "./B05_Profile_Util_Station";
import { DEFAULT_BASIN_SHAPE } from "../B06_Section/B06_Section_UI_Cross_Culvert_Basin";
export function field(
labelText: string,
input: HTMLElement,
basis?: string | null,
): HTMLLabelElement {
export function field(labelText: string, input: HTMLElement): HTMLLabelElement {
const wrapper = document.createElement("label");
wrapper.className = "b05-route__field";
const caption = document.createElement("span");
caption.textContent = labelText;
// 칸 밑 근거 글(`default_basis`)은 [?] 설명서 `구조물_<종류>.md` 로 옮김(54-2)
wrapper.append(caption, input);
// 칸 밑 근거 한 줄 — 등록부 `default_basis`(기본값의 뜻 · 10-A 2026-09-14 사용자 확정).
if (basis) {
const note = document.createElement("small");
note.className = "b05-structure__basis";
note.textContent = basis;
wrapper.append(note);
}
return wrapper;
}
@@ -63,19 +54,29 @@ interface OptionShape {
/**
* 등록부 옵션 입력 한 칸 — **받은 값만 칸에 넣음**. 새 구조물은 부르는 쪽이 등록부 기본값을 값으로
* 실어 줌(PLAN 46-7 · 제안값 단추 없음) · 옛 기록의 빈 칸은 빈 칸 그대로(미확정).
* 고르기 칸은 늘 빈 보기를 둠 — 첫 보기를 미리 고르지 않음.
* 필수 · 기본값 있는 고르기 칸 = 빈 보기 없음(54-43 · 빈 옛 값은 기본값 · 없으면 첫 보기) ·
* 그 밖 고르기 칸 = 빈 글 빈 보기.
*/
export function optionControl(
option: OptionShape,
stored: string | number | undefined,
/** 선택지 보일 글(정의 이름 표 · 52-12) — 값은 그대로 */
label: (choice: string) => string = (c) => c,
): HTMLInputElement | HTMLSelectElement {
const value = stored === undefined || stored === null ? "" : String(stored);
// 툴팁 — 표가 아직 안 읽는 칸이면 그 사유가 먼저(넣어도 안 바뀜을 알아야 함), 아니면 비울 때의 뜻.
const tip = option.not_in_table ?? option.empty_means ?? "";
if (option.input === "select") {
const blank = option.required ? "— 선택 —" : "— 안 정함 —";
const element = select([["", blank], ...option.choices.map((c) => [c, c] as [string, string])]);
element.value = value;
const fallback = option.default === null || option.default === "" ? "" : String(option.default);
const must = !!option.required || fallback !== "";
// 정의에서 뺀 선택지(48)를 고른 옛 값 — 그 값만 남겨 보임(값을 잃지 않음)
const kept = value && !option.choices.includes(value) ? [value] : [];
const element = select([
...(must ? [] : [["", ""] as [string, string]]),
...[...option.choices, ...kept].map((c) => [c, label(c)] as [string, string]),
]);
element.value = value || fallback;
if (element.selectedIndex < 0) element.selectedIndex = 0;
if (tip) element.title = tip;
return element;
}
@@ -83,7 +84,6 @@ export function optionControl(
option.input === "number" ? numberInput("0.1", "0") : document.createElement("input");
if (option.input !== "number") element.type = "text";
element.value = value;
element.placeholder = option.required ? "필수 입력" : "";
if (tip) element.title = tip;
const limit = option.warn_above;
if (typeof limit === "number") {
@@ -103,11 +103,14 @@ export function optionControl(
export function optionDefaults(
options: ReadonlyArray<{ key: string; default: string | number | null }>,
): Record<string, string | number> {
return Object.fromEntries(
const values: Record<string, string | number> = Object.fromEntries(
options
.filter((option) => option.default !== null && option.default !== "")
.map((option) => [option.key, option.default as string | number]),
);
// 배관 집수정 모양도 실제 값으로(54-39 · 54-36 기본 · 자동 배치 짝 `_apply_new_defaults`)
if (values.inlet_type === "집수정") values.inlet_structure ??= DEFAULT_BASIN_SHAPE;
return values;
}
/** 측점번호 + 잔여거리 두 칸 묶음. */
+32 -12
View File
@@ -24,14 +24,17 @@ import {
import { createFacilityOptionsForm } from "./B05_Profile_UI_Drainage_Facility";
import { buildSummaryRow, type SummaryRow } from "./B05_Profile_UI_Structures_Summary_Row";
import { createGroupBoxes, type GroupBoxes } from "./B05_Profile_UI_Structures_Groups";
import {
createFacilityDefinition,
type FacilityDefinition,
} from "./B05_Profile_UI_Structures_Define_Form";
import { createStructureSpecForm } from "./B05_Profile_UI_Structures_Spec";
export interface StructuresFormElements {
root: HTMLElement;
body: HTMLElement;
groupSelect: HTMLSelectElement;
typeSelect: HTMLSelectElement;
/** 「제원·수량은 다른 화면이 냅니다」 안내 한 줄 — `design_owner` 가 있을 때만 보인다. */
ownerNote: HTMLElement;
startFields: StationFields;
anchorFields: StationFields;
endFields: StationFields;
@@ -46,6 +49,10 @@ export interface StructuresFormElements {
/** 버튼 묶음 — 패널이 그 앞에 메모 칸을 끼워 넣는다. */
actions: HTMLElement;
facilityOptions: ReturnType<typeof createFacilityOptionsForm>;
/** 「지난 정의 값」 읽기만 상자(48-3) — 지금 정의에 없는 키의 값. */
staleBox: HTMLElement;
/** 시설 폼(손코딩)에 정의 붙이기(48-3 · 48-4) — 숨긴 선택지 · 규칙. */
facilityDefinition: FacilityDefinition;
primary: HTMLButtonElement;
removeButton: HTMLButtonElement;
resetButton: HTMLButtonElement;
@@ -104,13 +111,6 @@ export function buildStructuresForm(options: {
typeRow.className = "b05-structure__grid";
typeRow.append(field("구조물군", groupSelect), field("종류", typeSelect));
// 「제원·수량은 다른 화면이 냅니다」 안내 한 줄 — 목록 항목은 [측점][이름]만 적는 규칙이라
// (2026-08-18 사용자 지시) 표시는 이 폼에 둔다. 측구(옆도랑)가 그 경우다(2026-09-07 사용자:
// 「두되 표시만 해줘」). 문구는 레지스트리 `design_owner` 값으로 만든다.
const ownerNote = document.createElement("p");
ownerNote.className = "b05-structure__owner-note";
ownerNote.hidden = true;
// 옵션 칸은 타입마다 다르므로 선택할 때마다 새로 그린다.
const optionRow = document.createElement("div");
optionRow.className = "b05-structure__grid";
@@ -148,15 +148,34 @@ export function buildStructuresForm(options: {
const summary = buildSummaryRow();
summary.root.hidden = true;
const groupBoxes = createGroupBoxes();
// 배관 명세 컨테이너 「구조물 조합」 잇기 = 그룹 값(`group_items`)과 같은 자리 · 같은 [고르기] 길(PLAN 52-1)
facilityOptions.bindLinks({
get: groupBoxes.get,
pick: groupBoxes.pick,
clear: groupBoxes.clear,
set: groupBoxes.setOne,
});
groupBoxes.watch(facilityOptions.paintLinks);
// 일반 구조물 명세 컨테이너(PLAN 52-10 · 노면공 등) — 잇기 · 반영 길은 배관 명세와 같음
const structureSpec = createStructureSpecForm(
optionRow,
{ get: groupBoxes.get, pick: groupBoxes.pick, clear: groupBoxes.clear, set: groupBoxes.setOne },
options.onFacilityChange,
);
groupBoxes.watch(structureSpec.paintLinks);
const staleBox = document.createElement("fieldset");
staleBox.className = "b05-structure__group b05-structure__stale";
staleBox.hidden = true;
body.append(
typeRow,
ownerNote,
positionRow,
summary.root, // 종류 단위 「구조물 조합」 잇기 — 기준 측점 바로 아래(PLAN 52-1 · 컨테이너 없는 종류)
positionDivider,
optionRow,
structureSpec.root,
facilityOptions.root,
summary.root,
staleBox,
groupBoxes.root,
actions,
);
@@ -166,7 +185,6 @@ export function buildStructuresForm(options: {
body,
groupSelect,
typeSelect,
ownerNote,
startFields,
anchorFields,
endFields,
@@ -178,6 +196,8 @@ export function buildStructuresForm(options: {
optionRow,
actions,
facilityOptions,
staleBox,
facilityDefinition: createFacilityDefinition(body),
primary,
removeButton,
resetButton,
+94 -17
View File
@@ -10,6 +10,8 @@
* 독립 기슭막이 채널 키는 `hiddenFormKeys` 로 넓힘).
* · 그룹 연결 값(`{그룹 id: 참조}`)은 정의가 사라진 그룹 것도 그대로 쥠(값 보존 · 경고 한 줄).
* · 저장은 패널이 한다(`group_items` 칸) — 여기는 값만 쥠.
* · 그룹 형상 칸(48 정의 그룹 `형상` · 길이 · 높이 · 전 · 후 받기 켬끔) — 값은 구조물 옵션
* `{그룹 id}__{칸}` 으로 저장(패널이 옵션에 얹음) · 계산은 안 함(48-5).
* ========================================================================== */
import { openItemPicker } from "@ui/ui_template_item_picker";
@@ -17,6 +19,11 @@ import { pipeStructureId } from "@ui/ui_template_item_picker_project";
import type { StructureType } from "./B05_Profile_Api_Structures";
import { hiddenFormKeys } from "./B05_Profile_UI_Drainage_Facility_Merge";
import { buildSummaryRow, type SummaryRow } from "./B05_Profile_UI_Structures_Summary_Row";
import { isOptionVisible } from "./B05_Profile_UI_Structures_Summary";
import { SHAPE_FIELDS, shapeFields, shapeKey } from "./B05_Profile_UI_Structures_Define";
import { numberInput } from "./B05_Profile_UI_Structures_Fields";
import { grid, group as boxOf, labeled, stepper } from "./B05_Profile_UI_Drainage_Facility_Fields";
import { STRUCTURE_SPECS } from "../A00_Common/design/design_structure_pipe";
import {
GROUP_JOIN,
type GroupItems,
@@ -33,8 +40,25 @@ export interface GroupBoxes {
set: (items: GroupItems) => void;
/** 한 그룹 값 — null = 해제. */
setOne: (groupId: string, item: SummaryItem | null) => void;
/** [고르기] · [해제] 배선 — 패널이 한 번 부른다. */
bind: (handlers: { pick: (groupId: string) => void; clear: (groupId: string) => void }) => void;
/** [고르기] · [해제] · 형상 칸 고침 배선 — 패널이 한 번 부른다. */
bind: (handlers: GroupHandlers) => void;
/** 형상 칸 값 `{그룹 id}__{칸}: 수` — 빈 칸은 뺌. 옵션에 얹어 저장. */
shapes: () => Record<string, number>;
/** 지금 종류 그룹의 형상 키 전부(받기 끈 칸 포함) — 저장 병합 · 지난 정의 값 판정. */
shapeKeys: (type?: StructureType | null) => string[];
/** 구조물 옵션에서 형상 값을 실음(폼 불러오기). */
setShapes: (options: Record<string, string | number> | undefined) => void;
/** 명세 컨테이너 잇기 줄(PLAN 52-1)이 쓰는 [고르기] · [해제] — 그룹 상자와 같은 길. */
pick: (groupId: string) => void;
clear: (groupId: string) => void;
/** 값이 바뀔 때마다 부름(명세 컨테이너 잇기 줄 다시 그림). */
watch: (listener: () => void) => void;
}
interface GroupHandlers {
pick: (groupId: string) => void;
clear: (groupId: string) => void;
change?: () => void;
}
export function createGroupBoxes(): GroupBoxes {
@@ -43,7 +67,14 @@ export function createGroupBoxes(): GroupBoxes {
root.dataset.b05Groups = "";
root.hidden = true;
let items: GroupItems = {};
let handlers: { pick: (id: string) => void; clear: (id: string) => void } | null = null;
let handlers: GroupHandlers | null = null;
let shapes: Record<string, string> = {};
let current: StructureType | null = null;
const listeners: Array<() => void> = [];
const changed = (): void => listeners.forEach((listener) => listener());
const keysOf = (type: StructureType | null | undefined): string[] =>
(type?.groups ?? []).flatMap((g) => SHAPE_FIELDS.map((f) => shapeKey(g.id, f.suffix)));
const shapeInputs = new Map<string, HTMLInputElement>();
const rows = new Map<string, SummaryRow>();
/** 옮긴 칸 · 제자리 표지 */
const moved: Array<{ node: HTMLElement; mark: Comment }> = [];
@@ -83,29 +114,33 @@ export function createGroupBoxes(): GroupBoxes {
render(type, scopes, facility) {
restore();
rows.clear();
const groups = type?.groups ?? [];
shapeInputs.clear();
current = type;
// 명세 종류(PLAN 52 · 배관)는 컨테이너가 잇기 줄을 가짐 — 그룹 상자를 안 세움
const groups = type && STRUCTURE_SPECS[type.type_id] ? [] : (type?.groups ?? []);
const boxes: HTMLElement[] = [];
bodies = [];
// 「구조물 옵션 보이기」에서 끈 칸 — 시설 폼 밖으로 옮긴 칸도 같은 규칙으로 가림(Hidden 과 같은 식)
const off = hiddenFormKeys(
facility,
(type?.options ?? []).filter((o) => o.visible === false).map((o) => o.key),
(type?.options ?? []).filter((o) => !isOptionVisible(o)).map((o) => o.key),
);
for (const group of groups) {
const keys = hiddenFormKeys(facility, group.options);
const box = document.createElement("fieldset");
box.className = "b05-structure__group b05-structure__optgroup";
box.dataset.b05Group = group.id;
const legend = document.createElement("legend");
legend.textContent = group.name;
const body = document.createElement("div");
body.className = "b05-structure__grid";
// 상자 꼴 = 명세 컨테이너(`design_structure_form`)와 같은 조각 — 제목 · 몸통 · 격자 · 잇기 줄(52-18)
const box = boxOf(group.name);
box.root.classList.add("b05-structure__optgroup");
box.root.dataset.b05Group = group.id;
const body = grid();
for (const scope of scopes) {
const marked = [...scope.querySelectorAll<HTMLElement>("[data-option-keys]")];
// 지금 숨은 칸(다른 시설 몫 · 안 고른 갈래)은 그 자리에 둠 — 같은 키 칸이 두 벌 옮겨 오지 않게
// 자리 자체가 가려졌으면(안 쓰는 시설 폼) 그 칸도 숨은 것 — 같은 키 칸이 딸려 오지 않게(52-7)
const shown = (node: HTMLElement): boolean => {
for (let at: HTMLElement | null = node; at && at !== scope; at = at.parentElement)
for (let at: HTMLElement | null = node; at; at = at.parentElement) {
if (at.hidden) return false;
if (at === scope) break;
}
return true;
};
const fits = marked.filter(
@@ -133,24 +168,41 @@ export function createGroupBoxes(): GroupBoxes {
}
}
}
for (const shape of shapeFields(group.shape)) {
const key = shapeKey(group.id, shape.suffix);
const input = numberInput("0.1", "0");
input.value = shapes[key] ?? "";
input.dataset.shapeKey = key;
input.title = shape.meaning;
input.addEventListener("change", () => {
shapes = { ...shapes, [key]: input.value.trim() };
handlers?.change?.();
});
shapeInputs.set(key, input);
body.append(labeled(shape.label, stepper(input, 0.1)));
}
if (!body.childElementCount) {
const none = document.createElement("p");
none.className = "b05-structure__owner-note";
none.textContent = "옵션 없음 — 집계 항목만 지정";
none.textContent = "옵션 없음 — 구조물 조합만 지정";
body.append(none);
}
const row = buildSummaryRow();
row.root.querySelector(".b05-structure__summary-label")!.textContent = "구조물 조합";
row.set(items[group.id] ?? null);
row.bind({
pick: () => handlers?.pick(group.id),
clear: () => handlers?.clear(group.id),
});
rows.set(group.id, row);
box.append(legend, body, row.root);
boxes.push(box);
box.body.append(body, row.root);
boxes.push(box.root);
bodies.push(body);
}
const stale = type ? paintStale(new Set(groups.map((g) => g.id))) : null;
const stale =
type && !STRUCTURE_SPECS[type.type_id]
? paintStale(new Set(groups.map((g) => g.id)))
: null;
root.replaceChildren(...boxes, ...(stale ? [stale] : []));
root.hidden = !type || (!boxes.length && !stale);
// 잠금은 계곡 통과 시설 서브폼(`inert`)을 따름 — 레지스트리 칸은 칸마다 disabled 라 그대로
@@ -167,6 +219,7 @@ export function createGroupBoxes(): GroupBoxes {
set(next) {
items = { ...next };
for (const [id, row] of rows) row.set(items[id] ?? null);
changed();
},
setOne(groupId, item) {
if (item) items = { ...items, [groupId]: item };
@@ -175,10 +228,31 @@ export function createGroupBoxes(): GroupBoxes {
items = rest;
}
rows.get(groupId)?.set(item);
changed();
},
pick: (groupId) => handlers?.pick(groupId),
clear: (groupId) => handlers?.clear(groupId),
watch: (listener) => listeners.push(listener),
bind(next) {
handlers = next;
},
shapes() {
const out: Record<string, number> = {};
for (const key of shapeInputs.keys()) {
const text = (shapes[key] ?? "").trim();
if (text !== "" && Number.isFinite(Number(text))) out[key] = Number(text);
}
return out;
},
shapeKeys: (type) => keysOf(type === undefined ? current : type),
setShapes(options) {
shapes = Object.fromEntries(
Object.entries(options ?? {})
.filter(([key]) => key.includes(GROUP_JOIN))
.map(([key, value]) => [key, String(value)]),
);
for (const [key, input] of shapeInputs) input.value = shapes[key] ?? "";
},
};
}
@@ -193,6 +267,8 @@ export function bindSummaryPickers(opts: {
editingId: () => string | null;
selectedPipeChainage: () => number | null;
commitSummary: () => void;
/** 형상 칸 고침 반영 — 고치는 중이면 곧바로(새 항목은 [추가]가 확정). */
liveCommit: () => void;
}): void {
const base = (): string | null => {
const pipe = opts.selectedPipeChainage();
@@ -214,6 +290,7 @@ export function bindSummaryPickers(opts: {
},
});
opts.groups.bind({
change: opts.liveCommit,
pick: (groupId) => {
const id = base();
void pick(
+101 -3
View File
@@ -15,7 +15,17 @@ import {
} from "./B05_Profile_Api_Structures";
import type { PipeFacilityItem } from "./B05_Profile_UI_Structures_Panel";
import { stationLabel as formatStation } from "../common_util/common_util_station";
import { readSummaryItem, summaryTooltip } from "../common_util/common_util_summary_item";
import {
readGroupItems,
readSummaryItem,
summaryLabel,
summaryTooltip,
type SummaryItem,
} from "../common_util/common_util_summary_item";
import { STRUCTURE_SPECS } from "../A00_Common/design/design_structure_pipe";
import { pipeExtraCount } from "../A00_Common/design/design_structure_pipe_calc";
import { containerTitle, linkOf, readState } from "../A00_Common/design/design_structure_spec";
import { asRoad } from "./B05_Profile_UI_Structures_Define";
export interface StructureListParams {
/** 목록을 담을 <ul>. 그릴 때마다 통째로 갈아 끼운다. */
@@ -56,6 +66,78 @@ export function numberDuplicateNames(names: ReadonlyArray<string>): string[] {
});
}
/** 기타 = 사용자가 적은 상세 종류 이름(표 08 · 52-10) — 비었으면 null(종류 이름) · 알약도 씀(53-2). */
export function etcName(structure: StructureInstance): string | null {
const name = structure.type_id === "etc" ? String(structure.options?.name ?? "").trim() : "";
return name || null;
}
/** 잇기 자리 하나 — 상자 이름 · 이은 항목(없으면 null) · 필수 여부. */
interface LinkLamp {
title: string;
item: SummaryItem | null;
required: boolean;
}
/** 줄의 잇기 자리(54-15) — 폼이 잇기 줄을 세우는 규칙 그대로: 명세 컨테이너마다(선택은 인스턴스마다 ·
* 배관 흙막이는 지형이 세운 단까지) · 정의 그룹마다(옛 종류 단위 값 = 첫 그룹 · 54-6) · 그 밖은
* 종류 단위 하나 · 종단배수(B군)는 없음. */
export function linkLamps(
type: StructureType | undefined,
source: {
type_id: string;
options?: Record<string, string | number>;
summary_item?: unknown;
group_items?: unknown;
},
chainageM: number | null,
): LinkLamp[] {
const links = readGroupItems(source.group_items);
const summary = readSummaryItem(source.summary_item);
const spec = STRUCTURE_SPECS[source.type_id];
if (spec?.containers.length) {
const groupNames = Object.fromEntries((type?.groups ?? []).map((g) => [g.id, g.name]));
// 배관 흙막이 = 명세 이름 「흙막이」가 정의 옛 이름 「흙막이 추가」보다 앞섬(54-1 · 시설 폼과 같음)
const { soil_add: _old, ...pipeNames } = type?.spec_names ?? {};
const names = source.type_id === "pipe" ? pipeNames : (type?.spec_names ?? {});
const state = readState(spec, source.options ?? {});
return spec.containers.flatMap((c): LinkLamp[] => {
const title = containerTitle(c, names, groupNames[c.link]);
if (c.required) return [{ title, item: links[c.link] ?? null, required: true }];
const n = (c.id === "soil_add" ? pipeExtraCount(chainageM) : null) ?? state[c.id].length;
return Array.from({ length: n }, (_, i) => ({
title: `${title} ${i + 1}`,
item: links[linkOf(c, i + 1)] ?? null,
required: false,
}));
});
}
if (type?.groups?.length) {
const first = type.groups[0].id;
return type.groups.map((g) => ({
title: g.name,
item: links[g.id] ?? (g.id === first ? summary : null),
required: true,
}));
}
if (!type || type.group === "B") return [];
return [{ title: "구조물 조합", item: summary, required: true }];
}
/** 램프 칸 — 3행 × 열(위 → 아래 → 다음 열) · 색 = 이음 · 필수 미지정 · 선택 미지정 · 툴팁 = 상자 · 항목. */
function lampCell(lamps: LinkLamp[]): HTMLElement {
const cell = document.createElement("div");
cell.className = "b05-route__lamps";
for (const lamp of lamps) {
const dot = document.createElement("i");
dot.className = lamp.item ? "is-linked" : lamp.required ? "is-required" : "is-optional";
cell.append(dot);
}
if (lamps.length)
cell.title = lamps.map((lamp) => `${lamp.title} · ${summaryLabel(lamp.item)}`).join("\n");
return cell;
}
export function renderStructureList(params: StructureListParams): void {
const { list, typeMap, intervalM, editingId, selectedPipeChainage } = params;
list.replaceChildren();
@@ -89,10 +171,26 @@ export function renderStructureList(params: StructureListParams): void {
const displayNames = numberDuplicateNames(
rows.map((row) =>
row.kind === "structure"
? (typeMap.get(row.structure.type_id)?.name ?? row.structure.type_id)
? (etcName(row.structure) ??
typeMap.get(row.structure.type_id)?.name ??
row.structure.type_id)
: (typeMap.get(row.pipe.facility)?.name ?? row.pipe.facility),
),
);
const lamps = rows.map((row) =>
row.kind === "structure"
? linkLamps(typeMap.get(asRoad(row.structure).type_id), asRoad(row.structure), null)
: linkLamps(
typeMap.get(row.pipe.facility),
{ ...row.pipe, type_id: row.pipe.facility },
row.pipe.chainage_m,
),
);
// 램프 칸 폭 = 목록에서 가장 많은 열 — 줄마다 글 시작 자리가 같게(54-15)
list.style.setProperty(
"--lamp-cols",
String(Math.max(0, ...lamps.map((l) => Math.ceil(l.length / 3)))),
);
rows.forEach((row, index) => {
const item = document.createElement("li");
item.className = "b05-route__irregular-item";
@@ -124,7 +222,7 @@ export function renderStructureList(params: StructureListParams): void {
// 사용자). 패널이 막 펼쳐진 참이라 자리가 잡힌 다음 프레임에 민다.
if (picked) requestAnimationFrame(() => item.scrollIntoView({ block: "nearest" }));
}
item.append(station, name);
item.append(lampCell(lamps[index]), station, name);
list.append(item);
});
}
+93 -59
View File
@@ -19,7 +19,8 @@ import {
type StructureInstance,
type StructureType,
} from "./B05_Profile_Api_Structures";
import { numberDuplicateNames } from "./B05_Profile_UI_Structures_List";
import { etcName, numberDuplicateNames } from "./B05_Profile_UI_Structures_List";
import { balloonLines, type ContainerCount } from "./B05_Profile_UI_Structures_Balloon";
import { stationLabel as formatStation } from "../common_util/common_util_station";
/** 마크를 잡았다고 볼 여유(px) — 시작점에서 이만큼 **벗어나기 전에는** 이동으로
@@ -36,8 +37,11 @@ const SOLO_PILL_HEIGHT_PX = 22;
const ROW_GAP_PX = 2;
/** 레인 위아래 여백(px) — 그래프를 밀어내되 여유는 최소로. */
const LANE_PADDING_PX = 2;
/** 두 알약이 겹친다고 볼 가로 거리(px). 3자 라벨 폭 기준. */
const OVERLAP_PX = 52;
/** 알약 폭 어림(px) — 글자당 · 좌우 여백+테(54-49 이름 글이라 폭이 제각각). */
const PILL_CHAR_PX = 11;
const PILL_PAD_PX = 20;
/** 라벨을 위로 비키는 높이(px) — 그래프 바닥 ▼ 단추(바닥 2 + 높이 17) + 틈 2(54-14). */
const EDIT_BUTTON_CLEARANCE_PX = 21;
/** 레인 전체 높이(px) — 2행 구조를 항상 확보한다(항목이 하나여도 높이는 같다).
* 큰(혼자) 알약도 이 안에 들어간다. 아래 서브패널 손잡이와의 사이는 CSS 여백을
@@ -62,18 +66,8 @@ export interface StructureMarksOptions {
selectedId: string | null;
onSelect: (structureId: string | null) => void;
onMove: (structureId: string, toChainageM: number) => void;
}
function optionSummary(structure: StructureInstance, type: StructureType | undefined): string {
if (!type) return "";
return type.options
.map((option) => {
const value = structure.options?.[option.key];
if (value === undefined || value === "") return null;
return `${option.label} ${value}${option.unit ?? ""}`;
})
.filter(Boolean)
.join(" · ");
/** 라벨 선택 컨테이너 개수(폼과 같은 값 · 배관 흙막이 = 유출 단 수) — 없으면 저장된 것. */
containerCount?: (structure: StructureInstance) => ContainerCount | undefined;
}
/** 위치 표기 — 측점번호+잔여거리(예: 3+18.0). 누가거리 표기는 쓰지 않는다(2026-08-17). */
@@ -88,19 +82,24 @@ function positionText(structure: StructureInstance, intervalM: number): string {
function rowAssignments(
structures: ReadonlyArray<StructureInstance>,
x: (chainageM: number) => number,
labelOf: (structure: StructureInstance) => string,
): Map<string, number | null> {
const rows = new Map<string, number | null>();
const sorted = [...structures].sort(
(left, right) => structureAnchorM(left) - structureAnchorM(right),
);
const centers = sorted.map((structure) => x(structureAnchorM(structure)));
const halves = sorted.map(
(structure) => ([...labelOf(structure)].length * PILL_CHAR_PX + PILL_PAD_PX) / 2,
);
let row = 0;
sorted.forEach((structure, index) => {
const id = structure.structure_id ?? "";
const near =
(index > 0 && centers[index] - centers[index - 1] < OVERLAP_PX) ||
(index < sorted.length - 1 && centers[index + 1] - centers[index] < OVERLAP_PX);
(index > 0 && centers[index] - centers[index - 1] < halves[index] + halves[index - 1]) ||
(index < sorted.length - 1 &&
centers[index + 1] - centers[index] < halves[index] + halves[index + 1]);
if (!near) {
// 앞뒤 어디와도 안 겹친다 — 혼자이므로 레인 세로 가운데.
rows.set(id, null);
@@ -115,6 +114,26 @@ function rowAssignments(
return rows;
}
/** 표시 이름 · 알약 글(구조물 id 별) — 둘 다 좌측 「종류」 칸 · 목록과 같은 이름(54-49).
* 같은 이름이 여럿이면 시점에 가까운 순 「이름 1/2…」 · 기타 = 손 이름(빈 이름 = 「기타」). */
export function structurePillTexts(
structures: ReadonlyArray<StructureInstance>,
typeMap: ReadonlyMap<string, StructureType>,
): Map<string, { name: string; pill: string }> {
const sorted = [...structures].sort(
(left, right) => structureAnchorM(left) - structureAnchorM(right),
);
const numbered = numberDuplicateNames(
sorted.map((entry) => etcName(entry) ?? typeMap.get(entry.type_id)?.name ?? entry.type_id),
);
return new Map(
sorted.map((entry, index) => [
entry.structure_id ?? "",
{ name: numbered[index], pill: numbered[index] },
]),
);
}
/**
* 그래프 아래에 구조물 알약 레인을 만들어 돌려준다(호출부가 원하는 위치에 붙인다).
*/
@@ -125,28 +144,20 @@ export function buildStructureLane(options: StructureMarksOptions): HTMLElement
lane.style.height = `${STRUCTURE_LANE_HEIGHT_PX}px`;
const typeMap = new Map(options.types.map((type) => [type.type_id, type]));
const rows = rowAssignments(options.structures, options.x);
// 좌측 목록과 같은 중복 이름 번호(2026-08-19 사용자 지시) — 시점에 가까운 순
// "이름 1/2…". 알약 라벨(약호)·툴팁·벌룬 제목이 모두 이 번호를 따른다.
const anchorSorted = [...options.structures].sort(
(left, right) => structureAnchorM(left) - structureAnchorM(right),
);
const numberedNames = numberDuplicateNames(
anchorSorted.map((entry) => typeMap.get(entry.type_id)?.name ?? entry.type_id),
);
const displayNames = new Map(
anchorSorted.map((entry, index) => [entry.structure_id ?? "", numberedNames[index]]),
// 좌측 목록과 같은 중복 이름 번호(2026-08-19 사용자 지시) — 알약 글·툴팁·벌룬 제목이
// 모두 이 번호를 따른다.
const texts = structurePillTexts(options.structures, typeMap);
const rows = rowAssignments(
options.structures,
options.x,
(structure) => texts.get(structure.structure_id ?? "")?.pill ?? "",
);
options.structures.forEach((structure) => {
const id = structure.structure_id;
if (!id) return;
const type = typeMap.get(structure.type_id);
const rawName = type?.name ?? structure.type_id;
const displayName = displayNames.get(id) ?? rawName;
// "옹벽 1"에서 붙은 번호만 떼어 약호 뒤에 잇는다(알약은 약호 표기 유지).
const numberSuffix = displayName.startsWith(rawName) ? displayName.slice(rawName.length) : "";
const { name: displayName, pill } = texts.get(id) ?? { name: structure.type_id, pill: "?" };
const anchorPx = options.x(structureAnchorM(structure));
const selected = options.selectedId === id;
// 이웃과 겹치는 알약만 위·아래 두 줄로 가르고, 혼자면 레인 세로 가운데에 크게 둔다.
@@ -183,8 +194,8 @@ export function buildStructureLane(options: StructureMarksOptions): HTMLElement
mark.style.top = `${top}px`;
mark.style.borderColor = type?.style?.color ?? "#888";
mark.style.color = type?.style?.color ?? "#888";
// 라벨은 3자 이하 짧은 이름(레지스트리 style.abbr, 2026-08-17 지시 4) + 중복 번호.
mark.textContent = `${type?.style?.abbr ?? "?"}${numberSuffix}`;
// 라벨 = 「종류」 칸과 같은 이름 + 중복 번호(54-49).
mark.textContent = pill;
mark.title = `${displayName} ${positionText(structure, options.stationIntervalM)}`;
mark.dataset.structureId = id;
@@ -197,7 +208,17 @@ export function buildStructureLane(options: StructureMarksOptions): HTMLElement
if (selected)
lane.append(
buildBalloon(structure, type, anchorPx, row, options.stationIntervalM, displayName),
buildBalloon(
balloonLines(
structure,
type,
{ name: displayName, position: positionText(structure, options.stationIntervalM) },
options.containerCount?.(structure),
),
type,
anchorPx,
row,
),
);
});
@@ -220,44 +241,57 @@ export function buildStructureLane(options: StructureMarksOptions): HTMLElement
/** 고른 구조물의 값 벌룬. 유토곡선 벌룬과 같은 결(도형+텍스트)로 맞춘다.
* 알약 **위**로 띄운다 — 아래로 펴면 도면 테이블에 가려 안 보인다(2026-08-18
* 사용자 지시). 2행 구조에서 1행(윗줄)은 좌측 위, 2행(아랫줄)은 우측 위로
* 전개해 서로 겹치지 않게 하고, 솔로 알약은 위 중앙이다. */
* 전개해 서로 겹치지 않게 하고, 솔로 알약은 위 중앙이다.
* 줄 = 2행 — 이름 + 기준 측점 · 컨테이너마다 첫 옵션 값 이음(`balloonLines` · 54-14 · 54-46) · 그래프 바닥 ▼ 단추를 가리지
* 않게 단추 높이만큼 더 위 · 위가 잘리면 알약 아래로. */
function buildBalloon(
structure: StructureInstance,
lines: string[],
type: StructureType | undefined,
anchorPx: number,
row: number | null,
stationIntervalM: number,
/** 중복 번호가 붙은 표시 이름("옹벽 1") — 좌측 목록과 같은 표기(2026-08-19). */
displayName?: string,
): HTMLElement {
const balloon = document.createElement("div");
balloon.className = "b05-structure__balloon";
balloon.classList.add(row === 0 ? "is-left" : row === 1 ? "is-right" : "is-center");
balloon.style.left = `${anchorPx}px`;
balloon.style.bottom = `${STRUCTURE_LANE_HEIGHT_PX + ROW_GAP_PX}px`;
balloon.style.bottom = `${STRUCTURE_LANE_HEIGHT_PX + ROW_GAP_PX + EDIT_BUTTON_CLEARANCE_PX}px`;
balloon.style.borderColor = type?.style?.color ?? "#888";
const [name, ...rest] = lines;
const title = document.createElement("strong");
title.textContent = displayName ?? type?.name ?? structure.type_id;
const position = document.createElement("span");
position.textContent = positionText(structure, stationIntervalM);
balloon.append(title, position);
const summary = optionSummary(structure, type);
if (summary) {
const detail = document.createElement("span");
detail.textContent = summary;
balloon.append(detail);
}
if (structure.memo) {
const memo = document.createElement("span");
memo.className = "b05-structure__balloon-memo";
memo.textContent = structure.memo;
balloon.append(memo);
}
title.textContent = name;
balloon.append(
title,
...rest.map((line) => {
const span = document.createElement("span");
span.textContent = line;
return span;
}),
);
requestAnimationFrame(() => flipIfClipped(balloon));
return balloon;
}
/** 라벨 위가 스크롤 상자 · 창 밖으로 잘리면 알약 아래로 편다(아래가 덜 잘릴 때만). */
function flipIfClipped(balloon: HTMLElement): void {
const lane = balloon.parentElement;
if (!balloon.isConnected || !lane) return;
let top = 0;
let bottom = window.innerHeight;
for (let at: HTMLElement | null = lane; at; at = at.parentElement)
if (getComputedStyle(at).overflowY !== "visible") {
const clip = at.getBoundingClientRect();
top = Math.max(top, clip.top);
bottom = Math.min(bottom, clip.bottom);
}
const box = balloon.getBoundingClientRect();
const hiddenAbove = top - box.top;
const hiddenBelow = lane.getBoundingClientRect().bottom + ROW_GAP_PX + box.height - bottom;
if (hiddenAbove <= 0 || hiddenBelow >= hiddenAbove) return;
balloon.style.bottom = "auto";
balloon.style.top = `${STRUCTURE_LANE_HEIGHT_PX + ROW_GAP_PX}px`;
}
/** 마크를 좌우로 끌어 위치를 옮긴다. 구간형은 길이를 유지한 채 통째로 움직인다. */
function attachMarkDrag(
mark: HTMLElement,
+53 -46
View File
@@ -23,7 +23,12 @@ import {
import type { PipeFacility } from "../B04_PreProcess/B04_PreProcess_Api_Fetch";
import { type FacilityAttributes } from "./B05_Profile_UI_Drainage_Facility";
import { field, optionDefaults } from "./B05_Profile_UI_Structures_Fields";
import { renderOptionFields as renderOptionFieldsInto } from "./B05_Profile_UI_Structures_Panel_Options";
import {
hidesTypeSummary,
markRequired,
paintStale,
renderOptionFields as renderOptionFieldsInto,
} from "./B05_Profile_UI_Structures_Panel_Options";
import { bindSummaryPickers } from "./B05_Profile_UI_Structures_Groups";
import { buildStructuresForm } from "./B05_Profile_UI_Structures_Form";
import {
@@ -38,7 +43,8 @@ import {
loadPipeForm as loadPipeFormInto,
} from "./B05_Profile_UI_Structures_Panel_Commit";
import { renderStructureList } from "./B05_Profile_UI_Structures_List";
import { isOptionVisible } from "./B05_Profile_UI_Structures_Summary";
import { pickable, showsAnchor } from "./B05_Profile_UI_Structures_Define";
import { hiddenOptionKeys } from "./B05_Profile_UI_Structures_Define_Form";
import { stationLabel as formatStation } from "../common_util/common_util_station";
import { PIPE_MATCH_M, resolveSelection } from "../A00_Common/design/design_selection";
@@ -48,15 +54,14 @@ export { GROUP_LABELS } from "./B05_Profile_UI_Structures_Panel_Types";
export type { PipeFacilityItem, StructuresSection } from "./B05_Profile_UI_Structures_Panel_Types";
import {
DEFAULT_INTERVAL_LENGTH_M,
GROUP_LABELS,
groupOptions,
hasComputedRange,
typeOptions,
readBeforeOption,
readLengthOption,
} from "./B05_Profile_UI_Structures_Panel_Types";
import type {
PipeFacilityItem,
StructuresCallbacks,
StructuresSection,
type PipeFacilityItem,
type StructuresCallbacks,
type StructuresSection,
} from "./B05_Profile_UI_Structures_Panel_Types";
export function createStructuresSection(
@@ -74,7 +79,6 @@ export function createStructuresSection(
body,
groupSelect,
typeSelect,
ownerNote,
startFields,
anchorFields,
endFields,
@@ -86,6 +90,8 @@ export function createStructuresSection(
optionRow,
actions,
facilityOptions,
staleBox,
facilityDefinition,
primary,
removeButton,
resetButton,
@@ -94,12 +100,14 @@ export function createStructuresSection(
groupBoxes,
} = form;
/** 옵션 그룹 상자를 지금 종류 · 칸에 맞춰 다시 세움(PLAN 46-3) — 칸을 그린 뒤마다 부름. */
const regroup = (): void =>
const regroup = (): void => {
groupBoxes.render(
currentType(),
[optionRow, facilityOptions.root],
facilityFormKind(currentType()),
);
markRequired(optionInputs, optionRow); // 빈 필수 칸 안내 = 칸이 옮겨 간 상자 안(54-12)
};
/** 이 타입이 서브폼(계곡 통과 시설 부속)을 쓰는지 — 쓰면 레지스트리 옵션 칸 대신
* 서브폼이 그린다. 독립 기슭막이(D4)는 서브폼을 떠나 C군과 같은 레지스트리 옵션
@@ -159,6 +167,7 @@ export function createStructuresSection(
}
let types: StructureType[] = [];
let canPick: (type: StructureType) => boolean = () => true;
// 배열 자체를 바꾸지 않는다(조각들이 참조로 들고 있음) — 내용만 갈아끼운다.
const structures: StructureInstance[] = [];
let pipeFacilities: PipeFacilityItem[] = [];
@@ -222,19 +231,15 @@ export function createStructuresSection(
!!type && !managed && type.placement === "interval" && !hasComputedRange(type);
positionRow.hidden = !type;
positionDivider.hidden = !type;
summary.root.hidden = !type;
summary.root.hidden = !type || hidesTypeSummary(type); // 컨테이너 종류는 컨테이너마다 잇기(52-1)
startFields.wrap.hidden = !isInterval;
endFields.wrap.hidden = !isInterval;
primary.disabled = !type;
// 제원·수량 주인이 다른 화면인 타입은 그 사실을 폼에 적는다 — 목록에서 안 보이면
// 「측구가 왜 없지」로 헤매고, 그렇다고 수량에 넣으면 이중 계상이다(2026-09-07 사용자).
ownerNote.textContent = type?.design_owner
? `${type.design_owner}에서 관리 — 여기서 넣어도 제원·수량은 그쪽 값을 씁니다.`
: "";
ownerNote.hidden = !type?.design_owner;
anchorFields.wrap.querySelector("span")!.textContent = isInterval
? "기준 측점 (비우면 시작)"
: "기준 측점";
// [?] 설명서가 먼저 여는 항목 = `구조물_<종류 이름>.md`(54-2 · 종류 안내 글은 그 파일로 옮김)
root.dataset.helpTopic = type ? `구조물_${type.name}` : "";
// 정의가 기준 측점을 끈 종류(48-3) — 기준 측점이 곧 위치인 종류(점형 · 범위 계산)는 늘 보임
anchorFields.wrap.hidden = isInterval && !showsAnchor(type!);
anchorFields.wrap.querySelector("span")!.textContent = "기준 측점"; // 빈 칸 안내 없음(54-43)
syncRangeDisplay();
}
@@ -244,13 +249,14 @@ export function createStructuresSection(
designFlow: number | null = null,
): void {
const kind = facilityFormKind(currentType());
facilityOptions.setFacility(kind, options ?? newDefaults(), designFlow);
facilityOptions.setChainage(selectedPipeChainage ?? tempPipeChainage); // 관 길이(자동 · 52-1)
facilityOptions.setFacility(kind, options ?? newDefaults(), designFlow, currentType());
if (kind)
paintStale(staleBox, currentType(), options, kind, groupBoxes.shapeKeys(currentType()));
// 「구조물 옵션 보이기」에서 끈 옵션은 시설 폼에서도 가림(값은 옛 값 그대로 저장)
facilityOptions.setHiddenOptions(
kind,
(currentType()?.options ?? []).filter((o) => !isOptionVisible(o)).map((o) => o.key),
);
facilityOptions.setHiddenOptions(kind, hiddenOptionKeys(currentType()));
regroup();
facilityDefinition.apply(kind ? currentType() : null); // 숨긴 선택지 · 규칙(48-3 · 48-4)
syncOptionLock();
}
@@ -316,11 +322,15 @@ export function createStructuresSection(
commitTempPipe();
syncOptionLock();
syncRangeDisplay();
// 고르던 항목의 측점도 값 — 다른 칸처럼 바로 반영(53-1)
if (positionConfirmed) liveCommit();
}
/** 타입의 옵션 스키마대로 입력 칸을 다시 그린다 — 그리는 규칙은 `_Structures_Panel_Options`. */
function renderOptionFields(values?: Record<string, string | number>): void {
renderOptionFieldsInto(optionContext, values ?? newDefaults());
if (!facilityFormKind(currentType()))
paintStale(staleBox, currentType(), values, null, groupBoxes.shapeKeys(currentType()));
regroup();
}
@@ -334,11 +344,8 @@ export function createStructuresSection(
* 초기·리셋 상태를 "안 고름"으로 드러낸다. */
function syncTypeOptions(keepTypeId?: string): void {
const group = groupSelect.value;
const candidates = group ? types.filter((type) => type.group === group) : [];
typeSelect.replaceChildren(
new Option("— 선택 —", ""),
...candidates.map((type) => new Option(type.name, type.type_id)),
);
const candidates = group ? types.filter((t) => t.group === group && pickable(t)) : [];
typeSelect.replaceChildren(new Option("— 선택 —", ""), ...typeOptions(candidates, canPick));
typeSelect.value =
keepTypeId && candidates.some((type) => type.type_id === keepTypeId) ? keepTypeId : "";
syncPlacementFields();
@@ -424,8 +431,10 @@ export function createStructuresSection(
selectedPipeChainage,
// 재선택 = 해제(2026-08-18 복구) — 해제는 리셋과 같은 전체 초기화다.
onSelectStructure: (structure) => {
if (structure.structure_id !== null && structure.structure_id === editingId) resetForm();
else loadForm(structure);
if (structure.structure_id !== null && structure.structure_id === editingId) {
resetForm();
callbacks.onListRelease?.();
} else loadForm(structure);
},
onSelectPipe: (pipe) => {
const isSame =
@@ -433,6 +442,7 @@ export function createStructuresSection(
Math.abs(selectedPipeChainage - pipe.chainage_m) < PIPE_MATCH_M;
if (isSame) {
resetForm();
callbacks.onListRelease?.();
} else {
loadPipeForm(pipe);
callbacks.onPipeSelect(pipe.chainage_m);
@@ -462,6 +472,7 @@ export function createStructuresSection(
endFields,
facilityOptions,
callbacks,
projectId: sectionOptions.projectId ?? null,
structures,
types: () => types,
typeMap,
@@ -506,8 +517,7 @@ export function createStructuresSection(
},
summary: () => summary.get(),
setSummary: (value) => summary.set(value),
groupItems: () => groupBoxes.get(),
setGroupItems: (value) => groupBoxes.set(value),
groupBoxes,
};
bindStructuresEvents(panelContext);
// 집계 항목(본체 · 옵션 그룹) — [고르기]는 21-5 모달 · 배선은 `_Structures_Groups`
@@ -518,6 +528,7 @@ export function createStructuresSection(
editingId: () => editingId,
selectedPipeChainage: () => selectedPipeChainage,
commitSummary,
liveCommit,
});
body.insertBefore(field("메모", memoField), actions);
syncButtons();
@@ -525,17 +536,14 @@ export function createStructuresSection(
return {
root,
facility: facilityOptions,
facility: { ...facilityOptions, recount: () => (facilityOptions.recount(), renderList()) }, // 단 수 → 목록 램프(54-15)
listRoot: list,
hasSelection: () => editingId !== null || selectedPipeChainage !== null,
setTypes(next) {
setTypes(next, pick = () => true) {
types = next;
const groups = [...new Set(next.map((t) => t.group))];
canPick = pick;
// 첫 항목은 빈칸 — 진입·리셋 상태에서 군·종류를 강제로 고르게 두지 않는다.
groupSelect.replaceChildren(
new Option("— 선택 —", ""),
...groups.map((group) => new Option(GROUP_LABELS[group] ?? group, group)),
);
groupSelect.replaceChildren(new Option("— 선택 —", ""), ...groupOptions(next, pick));
groupSelect.value = "";
syncTypeOptions();
},
@@ -547,11 +555,10 @@ export function createStructuresSection(
// 목록에 반영되지 않는다(2026-09-04 실측: 저장 전 항목 [삭제]가 안 먹던 원인).
structures.splice(0, structures.length, ...next.map((entry) => ({ ...entry })));
// 실시간 반영으로 되돌아온 목록이면 폼을 닫지 않는다 — 고치던 칸이 사라진다.
if (applyingLive) renderList();
else {
loadForm(null);
renderList();
}
// [저장] 뒤 같은 id 가 남으면 그대로 고름 — 다시 열기와 같게(53-2).
const kept = structures.find((entry) => entry.structure_id === editingId) ?? null;
if (!applyingLive) loadForm(editingId === null ? null : kept);
renderList();
},
getStructures: () => [...structures],
setPipeFacilities(pipes) {
@@ -18,6 +18,10 @@ import type { FacilityAttributes, FacilityOptionsForm } from "./B05_Profile_UI_D
import type { StationFields } from "./B05_Profile_UI_Structures_Fields";
import { splitPavementRange } from "./B05_Profile_UI_Structures_Pavement";
import { mergeStructureOptions } from "./B05_Profile_UI_Structures_Summary";
import { readStructureSpec, specRenderedKeys } from "./B05_Profile_UI_Structures_Spec";
import { asRoad } from "./B05_Profile_UI_Structures_Define";
import type { GroupBoxes } from "./B05_Profile_UI_Structures_Groups";
import { STRUCTURE_SPECS } from "../A00_Common/design/design_structure_pipe";
import {
readGroupItems,
readSummaryItem,
@@ -39,6 +43,8 @@ export interface StructuresCommitContext {
startFields: StationFields;
endFields: StationFields;
facilityOptions: FacilityOptionsForm;
/** 옵션 칸 — 짝 명세 폼(52-10)을 찾는 열쇠. */
optionRow: HTMLElement;
optionInputs: Array<{
key: string;
required: boolean;
@@ -75,13 +81,13 @@ export interface StructuresCommitContext {
summary: () => SummaryItem | null;
setSummary: (value: SummaryItem | null) => void;
/** 옵션 그룹 보조 컨테이너마다 고른 항목(PLAN 46-3) — 저장은 `group_items` 칸. */
groupItems: () => GroupItems;
setGroupItems: (value: GroupItems) => void;
/** 옵션 그룹 상자 — 집계 항목(46-3) · 형상 칸 값(48-3). */
groupBoxes: GroupBoxes;
}
/** 저장할 그룹 연결 — 고른 것이 있을 때만 칸을 실음(빈 묶음 = 칸 없음). */
function groupField(ctx: StructuresCommitContext): { group_items?: GroupItems } {
const items = ctx.groupItems();
const items = ctx.groupBoxes.get();
return Object.keys(items).length ? { group_items: items } : {};
}
@@ -94,18 +100,25 @@ export function loadForm(ctx: StructuresCommitContext, target: StructureInstance
ctx.setPositionConfirmed(target !== null);
const step = ctx.interval();
if (target) {
const type = ctx.typeMap().get(target.type_id);
const shown = asRoad(target); // 옛 대피 종류 = 대피로 + 상세(52-7)
const type = ctx.typeMap().get(shown.type_id);
if (type) {
ctx.groupSelect.value = type.group;
ctx.syncTypeOptions(target.type_id);
ctx.syncTypeOptions(shown.type_id);
}
ctx.anchorFields.write(structureAnchorM(target), step);
ctx.startFields.write(target.start_m ?? null, step);
ctx.endFields.write(target.end_m ?? null, step);
ctx.memoField.value = target.memo ?? "";
ctx.renderOptionFields(target.options);
ctx.setSummary(readSummaryItem(target.summary_item));
ctx.setGroupItems(readGroupItems(target.group_items));
ctx.renderOptionFields(shown.options);
const links = readGroupItems(target.group_items);
const summary = readSummaryItem(target.summary_item);
// 정의 그룹 종류는 종류 단위 잇기 줄이 없음 — 옛 종류 단위 값은 첫 그룹 컨테이너 잇기로 읽음(54-6)
const first = type && !STRUCTURE_SPECS[type.type_id] ? type.groups?.[0]?.id : undefined;
const moved = !!(first && summary && !links[first]);
ctx.setSummary(moved ? null : summary);
ctx.groupBoxes.set(moved ? { ...links, [first!]: summary! } : links);
ctx.groupBoxes.setShapes(target.options);
// 구간 직접 입력 시절에 저장된 항목 호환 — 길이·전길이 옵션이 없으면 저장된
// 시작~종료·기준점에서 역산해 채워 범위 표시·재저장이 이어지게 한다(2026-08-19).
if (target.start_m != null && target.end_m != null && target.end_m > target.start_m) {
@@ -126,7 +139,7 @@ export function loadForm(ctx: StructuresCommitContext, target: StructureInstance
afterEntry.input.value = after.toFixed(1);
}
}
ctx.syncFacilityForm(target.options);
ctx.syncFacilityForm(shown.options);
} else {
ctx.anchorFields.write(null, step);
ctx.startFields.write(null, step);
@@ -134,7 +147,8 @@ export function loadForm(ctx: StructuresCommitContext, target: StructureInstance
ctx.memoField.value = "";
ctx.renderOptionFields();
ctx.setSummary(null);
ctx.setGroupItems({});
ctx.groupBoxes.set({});
ctx.groupBoxes.setShapes({});
ctx.syncFacilityForm();
}
[ctx.anchorFields, ctx.startFields, ctx.endFields].forEach((fields) => fields.clearInvalid());
@@ -182,7 +196,8 @@ export function loadPipeForm(ctx: StructuresCommitContext, pipe: PipeFacilityIte
ctx.memoField.value = "";
ctx.syncFacilityForm(pipe.options ?? {}, pipe.design_flow_m3s ?? null);
ctx.setSummary(readSummaryItem(pipe.summary_item));
ctx.setGroupItems(readGroupItems(pipe.group_items));
ctx.groupBoxes.set(readGroupItems(pipe.group_items));
ctx.groupBoxes.setShapes(pipe.options);
[ctx.anchorFields, ctx.startFields, ctx.endFields].forEach((fields) => fields.clearInvalid());
ctx.syncPlacementFields();
ctx.syncButtons();
@@ -191,15 +206,17 @@ export function loadPipeForm(ctx: StructuresCommitContext, pipe: PipeFacilityIte
}
export function readOptions(ctx: StructuresCommitContext): Record<string, string | number> {
// 서브폼이 담당하는 타입(독립 기슭막이)은 서브폼이 값을 읽는다.
if (ctx.facilityFormKind(ctx.currentType())) return ctx.facilityOptions.readOptions();
const values: Record<string, string | number> = {};
// 서브폼이 담당하는 타입(독립 기슭막이)은 서브폼이 값을 읽는다. 그룹 형상 칸(48-3)은 둘 다 얹음.
const shapes = ctx.groupBoxes.shapes();
if (ctx.facilityFormKind(ctx.currentType()))
return { ...ctx.facilityOptions.readOptions(), ...shapes };
const values: Record<string, string | number> = { ...shapes };
ctx.optionInputs.forEach((input) => {
// 빈 칸은 아예 넣지 않는다 — 빈 숫자를 0으로 저장하면 "0으로 확정"과 구분이 안 된다.
if (input.isEmpty()) return;
values[input.key] = input.read();
});
return values;
return { ...values, ...readStructureSpec(ctx.optionRow, ctx.currentType()) };
}
export function emit(ctx: StructuresCommitContext): void {
@@ -241,7 +258,7 @@ export async function commit(ctx: StructuresCommitContext, live = false): Promis
}
// 배수관 등 계곡 통과 시설은 점형 — 기준 측점 하나뿐이다(2026-08-17 지시 2).
const attributes: FacilityAttributes = { facility: type.type_id as PipeFacility };
const options = ctx.facilityOptions.readOptions();
const options = readOptions(ctx);
if (Object.keys(options).length) attributes.options = options;
// 집계 항목 — 미지정(null)도 그대로 실어 옛 지정을 풀 수 있게 한다.
attributes.summary_item = ctx.summary();
@@ -312,8 +329,9 @@ export async function commit(ctx: StructuresCommitContext, live = false): Promis
}
// 필수 옵션(미확정 기본값 없음)이 비어 있으면 추가하지 않는다 — 서버도 거절한다.
// 상세(detail) 옵션은 폼에 없으므로 여기 걸리지 않는다(B06/B07에서 받는다).
// 실시간 반영은 막지 않음 — 빈 칸은 표시 · 안내만(`markRequired` · 54-12), 막기는 [추가] · 서버 [저장]
const missing = ctx.optionInputs.find((entry) => entry.required && entry.isEmpty());
if (missing) {
if (missing && !live) {
missing.input.focus();
return;
}
@@ -361,9 +379,13 @@ export async function commit(ctx: StructuresCommitContext, live = false): Promis
...previous,
...records[0],
options: mergeStructureOptions(
previous,
asRoad(previous), // 옛 대피 종류를 대피로로 고쳐도 옛 칸 값은 남김(52-7)
type.type_id,
ctx.optionInputs.map((entry) => entry.key),
[
...ctx.optionInputs.map((entry) => entry.key),
...ctx.groupBoxes.shapeKeys(),
...specRenderedKeys(type, previous.options), // 명세 폼 키(52-10) — 비운 칸 · 뺀 컨테이너는 지움
],
records[0].options,
),
};
@@ -10,10 +10,16 @@
import type { StructureInstance, StructureType } from "./B05_Profile_Api_Structures";
import type { StructuresCommitContext } from "./B05_Profile_UI_Structures_Panel_Commit";
import { asRoad } from "./B05_Profile_UI_Structures_Define";
import { readState, writeState } from "../A00_Common/b_page_state";
import { NO_SELECTION, PIPE_MATCH_M, selectDesign } from "../A00_Common/design/design_selection";
import { readGroupItems, readSummaryItem } from "../common_util/common_util_summary_item";
/** 배선에 필요한 패널 내부 값 — 이름은 분리 전 지역변수와 같다. */
/** 배선에 필요한 값 — 저장 쪽(`StructuresCommitContext`)과 겹치는 것은 그대로 물려받는다. */
export interface StructuresEventContext extends StructuresCommitContext {
/** 종류별 캐시(54-32) 세션 키의 프로젝트. */
projectId: string | null;
typeSelect: HTMLSelectElement;
primary: HTMLButtonElement;
removeButton: HTMLButtonElement;
@@ -31,32 +37,106 @@ export interface StructuresEventContext extends StructuresCommitContext {
}
export function bindStructuresEvents(ctx: StructuresEventContext): void {
/** 새로 놓기(54-32) — 고름 · 측점 · 강조를 풀고 군(· 종류)만 남긴 빈 기본값 폼. */
function startNew(group: string, typeId?: string): void {
ctx.resetForm();
// 횡단 카드 · 부재 강조와 넘김 선택도 풂 — B05 → B06 넘김에서 되얹지 않게(54-38)
ctx.callbacks.onListRelease?.();
selectDesign(ctx.projectId, NO_SELECTION, { from: "b05" });
ctx.groupSelect.value = group;
ctx.syncTypeOptions(typeId);
}
ctx.groupSelect.addEventListener("change", () => {
ctx.cancelTempPipe(); // 종류가 달라진다 — 임시 배치는 취소(2026-08-18).
ctx.syncTypeOptions();
// 종류가 바뀌면 기존 항목 수정이 아니라 새 항목 추가로 넘어간다(옵션 스키마가 달라진다).
if (ctx.editingId()) {
ctx.setEditingId(null);
ctx.syncButtons();
ctx.renderList();
ctx.callbacks.onSelect(null);
}
// 고른 항목에서 군을 바꿈 = 새 항목 추가(54-32) — 고른 항목 값은 그대로
if (ctx.editingId() || ctx.selectedPipeChainage() !== null) startNew(ctx.groupSelect.value);
else ctx.syncTypeOptions();
});
ctx.typeSelect.addEventListener("change", () => {
ctx.cancelTempPipe(); // 종류가 달라진다 — 임시 배치는 취소(2026-08-18).
if (ctx.editingId() || ctx.selectedPipeChainage() !== null) return switchSelectedType();
ctx.syncPlacementFields();
ctx.renderOptionFields();
// 배수관·BOX암거·세월교·독립 기슭막이는 부속 옵션 서브폼이 따라 열려야 한다 —
// 수동 추가든 자동 배치 지점 편집이든 같은 옵션을 받는다(2026-08-17 사용자 지시:
// 자동은 통수단면으로 자리를 잡아 준 것일 뿐 같은 구조물이다).
ctx.syncFacilityForm();
if (ctx.editingId()) {
ctx.setEditingId(null);
ctx.syncButtons();
ctx.renderList();
ctx.callbacks.onSelect(null);
}
});
/** 고른 항목의 종류를 같은 군 안에서 바꿈(54-32) — 그 항목이 새 종류가 됨. 옛 종류 값은
* 종류별 캐시에 담고, 담아 둔 종류로 돌아오면 그 값으로 · 처음이면 새 종류 기본값으로.
* 관 지점 시설(배관 ↔ 박스 ↔ 세월교 ↔ 물넘이)도 같은 규칙 · 실시간 반영은 54-4 길 그대로. */
function switchSelectedType(): void {
const next = ctx.currentType();
const id = ctx.editingId();
const pipe = ctx.selectedPipeChainage();
const index = id ? ctx.structures.findIndex((entry) => entry.structure_id === id) : -1;
const record = index >= 0 ? ctx.structures[index] : null;
const pipeItem =
pipe === null
? null
: ctx.pipeFacilities().find((entry) => Math.abs(entry.chainage_m - pipe) < PIPE_MATCH_M);
const prev = ctx.typeMap().get(record ? asRoad(record).type_id : (pipeItem?.facility ?? ""));
// 정본이 다른 종류(관 지점 ↔ 구조물)로 · 빈칸으로 = 새로 놓기
if (!next || !prev || !!next.managed_by !== !!prev.managed_by)
return startNew(ctx.groupSelect.value, next?.type_id);
const key = record ? `s:${id}` : `p:${pipe}`;
// 구조물은 정본 기록(안 보이는 상세 칸까지) · 관은 아직 옛 종류로 그려진 폼에서 읽음
stashTypeValues(
key,
prev.type_id,
record
? {
options: record.options,
summary_item: record.summary_item,
group_items: record.group_items,
}
: {
options: { ...ctx.facilityOptions.readOptions(), ...ctx.groupBoxes.shapes() },
summary_item: ctx.summary(),
group_items: ctx.groupBoxes.get(),
},
);
const back = recallTypeValues(key, next.type_id);
// 기록을 새 종류로 갈아 둠 — 되살린 값의 안 보이는 칸이 [수정] 병합에서 살게
const draft = record && { ...record, type_id: next.type_id, options: back?.options ?? {} };
if (draft) ctx.structures[index] = draft;
ctx.syncPlacementFields();
ctx.renderOptionFields(back?.options);
ctx.setSummary(readSummaryItem(back?.summary_item));
ctx.groupBoxes.set(readGroupItems(back?.group_items));
ctx.groupBoxes.setShapes(back?.options ?? {});
ctx.syncFacilityForm(back?.options);
ctx.liveCommit();
// 반영이 막혀(측점 등) 기록이 그대로면 옛 기록으로 되돌림
if (record && draft && ctx.structures[index] === draft) ctx.structures[index] = record;
}
type TypeValues = {
options?: Record<string, string | number>;
summary_item?: unknown;
group_items?: unknown;
};
type TypeCache = Record<string, Record<string, TypeValues>>;
/** 관 지점은 재계산 스냅으로 누가거리가 살짝 옮겨짐 — 관 매칭 기준 안이면 같은 관. */
function cacheKeyOf(cache: TypeCache, key: string): string {
if (!key.startsWith("p:")) return key;
const at = Number(key.slice(2));
const hit = Object.keys(cache).find(
(k) => k.startsWith("p:") && Math.abs(Number(k.slice(2)) - at) < PIPE_MATCH_M,
);
return hit ?? key;
}
function stashTypeValues(key: string, typeId: string, values: TypeValues): void {
const cache = readState<TypeCache>("structure-type-cache", ctx.projectId) ?? {};
const slot = cacheKeyOf(cache, key);
cache[slot] = { ...cache[slot], [typeId]: values };
writeState("structure-type-cache", cache, ctx.projectId);
}
function recallTypeValues(key: string, typeId: string): TypeValues | null {
const cache = readState<TypeCache>("structure-type-cache", ctx.projectId) ?? {};
return cache[cacheKeyOf(cache, key)]?.[typeId] ?? null;
}
ctx.primary.addEventListener("click", () => void ctx.commit());
ctx.removeButton.addEventListener("click", () => {
// 임시 배치 중이면 취소와 같다 — 관을 물리고 추가 직전 상태로(2026-08-18).
@@ -11,7 +11,32 @@
import { isB05Option, type StructureType } from "./B05_Profile_Api_Structures";
import type { PipeFacility } from "../B04_PreProcess/B04_PreProcess_Api_Fetch";
import { field, optionControl } from "./B05_Profile_UI_Structures_Fields";
import { isOptionVisible } from "./B05_Profile_UI_Structures_Summary";
import {
columnsOf,
gridPlace,
orderedOptions,
ruleDefaults,
ruleStates,
staleValues,
} from "./B05_Profile_UI_Structures_Define";
import { FORM_OPTION_KEYS } from "./B05_Profile_UI_Drainage_Facility_Merge";
import { stepper } from "./B05_Profile_UI_Drainage_Facility_Fields";
import { STRUCTURE_SPECS } from "../A00_Common/design/design_structure_pipe";
import { paintStructureSpec, specOwnedKeys } from "./B05_Profile_UI_Structures_Spec";
import { solveSplit, specKeys, type SplitRole } from "../A00_Common/design/design_structure_spec";
/** 종류 단위 「구조물 조합」 줄을 가릴 종류인지 — 구조물 명세 컨테이너 · 정의 그룹 상자(그룹마다 잇기 줄)로
* 그리는 종류(PLAN 52-1 · 52-6b · 52-7) · 종단배수(B군 · 조합 잇기 없음 · 표 07). */
export const hidesTypeSummary = (type: StructureType): boolean =>
!!STRUCTURE_SPECS[type.type_id]?.containers.length || !!type.groups?.length || type.group === "B";
/** 길이 = 전 + 후 를 배관 맞물림(`solveSplit` · 마지막에 고친 둘을 지킴)으로 푸는 종류(표 07 가드레일 · 표 09 흙막이 · 옹벽). */
const SOLVE_SPLIT = new Set(["guardrail", "soil_guard", "retaining_wall"]);
const SPLIT_ROLE: Record<string, SplitRole> = {
length_m: "length",
before_m: "before",
after_m: "after",
};
/** 패널이 쥔 값 중 옵션 그리기에 필요한 것들. 이름은 분리 전 지역변수와 같다. */
export interface OptionRenderContext {
@@ -46,39 +71,60 @@ export function renderOptionFields(
optionInputs.length = 0;
optionRow.replaceChildren();
// 서브폼이 담당하는 타입(계곡 통과 시설·독립 기슭막이)은 여기서 그리지 않는다.
// 차례 · 안 씀 · 숨김은 정의대로(48-3 · `_Structures_Define`).
// 명세 종류(52-10)는 명세 키 · 명세가 뺀 옛 키를 칸으로 안 그림 — 명세 폼이 옵션 칸 아래에 그림
const owned = specOwnedKeys(type);
const shown =
type && !ctx.facilityFormKind(type)
? type.options.filter((o) => (ctx.includeDetail || isB05Option(o)) && isOptionVisible(o))
? orderedOptions(type).filter(
(o) => (ctx.includeDetail || isB05Option(o)) && !owned.has(o.key),
)
: [];
if (!shown.length) {
paintStructureSpec(optionRow, type, values);
optionRow.style.gridTemplateColumns = "";
if (!type || !shown.length) {
optionRow.hidden = true;
ctx.syncOptionLock();
return;
}
optionRow.hidden = false;
const columns = columnsOf(type);
if (columns !== 2) optionRow.style.gridTemplateColumns = `repeat(${columns}, minmax(0, 1fr))`;
// 규칙(48-4)이 가린 칸은 `optionInputs` 에서 뺌 — 필수 검사 · 저장이 안 봄(옛 값은 병합이 지킴)
const all: Array<{ entry: (typeof optionInputs)[number]; wrap: HTMLElement }> = [];
shown.forEach((option) => {
// 받은 값만 칸에 — 새 구조물은 부르는 쪽(패널)이 등록부 기본값을 `values` 로 실어 줌(PLAN 46-7).
const input = optionControl(option, values[option.key]);
// 보기는 정의 전부로 세워 옛 값을 잃지 않고, 숨김 · 규칙 선택지는 `applyRules` 가 좁힘.
const name = (c: string): string => type.spec_names?.[`${option.key}=${c}`] ?? c;
const input = optionControl(option, values[option.key], name);
const label = `${option.unit ? `${option.label} (${option.unit})` : option.label}${option.not_in_table ? " · 표에 안 쓰임" : ""}`;
// `enabled:false` 는 칸을 남기고 잠그기만 한다 — 값은 기본값이 그대로 저장된다
// (고를 수 없는 칸이라 제안이 아니라 프로그램 값).
const locked = option.enabled === false;
if (locked && !input.value) input.value = String(option.default ?? "");
if (locked) {
input.disabled = true;
input.classList.add("is-locked");
input.title = "지금은 고를 수 없는 항목입니다.";
}
const wrap = field(label, input, option.default_basis);
// 정의 그룹 상자로 옮겨 갈 숫자 칸 = 명세 컨테이너와 같은 [-][숫자][+](52-18)
const grouped =
option.input === "number" && !!type.groups?.some((g) => g.options.includes(option.key));
const wrap = field(label, grouped ? stepper(input as HTMLInputElement, 0.1) : input);
if (grouped) wrap.htmlFor = input.id; // 라벨 대상 = 숫자 칸(첫 버튼으로 새지 않게)
wrap.dataset.optionKeys = option.key; // 옵션 그룹 상자가 이 표식으로 칸을 옮김(PLAN 46-3)
// 배치 격자(48-3) — 정의 `배치` 의 줄 · 칸 · 너비 · 없으면 흐름대로
const place = gridPlace(type.spots?.[option.key], columns);
wrap.style.gridRow = place?.row ?? "";
wrap.style.gridColumn = place?.column ?? "";
optionRow.append(wrap);
input.addEventListener("change", () => ctx.liveCommit());
optionInputs.push({
key: option.key,
required: !locked && !!option.required,
input,
read: () => (option.input === "number" ? Number(input.value) || 0 : input.value),
isEmpty: () => input.value.trim() === "",
// 상위 값이 바뀌면 하위 기본값 · 선택지 · 보이기를 먼저 맞추고 반영(48-4)
input.addEventListener("change", () => {
applyRules(option.key);
markRequired(optionInputs, optionRow);
ctx.liveCommit();
});
input.addEventListener("input", () => markRequired(optionInputs, optionRow));
all.push({
wrap,
entry: {
key: option.key,
required: !!option.required,
input,
read: () => (option.input === "number" ? Number(input.value) || 0 : input.value),
isEmpty: () => input.value.trim() === "",
},
});
// 전면 기울기는 품셈 표준경사 표(0.20~0.50) 밖 값도 받는다 — 실무 도면이 S0.7·S0.8 을
// 쓴다(2026-09-09 실무 DWG 확인). **막지 않고 알리기만** 한다: 막으면 실물이 안 들어간다.
@@ -104,12 +150,155 @@ export function renderOptionFields(
"length" | "before_m" | "after_m";
const refresh = (normalize: boolean): void => {
input.classList.remove("is-invalid");
ctx.syncSplitInputs(source, normalize);
if (SOLVE_SPLIT.has(type!.type_id)) {
solveInto(option.key); // 타이핑 중에도 — change 의 실시간 반영이 푼 값을 읽게
ctx.syncRangeDisplay();
} else ctx.syncSplitInputs(source, normalize);
};
input.addEventListener("input", () => refresh(false));
input.addEventListener("change", () => refresh(true));
}
});
// 숨긴 길이 · 전 · 후(표 09 소단) — 칸은 안 그리고 값만 쥠: 범위 계산 · 저장이 옛 값 · 기본값을 이어 씀(54-26)
for (const option of type.options) {
if (!SPLIT_ROLE[option.key] || option.visible !== false) continue;
const input = document.createElement("input");
input.value = values[option.key] === undefined ? "" : String(values[option.key]);
all.push({
wrap: document.createElement("div"),
entry: {
key: option.key,
required: false,
input,
read: () => Number(input.value) || 0,
isEmpty: () => input.value.trim() === "",
},
});
}
/** 길이 · 전 · 후 맞물림 — 고친 차례(최근이 앞)를 쥐고 나머지 하나를 셈. */
const recent: SplitRole[] = [];
function solveInto(key: string): void {
const role = SPLIT_ROLE[key];
recent.splice(0, recent.length, role, ...recent.filter((r) => r !== role));
const inputOf = (r: SplitRole) =>
all.find(({ entry }) => SPLIT_ROLE[entry.key] === r)?.entry.input;
const values = Object.fromEntries(
(["length", "before", "after"] as SplitRole[]).map((r) => [r, inputOf(r)?.value ?? ""]),
);
const solved = solveSplit(values, recent);
for (const r of ["length", "before", "after"] as SplitRole[]) {
const input = inputOf(r);
if (input) input.value = solved[r] ?? "";
}
}
/** 규칙 걸기 — `parent` 가 바뀐 칸이면 그 칸에 매인 기본값부터 넣음. */
function applyRules(parent: string | null): void {
const now = (): Record<string, string> =>
Object.fromEntries(all.map(({ entry }) => [entry.key, entry.input.value]));
if (parent) {
for (const [key, value] of Object.entries(ruleDefaults(type!, parent, now()))) {
const hit = all.find(({ entry }) => entry.key === key);
if (hit) hit.entry.input.value = String(value);
}
}
const next = ruleStates(type!, now());
optionInputs.length = 0;
for (const { entry, wrap } of all) {
const state = next.get(entry.key);
const off = state?.visible === false;
wrap.classList.toggle("is-rule-hidden", off); // 그룹 상자로 옮겨 가도 같은 표식
if (!off) optionInputs.push(entry);
if (state && entry.input.tagName.toLowerCase() === "select")
syncChoices(
entry.input as HTMLSelectElement,
state.choices,
(c) => type!.spec_names?.[`${entry.key}=${c}`] ?? c,
);
}
}
applyRules(null);
ctx.syncOptionLock();
ctx.syncRangeDisplay();
}
/** 빈 필수 칸 표시(54-12) — 칸 테두리 + 그 칸이 든 상자(격자) 안 안내 한 줄. 칸이 그룹 상자로 옮겨 간
* 뒤에도 맞게 패널이 칸 그리기 · 그룹 다시 세우기 · 값 바꿈마다 부름. 막지 않음(막기는 [추가] · [저장]). */
export function markRequired(
optionInputs: OptionRenderContext["optionInputs"],
optionRow: HTMLElement,
): void {
const scope = optionRow.parentElement ?? optionRow;
scope.querySelectorAll(".b05-structure__required-note").forEach((note) => note.remove());
scope
.querySelectorAll(".is-required-empty")
.forEach((input) => input.classList.remove("is-required-empty"));
for (const entry of optionInputs) {
if (!entry.required || !entry.isEmpty()) continue;
entry.input.classList.add("is-required-empty");
const box = entry.input.closest<HTMLElement>("[data-option-keys]")?.parentElement;
if (!box || box.querySelector(":scope > .b05-structure__required-note")) continue;
const note = document.createElement("p");
note.className = "b05-structure__required-note";
note.textContent = "필수 칸 비어 있음 — [저장] 전 채움";
box.append(note);
}
}
/** 고르기 칸 보기를 규칙 선택지로 — 빈 보기는 남기고, 지금 값이 목록 밖이면 그 값만 남겨 보임. */
function syncChoices(
element: HTMLSelectElement,
choices: string[],
label: (choice: string) => string,
): void {
// 빈 보기는 선택 칸에만(54-43 · 필수 칸은 없음)
const blank = [...element.options].filter((o) => o.value === "").slice(0, 1);
const now = [...element.options].filter((o) => o.value !== "").map((o) => o.value);
const keep = element.value && !choices.includes(element.value) ? [element.value] : [];
const want = [...choices, ...keep];
if (now.length === want.length && now.every((v, i) => v === want[i])) return;
const value = element.value;
element.replaceChildren(...blank, ...want.map((c) => new Option(label(c), c)));
element.value = value;
if (element.selectedIndex < 0) element.selectedIndex = 0;
}
/** 「지난 정의 값」 상자(48-3) — 지금 정의에 없는 키의 값을 읽기만 칸으로 보임(오류 없음 · 저장은
* 병합이 옛 값 그대로 지킴). 아는 키 = 정의 옵션 전부(안 씀 포함) + 시설 폼이 적는 칸. */
export function paintStale(
box: HTMLElement,
type: StructureType | null,
values: Record<string, string | number> | undefined,
facility: PipeFacility | null,
/** 그룹 형상 키(`{그룹 id}__{칸}`) — 정의된 그룹 몫이라 지난 값이 아님. */
shapeKeys: string[] = [],
): void {
// 명세 종류(52) — 명세가 뺀 옛 키(retired)는 지난 정의 값 · 선택 컨테이너 키(머리)는 앎
const spec = type ? STRUCTURE_SPECS[type.type_id] : undefined;
const own = spec ? specKeys(spec) : { keys: [], prefixes: [] };
const known = [
...shapeKeys,
...(type?.options ?? []).map((o) => o.key),
...(facility ? (FORM_OPTION_KEYS[facility] ?? []) : []),
...own.keys,
].filter((key) => !spec?.retired.includes(key));
const stale = type
? staleValues(values, known).filter(([key]) => !own.prefixes.some((p) => key.startsWith(p)))
: [];
box.replaceChildren();
// 상자는 모든 종류에서 숨김(54-1) — 값은 파일에 그대로
box.hidden = true;
if (!stale.length) return;
const legend = document.createElement("legend");
legend.textContent = "지난 정의 값";
const body = document.createElement("div");
body.className = "b05-structure__grid";
for (const [key, value] of stale) {
const input = document.createElement("input");
input.type = "text";
input.readOnly = true;
input.value = String(value);
input.title = "지금 정의에 없는 칸 — 읽기만 · 계산에 안 쓰임";
body.append(field(key, input));
}
box.append(legend, body);
}
@@ -34,6 +34,53 @@ export const GROUP_LABELS: Record<string, string> = {
호환: "기타",
};
/** 새로 놓을 때 고르기 목록(군 드롭다운 · 우클릭 메뉴)에서 뺄 군 — 종단배수·계류사방(표 07).
* 옛 값 · 도면 · 집계는 그대로이고 데이터도 지우지 않는다. */
export const HIDDEN_PICK_GROUPS: ReadonlySet<string> = new Set(["B", "D"]);
/** 고르기 목록에서 뺄 종류 — 사면안정은 흙막이 · 옹벽 · 소단만(54-31). 옛 값은 그대로. */
export const HIDDEN_PICK_TYPES: ReadonlySet<string> = new Set([
"masonry_wet",
"masonry_dry",
"boulder_masonry",
]);
/** 새로 놓을 때 고르기 목록에서 가릴 종류인가 — 뺄 군이거나 뺄 종류. */
export function isPickHidden(type: { group: string; type_id: string }): boolean {
return HIDDEN_PICK_GROUPS.has(type.group) || HIDDEN_PICK_TYPES.has(type.type_id);
}
/** 고르기 목록 항목 — 가릴 항목은 가림(옛 항목을 열 때는 값으로 그대로 고를 수 있음). */
export function pickOption(text: string, value: string, hidden: boolean): HTMLOptionElement {
const option = new Option(text, value);
option.hidden = hidden;
if (hidden) option.dataset.pickHidden = ""; // 정의 폼의 「가림 풀기」가 건드리지 않게
return option;
}
/** 군 드롭다운 항목들 — 이름은 정의(48) 먼저 · 뺄 군과 고를 종류가 없는 군은 가림. */
export function groupOptions(
types: StructureType[],
pick: (type: StructureType) => boolean,
): HTMLOptionElement[] {
const groups = new Map(types.map((t) => [t.group, t.group_name] as const));
return [...groups].map(([g, name]) =>
pickOption(
name ?? GROUP_LABELS[g] ?? g,
g,
!types.some((t) => t.group === g && pick(t) && !isPickHidden(t)),
),
);
}
/** 종류 드롭다운 항목들 — 고를 수 없거나 뺄 종류는 가림. */
export function typeOptions(
types: StructureType[],
pick: (type: StructureType) => boolean,
): HTMLOptionElement[] {
return types.map((t) => pickOption(t.name, t.type_id, !pick(t) || isPickHidden(t)));
}
/** 구간형 신규 추가 시 기본 구간 길이(m). 사용자가 종점을 바로 고칠 수 있게 짧게 잡는다. */
export const DEFAULT_INTERVAL_LENGTH_M = 15;
@@ -83,8 +130,9 @@ export interface StructuresSection {
/** 배치된 구조물 목록(<ul>) — 섹션 본문이 아니라 사이드 하단 고정 영역에 붙인다
* (2026-08-18 사용자 지시: 폼 길이에 밀려 목록이 화면 밖으로 나가던 문제). */
listRoot: HTMLElement;
/** 서버에서 받은 타입 목록을 채운다(최초 1회). */
setTypes: (types: StructureType[]) => void;
/** 서버에서 받은 타입 목록을 채운다(최초 1회). 이름·폼은 넘긴 종류 전부로 풀고,
* 고르기 목록엔 `pick` 이 고른 종류만 보임(빼면 전부). */
setTypes: (types: StructureType[], pick?: (type: StructureType) => boolean) => void;
/** 서버 정본으로 목록을 교체한다(진입·복원·저장 후). */
setStructures: (structures: StructureInstance[]) => void;
getStructures: () => StructureInstance[];
@@ -136,6 +184,8 @@ export interface StructuresCallbacks {
* 목록에서 직접 고른 경우엔 이미 펼쳐져 있어 아무 일도 안 한다.
*/
onReveal?: () => void;
/** 목록에서 고른 줄을 다시 눌러 풂 — 다른 화면의 고름(횡단 카드)도 함께 끔(54-8). */
onListRelease?: () => void;
}
type OptionEntry = { key: string; read: () => string | number; isEmpty: () => boolean };
@@ -0,0 +1,89 @@
/* =============================================================================
* B05_Profile_UI_Structures_Spec.ts
* 일반 구조물(structures.json) 명세 컨테이너 폼(PLAN 52-10) — 계곡 통과 시설 밖 종류가 명세
* (`STRUCTURE_SPECS`)를 가지면 옵션 칸 아래에 같은 공용 폼(`design_structure_form`)을 그림.
*
* · 폼은 옵션 칸(`optionRow`) 짝으로 하나 — 조립기가 세워 걸고, 옵션 그리기 · 저장이 꺼내 씀
* · 명세 키 · 명세가 뺀 옛 키(retired)는 정의 옵션 칸으로 그리지 않음(옛 값은 병합이 지킴)
* · 잠금은 옵션 칸을 따름(측점 확정 전 흐림 · 조작 막음)
* ========================================================================== */
import type { StructureType } from "./B05_Profile_Api_Structures";
import {
createSpecForm,
type SpecForm,
type SpecLinks,
} from "../A00_Common/design/design_structure_form";
import { STRUCTURE_SPECS } from "../A00_Common/design/design_structure_pipe";
import { specKeys, type StructureSpec } from "../A00_Common/design/design_structure_spec";
import { optionDefaults } from "./B05_Profile_UI_Structures_Fields";
const forms = new WeakMap<HTMLElement, SpecForm>();
/** 일반 구조물 명세 — 계곡 통과 시설(관 지점 정본)은 시설 폼 몫이라 뺌. */
export const structureSpecOf = (type: StructureType | null): StructureSpec | null =>
(type && !type.managed_by && STRUCTURE_SPECS[type.type_id]) || null;
/** 옵션 칸 짝 폼을 세움 — 값이 바뀌면 `onChange`(패널 즉시 반영). */
export function createStructureSpecForm(
optionRow: HTMLElement,
links: SpecLinks,
onChange: () => void,
): SpecForm {
const form = createSpecForm(links, { onChange });
form.root.hidden = true;
forms.set(optionRow, form);
const lock = (): void => {
const locked = optionRow.classList.contains("is-locked");
form.root.inert = locked;
form.root.classList.toggle("is-locked", locked);
};
if (typeof MutationObserver !== "undefined")
new MutationObserver(lock).observe(optionRow, {
attributes: true,
attributeFilter: ["class"],
});
return form;
}
/** 정의 옵션 칸으로 안 그리는 키 — 명세 키 · 명세가 뺀 옛 키. */
export function specOwnedKeys(type: StructureType | null): Set<string> {
const spec = structureSpecOf(type);
return new Set(spec ? [...specKeys(spec).keys, ...spec.retired] : []);
}
/** 종류 · 값으로 명세 폼을 다시 그림(명세 없는 종류면 가림). */
export function paintStructureSpec(
optionRow: HTMLElement,
type: StructureType | null,
values: Record<string, string | number>,
): void {
const form = forms.get(optionRow);
const spec = structureSpecOf(type);
if (!form) return;
form.root.hidden = !spec;
if (!spec) return;
const groups = Object.fromEntries((type?.groups ?? []).map((g) => [g.id, g.name]));
form.write(spec, values, type?.spec_names ?? {}, groups, optionDefaults(type?.options ?? []));
}
/** 명세 폼 값(저장 키 그대로) — 명세 없는 종류면 빈 묶음. */
export function readStructureSpec(
optionRow: HTMLElement,
type: StructureType | null,
): Record<string, string | number> {
const form = forms.get(optionRow);
return form && structureSpecOf(type) ? form.read() : {};
}
/** [수정] 병합에서 폼이 다시 쓰는 키 — 명세 키 + 옛 값 중 선택 컨테이너 머리 키(빼면 지워져야 함). */
export function specRenderedKeys(
type: StructureType | null,
previous: Record<string, string | number> | undefined,
): string[] {
const spec = structureSpecOf(type);
if (!spec) return [];
const { keys, prefixes } = specKeys(spec);
const own = Object.keys(previous ?? {}).filter((key) => prefixes.some((p) => key.startsWith(p)));
return [...keys, ...own];
}
@@ -8,9 +8,9 @@
* import 없음 — 시험이 이 파일만 옮겨 돌림.
* ========================================================================== */
/** 옵션 보이기 — 서버가 채운 `visible`(21-8)이 false 일 때만 숨김. 없으면 보임. */
export function isOptionVisible(option: { visible?: boolean }): boolean {
return option.visible !== false;
/** 옵션 보이기 — 서버가 채운 `visible`(21-8)이 false 이거나 정의가 「안 씀」(`enabled:false` · 48)일 때 숨김. */
export function isOptionVisible(option: { visible?: boolean; enabled?: boolean }): boolean {
return option.visible !== false && option.enabled !== false;
}
/** 저장할 옵션 — 같은 종류를 고치는 중이면 폼이 안 그린 옛 칸을 이어 붙임.
@@ -23,30 +23,38 @@ export interface SummaryRow {
}
export function buildSummaryRow(): SummaryRow {
// 옵션 칸과 같은 2행 꼴(54-17) — 위 제목(`b05-route__field > span`) · 아래 [이름 칸][선택][해제]
const root = document.createElement("div");
root.className = "b05-structure__summary";
root.className = "b05-route__field b05-structure__summary";
root.dataset.b05Summary = "row";
const label = document.createElement("span");
label.className = "b05-structure__summary-label";
label.textContent = "집계 항목";
const name = document.createElement("span");
label.textContent = "구조물 조합";
// 이름 = 읽기 전용 입력 칸 — 옵션 입력 칸과 글꼴 · 크기 · 칸 모양이 같음
const name = document.createElement("input");
name.type = "text";
name.readOnly = true;
name.tabIndex = -1;
name.className = "b05-structure__summary-name";
const pick = document.createElement("button");
pick.type = "button";
pick.className = "b05-route__irregular-btn";
pick.textContent = "고르기";
pick.textContent = "선택";
pick.dataset.b05Summary = "pick";
const clear = document.createElement("button");
clear.type = "button";
clear.className = "b05-route__irregular-btn";
clear.textContent = "해제";
clear.dataset.b05Summary = "clear";
root.append(label, name, pick, clear);
const line = document.createElement("div");
line.className = "b05-route__irregular-actions";
line.append(name, pick, clear);
root.append(label, line);
let current: SummaryItem | null = null;
const set = (item: SummaryItem | null): void => {
current = item;
name.textContent = summaryLabel(item);
name.value = summaryLabel(item);
name.title = summaryTooltip(item);
name.classList.toggle("is-assigned", item !== null);
clear.disabled = item === null;
+4
View File
@@ -395,6 +395,10 @@
cursor: pointer;
}
.b05-route__irregular-item:hover {
border-color: var(--color-royal-amethyst, rgb(109 40 217));
}
.b05-route__irregular-item.is-selected {
border-color: var(--color-royal-amethyst, rgb(109 40 217));
background: color-mix(in srgb, var(--color-royal-amethyst, rgb(109 40 217)) 12%, transparent);
+102 -47
View File
@@ -6,11 +6,11 @@
* ========================================================================== */
/* 구조물 알약 레인 — 그래프 바로 아래 한 줄(2026-08-17 사용자 지시 1·3·6).
높이는 2행분 고정이고, 겹치지 않으면 알약이 세로 가운데에 놓인다. */
높이는 2행분 고정이고, 겹치지 않으면 알약이 세로 가운데에 놓인다.
z-index 를 두지 않음 — 쌓임 층을 만들면 라벨이 그 안에 갇혀 ▲▼ 단추층(4) 밑으로 감(54-14). */
.b05-structure__lane {
position: relative;
overflow: visible;
z-index: 3;
}
/* 레인 왼쪽 Y축 띠 — 그래프 sticky Y축과 같은 폭·같은 배경으로 이어 붙여, 가로
@@ -105,7 +105,8 @@
/* 값 벌룬 — 유토곡선 벌룬과 같은 결(테두리 도형 + 여러 줄 텍스트). */
/* 벌룬은 알약 위로 뜬다(2026-08-18) — 아래는 도면 테이블에 가린다. 전개 방향:
1행 알약 = 좌측 위(is-left), 2행 = 우측 위(is-right), 솔로 = 위 중앙(is-center). */
1행 알약 = 좌측 위(is-left), 2행 = 우측 위(is-right), 솔로 = 위 중앙(is-center).
층 = 종단 패널 맨 위 — ▲▼ 단추층(4) · 고정 Y축 · 테이블 · 유토곡선(5) 위 · 우클릭 메뉴(7) 아래(54-14). */
.b05-structure__balloon {
position: absolute;
z-index: 6;
@@ -122,7 +123,6 @@
line-height: 1.35;
white-space: nowrap;
pointer-events: none;
z-index: 4;
}
.b05-structure__balloon.is-left {
@@ -138,11 +138,6 @@
font-size: 11.5px;
}
.b05-structure__balloon-memo {
opacity: 0.7;
font-style: italic;
}
/* ── 계곡 통과 시설 부속 옵션 서브폼 (구조물 배치 폼 안, 2026-08-17 UI 개편) ──
* 배관·BOX암거·세월교·독립 기슭막이의 부속 옵션을 2열 격자로 담는다. */
.b05-drainage__facility {
@@ -190,6 +185,7 @@
/* 측점 미입력 상태의 상세 옵션 잠금 — 입력 순서 가이드(2026-08-18 사용자 지시).
조작 차단은 disabled·inert가 맡고 여기서는 흐림만 그린다. */
.b05-structure__grid.is-locked,
.b05-structure__spec.is-locked,
.b05-drainage__facility.is-locked {
opacity: 0.5;
}
@@ -214,13 +210,6 @@
line-height: 1.5;
}
/* 칸 밑 근거 한 줄 — 등록부 `default_basis`(10-A). 회색 작은 글씨. */
.b05-structure__basis {
color: var(--color-text-muted, #9aa1ad);
font-size: var(--text-caption, 12px);
line-height: 1.3;
}
/* 시작·기준·종료 측점 = 3행. 한 행은 [라벨][측점][+거리] 가로 배치
* (2026-08-17 사용자 지시 2). */
.b05-structure__position-row {
@@ -250,6 +239,18 @@
background: rgba(224, 91, 91, 0.08);
}
/* 빈 필수 칸 — 칸 테두리 + 그 칸이 든 상자 안 안내 한 줄(54-12) */
.b05-route__field .is-required-empty {
border-color: #e05b5b;
}
.b05-structure__required-note {
grid-column: 1 / -1;
margin: 0;
color: #e05b5b;
font-size: var(--text-caption, 12px);
}
/* 측점 범위(계산 표시) — C군 등 길이 옵션 기반 구간 타입. 입력 칸이 아니라 기준
* 측점 + 길이로 계산된 "시작 ~ 종료"를 보여만 준다(2026-08-19 사용자 지시).
* 글자 크기는 기준 측점 입력 칸과 동일(크롬 input 기본 13.333px — 패널 입력에
@@ -433,33 +434,16 @@
border-color: var(--color-warning, #c98a00);
}
/* 집계 항목 줄(PLAN 21-4) — 옵션 · 시설 서브폼 아래 [이름][고르기][해제] 한 줄. 이름이 남는 폭을
* 먹고 말줄임 · 키는 툴팁에만. 지정되면 성공색(`.is-assigned`) — 목록 줄과 같은 색. */
.b05-structure__summary {
display: flex;
align-items: center;
gap: var(--spacing-8);
min-width: 0;
}
/* 구조물 조합 잇기 줄(PLAN 21-4 · 54-17) — 옵션 칸 꼴(`b05-route__field`) 2행 · 아래 줄은
* [이름 칸][선택][해제] · 이름 칸이 남는 폭을 먹고 말줄임 · 키는 툴팁에만. 지정되면 성공색. */
.b05-structure__summary[hidden] {
display: none;
}
.b05-structure__summary-label {
flex: none;
color: var(--color-text-secondary);
font-size: var(--text-caption);
}
.b05-structure__summary-name {
flex: 1 1 auto;
min-width: 0;
overflow: hidden;
color: var(--color-text-secondary);
font-size: var(--text-caption);
align-self: center;
text-overflow: ellipsis;
white-space: nowrap;
}
/* 글자는 성공색에 본문색을 섞어 대비 4.5 를 넘김(성공색 그대로는 밝은 테마에서 4.4). */
@@ -473,7 +457,37 @@
/* 목록 줄 — 집계 항목이 지정된 구조물 · 관은 왼쪽 선 + 이름 색으로(밝음 · 어두움 같은 토큰). */
.b05-route__irregular-item.is-assigned {
border-left: 3px solid var(--color-success);
/* 테두리 두께 대신 안쪽 그림자 — 글 시작 자리가 다른 줄과 같게(54-15) */
border-left-color: var(--color-success);
box-shadow: inset 2px 0 0 var(--color-success);
}
/* 목록 줄 잇기 램프(54-15) — 측점 왼쪽 고정 폭 칸 · 3행 × 열(위 → 아래 → 다음 열) ·
폭 = 목록에서 가장 많은 열(`--lamp-cols`) · 줄 높이를 늘리지 않음 */
.b05-route__lamps {
display: grid;
flex: none;
grid-auto-flow: column;
grid-template-rows: repeat(3, 5px);
grid-auto-columns: 5px;
gap: 2px;
align-self: center;
width: max(0px, calc(var(--lamp-cols, 0) * 7px - 2px));
}
.b05-route__lamps i {
border-radius: 50%;
background: var(--color-success);
}
.b05-route__lamps i.is-required {
background: var(--color-text-muted);
}
.b05-route__lamps i.is-optional {
box-sizing: border-box;
border: 1px solid var(--color-text-muted);
background: transparent;
}
.b05-route__irregular-item.is-assigned span {
@@ -498,20 +512,61 @@
}
.b05-structure__optgroup {
display: flex;
flex-direction: column;
gap: 6px;
}
.b05-structure__optgroup > legend {
font-weight: 600;
opacity: 1;
min-width: 0; /* 긴 집계 항목 이름이 상자를 패널 밖으로 밀지 않게(fieldset 최소 폭 · 52-9) */
}
.b05-structure__optgroup .is-option-hidden {
display: none;
}
.b05-structure__optgroup > .b05-structure__grid.is-locked {
opacity: 0.5;
/* 구조물 정의 규칙(PLAN 48-4)이 가린 칸 — 그룹 상자로 옮겨 가도 같은 표식 */
.b05-structure-section .is-rule-hidden {
display: none;
}
/* 「지난 정의 값」 읽기만 상자(PLAN 48-3) — 지금 정의에 없는 키의 값 */
.b05-structure__stale input[readonly] {
opacity: 0.7;
}
/* 구조물 명세 컨테이너(PLAN 52-1) — 상자 차례 · 긴 잇기 이름이 상자를 밀어 넓히지 않게(fieldset 최소 폭) */
.b05-structure__spec {
display: flex;
flex-direction: column;
gap: 6px;
}
.b05-structure__spec[hidden] {
display: none;
}
.b05-structure__spec .b05-structure__group {
min-width: 0;
}
.b05-structure__spec-add {
align-self: flex-start;
}
/* 반 폭 단추 둘 한 줄 — 관 보호공 [연동] · [경사](54-30). */
.b05-structure__half-pair {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 4px;
}
/* [연동] [경사] 한 줄(54-36) — 안 여백만 줄임 */
.b05-structure__half-pair > button {
padding-inline: 4px;
white-space: nowrap;
}
/* 상자 안 작은 단추 템플릿(54-41) — 높이 = 숫자 칸 [-][+](`--b05-control-h`) · 글 · 안 여백도 그 높이에 ·
* 상자 이름표 [빼기] · 상자 밖 [추가] · [삭제] · [리셋]은 제외 */
.b05-structure__group-body button:not(.b05-structure__step) {
box-sizing: border-box;
height: var(--b05-control-h);
min-height: 0;
padding-block: 0;
font-size: var(--text-caption);
line-height: 1;
}
+6 -3
View File
@@ -289,8 +289,9 @@ export function createRouteViewer(): RouteViewer {
iso: [distance, distance, distance],
// 정확히 수직이면 lookAt이 화면 방향을 못 정해 첫 드래그에 화면이 뒤집힌다.
top: [0, distance, distance * TOP_VIEW_TILT],
front: [0, distance * 0.25, distance],
side: [distance, distance * 0.25, 0],
// 정면 = 남에서 북을, 측면 = 동에서 서를 수평으로 본다(장면 +z 가 남, +x 가 동).
front: [0, 0, distance],
side: [distance, 0, 0],
} as const;
const [x, y, z] = positions[view];
const camera = cameraRig.camera();
@@ -309,7 +310,9 @@ export function createRouteViewer(): RouteViewer {
if (!bounds) return;
const width = bounds.x[1] - bounds.x[0];
const depth = bounds.y[1] - bounds.y[0];
placeCamera(new THREE.Vector3(0, 0, 0), Math.max(width, depth, 20) * 1.35, view);
// 수평 보기는 지형 앞 가장자리가 카메라에 가까워 원근에서 잘린다 — 그 반폭만큼 물린다.
const nearHalf = view === "front" ? depth / 2 : view === "side" ? width / 2 : 0;
placeCamera(new THREE.Vector3(0, 0, 0), Math.max(width, depth, 20) * 1.35 + nearHalf, view);
}
async function reloadContours(interval: number): Promise<void> {
+2 -3
View File
@@ -2,8 +2,7 @@
* B05_Profile_UI_Viewer_Camera.ts
* B05 뷰어의 **원근/직교 두 카메라**와 그 사이 갈아 끼우기.
*
* 기본은 원근(시야각 45°) — B04 지표면 화면과 같은 조작감이다(2026-09-04 사용자 확정).
* 탑뷰에서 크기를 정밀하게 대조할 때만 직교로 바꾼다. 갈아 끼울 때 위치·시선·근평면·
* 기본은 직교 — 원근(시야각 45°)은 단추로 고른다. 갈아 끼울 때 위치·시선·근평면·
* 먼평면과 **보이는 크기**를 그대로 옮기므로 화면이 튀지 않는다.
*
* 카메라 객체가 바뀌므로 쓰는 쪽은 붙잡아 두지 말고 `camera()`로 그때그때 읽을 것.
@@ -22,7 +21,7 @@ export function createCameraRig() {
const perspective = new THREE.PerspectiveCamera(FOV, 1, 0.1, 100000);
perspective.position.set(100, 120, 100);
const ortho = new THREE.OrthographicCamera(-100, 100, 100, -100, 0.1, 100000);
let kind: ProjectionKind = "perspective";
let kind: ProjectionKind = "ortho";
let aspect = 1;
let halfHeight = 100;
+192
View File
@@ -0,0 +1,192 @@
/* Old — 54-24 · 나중에 삭제 */
/* =============================================================================
* B05_Profile_UI_RouteCalc.ts
* 좌측 패널 「경로 계산 설정」 칸 — 포인트 팔레트 · 알고리즘 · 조건 · [최적 경로 계산](숨김).
* `B05_Profile_UI_Panel_Route.ts` · `_Panel_Sections.ts` · `_Page_Actions.ts` · `_Page_Helpers.ts`
* 에서 떼어 옮겼다. 어디서도 import 하지 않는다(tsconfig 제외).
* ========================================================================== */
import {
createSelectField,
hideLoadingOverlay,
showLoadingOverlay,
showToast,
} from "@ui/ui_template_elements";
import {
createSectionFrame,
part,
registerPanelSection,
} from "../../A00_Common/design/design_panel";
import { solveRoute, type CirclePoint, type RoutePoint } from "../B05_Profile_Api_Fetch";
import type { PlacedRoutePoint, RoutePointKind } from "../B05_Profile_UI_Markers";
import { button, checkbox, numberField, parseOptional } from "../B05_Profile_UI_Panel_Fields";
import type { PageActionContext } from "../B05_Profile_UI_Page_Actions";
export function createRouteCalcPart(callbacks: { onSolve: () => void }) {
const paletteGrid = document.createElement("div");
paletteGrid.className = "b05-route__palette";
const pointLabels: Record<RoutePointKind, string> = {
bp: "BP 시작점",
ep: "EP 종료점",
cp: "CP 경유점",
ap: "AP 회피구역",
fp: "FP 금지구역",
};
(Object.keys(pointLabels) as RoutePointKind[]).forEach((kind) => {
const chip = document.createElement("div");
chip.className = `b05-route__chip is-${kind}`;
chip.draggable = true;
chip.textContent = pointLabels[kind];
chip.addEventListener("dragstart", (event) => event.dataTransfer?.setData("pointType", kind));
paletteGrid.append(chip);
});
// 드롭다운은 공통 컴포넌트(createSelectField) 재사용. `.select`로 받아 이하 로직 불변.
const algorithmField = createSelectField({
label: "알고리즘",
options: [
{ value: "dijkstra", text: "Dijkstra" },
{ value: "ridge_valley", text: "능선·계곡" },
],
});
const algorithm = algorithmField.select;
const minCurveRadius = numberField("최소 곡선반경 (m)");
const maxUphillGrade = numberField("오르막 경사 상한 (%)");
const maxDownhillGrade = numberField("내리막 경사 상한 (%)");
const minUphillGrade = numberField("오르막 경사 하한 (%)");
const minDownhillGrade = numberField("내리막 경사 하한 (%)");
const paved = checkbox("포장 임도", false);
const avoidPass = checkbox("회피구역 통과 허용", false);
const details = document.createElement("details");
const summary = document.createElement("summary");
summary.textContent = "사용한 조건";
details.append(
summary,
minCurveRadius.wrapper,
maxUphillGrade.wrapper,
maxDownhillGrade.wrapper,
minUphillGrade.wrapper,
minDownhillGrade.wrapper,
);
// [최적 경로 계산] 입구는 2026-09-06 사용자 확정으로 화면에서 내렸다 — 평면만 보고
// 노선을 정하는 방식이라 실제 판단(평면·종단·횡단·유토곡선을 함께 봄)과 맞지 않는다.
const solveButton = button("최적 경로 계산", callbacks.onSolve, "filled");
solveButton.hidden = true;
return {
/** 「경로 계산 설정」 본문 — 화면 순서대로. */
calcNodes: [
paletteGrid,
algorithmField.root,
paved.wrapper,
avoidPass.wrapper,
details,
solveButton,
] as HTMLElement[],
fields: {
algorithm,
paved,
avoidPass,
minCurveRadius,
maxUphillGrade,
maxDownhillGrade,
minUphillGrade,
minDownhillGrade,
},
};
}
export type RouteCalcPart = ReturnType<typeof createRouteCalcPart>;
registerPanelSection({
id: "route-calc",
title: "경로 계산 설정",
views: ["profile"],
order: 40,
build: (ctx, view) => {
const frame = createSectionFrame(view, "경로 계산 설정", true);
frame.body.append(...part<RouteCalcPart>(ctx, "routeCalc").calcNodes);
// 경로 계산 설정 — 사용여부 미결정으로 조작 불가(숨기지 않는다, 2026-08-18 사용자
// 지시). inert가 본문 전체 입력·드래그를 막고, is-disabled가 흐림을 그린다.
// 제목 클릭(접기/펼치기)은 본문 밖이라 그대로 산다.
frame.root.classList.add("is-disabled");
frame.body.inert = true;
return frame.root;
},
});
export function routePoint(point: PlacedRoutePoint): RoutePoint {
// 서버 스키마는 표고를 빼면 "모름"으로 받는다 — null은 undefined로 바꿔 보낸다.
return { x: point.x, y: point.y, z: point.z ?? undefined };
}
export function circlePoint(point: PlacedRoutePoint): CirclePoint {
return { ...routePoint(point), radius_m: point.radius_m ?? 25 };
}
/** [경로 계산] — 마커·패널 값으로 노선을 풀고 종횡단까지 다시 받는다. */
export async function solveRouteAction(
ctx: PageActionContext,
calc: RouteCalcPart["fields"],
): Promise<void> {
const latest = ctx.latest();
const confirmedSurface = ctx.confirmedSurface();
if (!confirmedSurface || !latest) return;
const points = ctx.viewer().markers.getPoints();
if (!points.bp || !points.ep) {
showToast("BP와 EP를 지형에 배치하세요.", "error");
return;
}
const values = ctx.panel().values();
showLoadingOverlay();
try {
const solved = await solveRoute(ctx.projectId, {
filter_key: latest.surface_params.source_filter,
method: latest.surface_params.method,
smooth: latest.surface_params.smooth,
surface_model_id: confirmedSurface.model_id ?? undefined,
algorithm: calc.algorithm.value,
bp: routePoint(points.bp),
ep: routePoint(points.ep),
cp: points.cp.map(routePoint),
ap: points.ap.map(circlePoint),
fp: points.fp.map(circlePoint),
grade_class: values.gradeClass,
paved: calc.paved.checked,
min_curve_radius_m: parseOptional(calc.minCurveRadius),
max_uphill_grade: parseOptional(calc.maxUphillGrade),
max_downhill_grade: parseOptional(calc.maxDownhillGrade),
min_uphill_grade: parseOptional(calc.minUphillGrade),
min_downhill_grade: parseOptional(calc.minDownhillGrade),
allow_avoid_pass_through: calc.avoidPass.checked,
station_interval_m: values.stationInterval,
cross_half_width_m: null,
cross_sample_interval_m: values.crossSampleInterval,
long_sample_interval_m: values.longSampleInterval,
terrain_type: values.terrainType,
design_speed_kph: values.designSpeed,
max_grade_pct: values.maxGradePct,
min_vertical_radius_m: values.minVerticalRadius,
min_tangent_length_m: values.minTangentLength,
start_elevation_offset_m: values.startElevationOffset,
end_elevation_offset_m: values.endElevationOffset,
enforce_pipe_clearance: values.enforcePipeClearance,
});
// 새 경로는 측점 구성이 달라지므로 이전 상단측 변경분을 폐기한다(자동 판정 재사용).
ctx.uphillOverrides.clear();
ctx.persistUphillOverrides();
ctx.renderLatest(await ctx.loadLatest(true));
await ctx.restoreSections(solved.route_id);
if (solved.cross_section_count === null) {
showToast("경로는 저장되었지만 종횡단 생성에 실패했습니다.", "error");
} else if (solved.grade_summary === null) {
showToast("경로·종횡단은 저장되었지만 계획선 산출에 실패했습니다.", "error");
} else {
showToast("최적 경로 계산이 완료되었습니다.", "success");
}
} catch (error) {
showToast(error instanceof Error ? error.message : "경로 계산에 실패했습니다.", "error");
} finally {
hideLoadingOverlay();
}
}
+4
View File
@@ -207,6 +207,10 @@ export interface CulvertSideSpec {
/** 집수정 기준측점 전/후 몫(m) — 기슭막이와 같은 체계(2026-08-24). 기본 각 1m. */
basin_before_m?: number | null;
basin_after_m?: number | null;
/** 집수정 높이(m) — 좌측 폼 「높이」. 없으면 횡단도 자동(I형 노견 접점 · ㄴ·ㄷ형 내공 높이). */
basin_height_m?: number | null;
/** 집수정 모양(I · L · U) — 폼 「형태」(54-39) · 횡단 patch 형식이 없을 때 그림이 씀. 없으면 집수정 없음. */
basin_form?: string | null;
/** 기슭막이 전면 기울기(1:n) 종전값 — 그림은 `revetWallSpec().lean`(표준경사 표)을 씀. */
face_slope?: number;
/** 독립 기슭막이 기울기 판정 칸(저장 원본) — 설치 측 · 성토/절토 · 전면 기울기(B08 과 같은 칸). */
+6 -1
View File
@@ -124,8 +124,11 @@ function preserveUserFields(
/**
* 전 측점 횡단을 현재 계획선으로 다시 계산해 `detail.cross_sections[].design`을 제자리 교체한다.
* 돌려주는 값은 실제로 바뀐 측점의 누가거리 목록 — 호출한 쪽이 그 카드만 다시 그리면 된다.
* 계획선 ▲ 한 번에 값이 바뀌는 측점은 몇 개뿐 — 전부 돌려주면 카드를 다 갈아 끼워 멈춤(54-22).
*/
export async function refreshCrossDesigns(input: CrossRefreshInput): Promise<number[]> {
const sections = input.detail.cross_sections;
const before = new Map(sections.map((section) => [section, JSON.stringify(section.design)]));
const updated = refreshLocally(input) ?? (await refreshFromServer(input));
// 구조물이 선 측점은 폐회로 면적이 정본이다 — 설계를 갈아 끼운 **이 자리에서 한 번** 다시
// 얹는다. 부르는 쪽마다 얹으면 B06 흐름만 얹고 B05 는 안 얹어 두 보기의 유토 뱃지가
@@ -136,7 +139,9 @@ export async function refreshCrossDesigns(input: CrossRefreshInput): Promise<num
structureAreaRows(input.detail.cross_sections),
);
}
return updated;
return sections
.filter((section) => JSON.stringify(section.design) !== before.get(section))
.map((section) => section.chainage_m);
}
/**
+21 -14
View File
@@ -168,8 +168,11 @@ def _side_spec(
구조가 집수정이면 기슭막이·보호공을 만들지 않는다 — 집수정 단면은 후속 작업이라
화면은 라벨만 쓴다(2026-08-19 사용자 확정).
"""
structure = options.get(f"{side}_type") or defaults.get(f"{side}_type") or "기슭막이"
# 고르기 칸 빈 값 = 그 부재 없음(54-39 · 기본값으로 안 바꿈)
structure = options.get(f"{side}_type") or ""
spec: dict[str, Any] = {"role": side, "structure": str(structure)}
if not structure:
return spec
if spec["structure"] == INLET_STRUCTURE_BASIN:
# 집수정 종방향 길이(3D 예상형상용, 기본 2m — 2026-08-23 사용자).
# 전/후는 기슭막이와 같은 체계로 따로 지정한다(기본 각 1m — 2026-08-24 사용자).
@@ -179,33 +182,37 @@ def _side_spec(
)
spec["basin_before_m"] = _number(
options.get("inlet_basin_before_m"),
_number(defaults.get("inlet_basin_before_m"), None),
None,
)
spec["basin_after_m"] = _number(
options.get("inlet_basin_after_m"),
_number(defaults.get("inlet_basin_after_m"), None),
None,
)
# 집수정 높이(좌측 폼 · 비면 정의 기본값) — 횡단도 집수정 벽 높이.
spec["basin_height_m"] = _number(options.get("inlet_basin_height_m"), None)
# 집수정 모양(54-39) — 빈 값 = 안 고름
spec["basin_form"] = str(options.get("inlet_structure") or "") or None
return spec
# 높이를 안 적었으면 **횡단도가 그리는 관경 기준 최소 높이**(2026-09-14 · 옛 기본 2.5 걷음).
height = _number(
options.get(f"{side}_revet_height_m"),
_number(defaults.get(f"{side}_revet_height_m"), pipe_wall_min_height_m(diameter_m)),
pipe_wall_min_height_m(diameter_m),
)
length = _number(
options.get(f"{side}_revet_length_m"),
_number(defaults.get(f"{side}_revet_length_m"), None),
None,
)
form = options.get(f"{side}_revet_form") or defaults.get(f"{side}_revet_form")
form = options.get(f"{side}_revet_form")
# 기준측점 전/후 몶(3D 예상형상 종방향 배치 — 2026-08-23 사용자).
# 저장분이 없으면 길이 절반씩.
before = _number(
options.get(f"{side}_revet_before_m"),
_number(defaults.get(f"{side}_revet_before_m"), None),
None,
)
after = _number(
options.get(f"{side}_revet_after_m"),
_number(defaults.get(f"{side}_revet_after_m"), None),
None,
)
spec.update(
{
@@ -231,7 +238,7 @@ def _culvert_set(options: dict[str, Any] | None) -> dict[str, Any]:
diameter_mm = _number(
values.get("pipe_diameter_mm"), _number(defaults.get("pipe_diameter_mm"), 1000.0)
)
kind = values.get("pipe_kind") or defaults.get("pipe_kind")
kind = values.get("pipe_kind")
diameter_m = round((diameter_mm or 1000.0) / 1000.0, 3)
return {
"type": "pipe",
@@ -240,10 +247,7 @@ def _culvert_set(options: dict[str, Any] | None) -> dict[str, Any]:
"min_cover_m": MIN_PIPE_COVER_M,
# 관 기슭막이 기초 축 — **유입·유출 한 칸으로** 받는다(2026-09-09). 한쪽만 기초유로
# 하는 일이 드물어 폼을 둘로 늘리지 않았다. 실무가 갈라 쓰면 그때 나눌 것.
"foundation": (
str(values.get("revet_foundation") or defaults.get("revet_foundation") or "").strip()
or None
),
"foundation": (str(values.get("revet_foundation") or "").strip() or None),
"inlet": _side_spec(values, defaults, "inlet", diameter_m),
"outlet": _side_spec(values, defaults, "outlet", diameter_m),
}
@@ -327,7 +331,8 @@ def _wing_spec(values: dict[str, Any], defaults: dict[str, Any], side: str) -> d
height = _number(
values.get(f"{prefix}_height_m"), _number(defaults.get(f"{prefix}_height_m"), 0.0)
)
installed = str(install or "").strip() != "없음"
# BOX암거 유입·유출 구조(표 02) — 없음 · 날개벽 · 흙막이 · 옛 값 있음 = 날개벽. 날개벽만 세움.
installed = str(install or "").strip() not in ("없음", "흙막이")
extend = (length or 0.0) * math.cos(math.radians(angle or 0.0)) if installed else 0.0
return {
"installed": installed,
@@ -499,6 +504,8 @@ def load_culvert_sets(project_root: Path) -> dict[float, dict[str, Any]]:
sets: dict[float, dict[str, Any]] = {}
for point in parse_pipe_points(document.get("points")):
if point.facility == PIPE_FACILITY_PIPE:
if (point.options or {}).get("pipe_diameter_mm") in (None, ""):
continue # 관경 안 고름 = 관 없음(54-39)
spec = _culvert_set(point.options)
elif point.facility == PIPE_FACILITY_FORD_BRIDGE:
spec = _ford_set(point.options)
+40 -35
View File
@@ -37,32 +37,35 @@ _SIDE_AUTO = "자동(성토 쪽)"
_SIDE_WORDS = {"좌": "left", "우": "right"}
def _sections_in(cross_sections: list[dict[str, Any]], start_m: float, end_m: float) -> list[dict]:
"""구간 안에 든 측점만. **새 측점을 만들지 않는다**(2026-09-09 사용자 확정 ③)."""
picked = []
for section in cross_sections:
chainage = section.get("chainage_m")
if chainage is None:
continue
value = float(chainage)
if start_m - 1e-6 <= value <= end_m + 1e-6:
picked.append(section)
return sorted(picked, key=lambda item: float(item["chainage_m"]))
def _section_at(cross_sections: list[dict[str, Any]], chainage_m: float) -> list[dict]:
"""기준 측점에 가장 가까운 측점 하나(PLAN 54-7 · 가운데면 앞 측점).
def _spans(sections: list[dict[str, Any]], start_m: float, end_m: float) -> list[float]:
"""측점마다 대표 길이(m) — 앞뒤 측점과의 절반씩. 구간 끝은 경계까지만."""
spans: list[float] = []
for index, section in enumerate(sections):
chainage = float(section["chainage_m"])
left = float(sections[index - 1]["chainage_m"]) if index else max(start_m, chainage)
right = (
float(sections[index + 1]["chainage_m"])
if index + 1 < len(sections)
else min(end_m, chainage)
**새 측점을 만들지 않는다**(확정 ③).
"""
placed = [section for section in cross_sections if section.get("chainage_m") is not None]
if not placed:
return []
return [
min(
placed,
key=lambda item: (
abs(float(item["chainage_m"]) - chainage_m),
float(item["chainage_m"]),
),
)
spans.append(max((chainage - left) / 2 + (right - chainage) / 2, 0.0))
return spans
]
def _span_of(cross_sections: list[dict[str, Any]], section: dict[str, Any]) -> float:
"""그 측점의 대표 길이(m) — 앞뒤 측점과의 절반씩. 끝 측점은 한쪽만."""
chainages = sorted(
{float(item["chainage_m"]) for item in cross_sections if item.get("chainage_m") is not None}
)
here = float(section["chainage_m"])
index = chainages.index(here)
left = chainages[index - 1] if index else here
right = chainages[index + 1] if index + 1 < len(chainages) else here
return (right - left) / 2
def _has_spoil_value(design: dict[str, Any]) -> bool:
@@ -92,7 +95,10 @@ def _side_of(design: dict[str, Any], option: Any) -> str | None:
def spoil_sites(structures: list[Any]) -> list[dict[str, Any]]:
"""배치된 사토장만 골라 쓰기 좋은 모양으로. 구간·용량이 없으면 뺀다."""
"""배치된 사토장만 골라 쓰기 좋은 모양으로. 기준 측점·용량이 없으면 뺀다.
기준 측점이 없는 옛 구간 저장분은 시작 측점으로 읽음(PLAN 54-7).
"""
sites: list[dict[str, Any]] = []
for item in structures:
type_id = getattr(item, "type_id", None) or (
@@ -104,13 +110,13 @@ def spoil_sites(structures: list[Any]) -> list[dict[str, Any]]:
if options is None and isinstance(item, dict):
options = item.get("options")
options = options or {}
start = getattr(item, "start_m", None)
end = getattr(item, "end_m", None)
chainage = getattr(item, "chainage_m", None)
if isinstance(item, dict):
start = item.get("start_m")
end = item.get("end_m")
chainage = item.get("chainage_m")
if chainage is None:
chainage = item.get("start_m")
capacity = options.get("capacity_m3")
if start is None or end is None or capacity in (None, ""):
if chainage is None or capacity in (None, ""):
continue
try:
capacity_value = float(capacity)
@@ -122,8 +128,7 @@ def spoil_sites(structures: list[Any]) -> list[dict[str, Any]]:
{
"structure_id": getattr(item, "structure_id", None)
or (item.get("structure_id") if isinstance(item, dict) else None),
"start_m": min(float(start), float(end)),
"end_m": max(float(start), float(end)),
"chainage_m": float(chainage),
"capacity_m3": capacity_value,
"side_option": options.get("side"),
"slope_ratio_n": options.get("fill_slope_ratio"),
@@ -223,7 +228,7 @@ def enforce_spoil_fills(
# (노선 성토도 그때 원래 값으로 돌아온다 — 사토장 몫을 빼 두었기 때문이다.)
covered: set[float] = set()
for site in sites:
for section in _sections_in(cross_sections, site["start_m"], site["end_m"]):
for section in _section_at(cross_sections, site["chainage_m"]):
covered.add(float(section["chainage_m"]))
for section in cross_sections:
design = section.get("design")
@@ -256,10 +261,10 @@ def enforce_spoil_fills(
if not sites:
return changed
for site in sites:
sections = _sections_in(cross_sections, site["start_m"], site["end_m"])
sections = _section_at(cross_sections, site["chainage_m"])
if not sections:
continue
spans = _spans(sections, site["start_m"], site["end_m"])
spans = [_span_of(cross_sections, section) for section in sections]
sides = [_side_of(section.get("design") or {}, site["side_option"]) for section in sections]
ratio = site["slope_ratio_n"]
@@ -28,8 +28,8 @@ logger = logging.getLogger(__name__)
# 구간 경계 측점을 구간 안으로 볼 허용 오차(m) — 정본이 누가거리를 0.01m로 끊어 쓴다.
_EDGE_TOLERANCE_M = 0.02
# 구조물 종류 → 횡단 기하가 아는 **형태** 이름. 형태가 벽 높이 한계·두께를 정하므로
# (`B06_Section_UI_Cross_Revetment.revetHeightLimit`) 가장 가까운 것으로 잇는다.
# 구조물 종류 → 횡단 기하가 아는 **형태** 이름. 형태는 벽 안 무늬만 정하므로
# 가장 가까운 것으로 잇는다.
_FORM_BY_TYPE = {
"masonry_wet": "돌쌓기(찰)",
"masonry_dry": "돌쌓기(메)",
+2
View File
@@ -16,6 +16,7 @@ from B05_Profile.B05_Profile_Engine_Grade import GradeDesignOptions, resolve_gra
from B05_Profile.B05_Profile_Engine_Grade_Profile import rebuild_alignment_profile
from B05_Profile.B05_Profile_Engine_Sections import (
prune_stale_cross_files,
relabel_pipe_stations,
run_section_generation,
)
from B05_Profile.B05_Profile_Engine_Sections_Core import SectionGenerationOptions
@@ -269,6 +270,7 @@ def _read_section_detail(project_root: Path, longitudinal_file_path: str) -> dic
# 배수관 측점에 세트(배관·기슭막이·보호공) 제원을 얹는다 — 횡단 카드가 그림을 그린다.
# 독립 기슭막이도 2026-08-28 이관으로 **관 숨김 세트**로 여기 함께 얹힌다(pipe_points).
attach_culvert_sets(root, cross_sections)
relabel_pipe_stations(root, cross_sections) # 저장으로 종류만 바꾼 관 — 카드 제목(54-4)
# 좌측 「구조물 배치」로 넣은 C군 벽(옹벽·돌쌓기 등)도 같은 제원 자리에 얹는다 —
# 그래야 횡단도·설계선 트림·폐회로 면적이 그 벽을 본다(2026-09-06 사용자 확정).
attach_wall_structures(root, cross_sections)
+68
View File
@@ -22,6 +22,13 @@ import {
fetchStructureTypes,
readPendingStructures,
} from "../B05_Profile/B05_Profile_Api_Structures";
import { readPendingPipes } from "../B05_Profile/B05_Profile_Api_Pipes_Draft";
import { PIPE_MATCH_M } from "../A00_Common/design/design_selection";
import {
attachCulvertSets,
buildCulvertSets,
registryDefaults,
} from "@util/common_util_culvert_sets";
import {
attachWallSpecs,
wallSpecsFrom,
@@ -55,6 +62,7 @@ async function withDraftWalls(
// ⚠ **빈 목록도 「초안 없음」이다**(2026-09-09). 예전에는 `[]` 가 「초안이 있는데 벽이
// 하나도 없다」로 읽혀 **아래에서 서버 저장분을 통째로 지웠다** — 구조물을 놓아도
// 횡단도에 아무것도 안 보이던 결함의 원인이다(창 둘에서 같은 증상, 실측 확인).
await withDraftPipeKinds(detail, projectId);
if (!drafts || !drafts.length) return withStructureAreas(detail);
const types = await fetchStructureTypes().catch(() => []);
const names = new Map(
@@ -77,6 +85,66 @@ async function withDraftWalls(
return withStructureAreas(detail);
}
/** 관 지점 시설 → 횡단 자리 키(파이썬 `_SECTION_KEYS` · 배관 · 독립 기슭막이 = culvert). */
const FACILITY_KEYS = ["culvert", "ford", "box", "ford_pavement"] as const;
const facilityKey = (facility: string): (typeof FACILITY_KEYS)[number] =>
facility === "ford_bridge"
? "ford"
: facility === "box_culvert"
? "box"
: facility === "ford_pavement"
? "ford_pavement"
: "culvert";
/**
* 저장 전에 **종류를 바꾼 관**(배관 ↔ BOX암거 ↔ 세월교 ↔ 물넘이포장 · 54-4)을 상세에 얹는다.
* 서버는 저장분 종류로만 얹어 준다 — 초안 종류와 다른 관만 옛 자리를 걷고 짝 산식
* (`common_util_culvert_sets`)으로 새 종류 제원을 얹는다. 옛 종류 칸 값은 섞지 않는다.
*/
async function withDraftPipeKinds(detail: SectionDetailResponse, projectId: string): Promise<void> {
const pipes = readPendingPipes(projectId);
if (!pipes?.length) return;
const sections = detail.cross_sections as unknown as Array<Record<string, unknown>>;
const near = (spec: Record<string, unknown>, section: Record<string, unknown>, at: number) =>
Math.abs(Number(spec.chainage_m ?? section.chainage_m) - at) < PIPE_MATCH_M;
/** 그 관 자리에 얹힌 시설 키가 이 종류와 맞는가 — 얹힌 것이 없으면(새 관 · 옮긴 관) 대상 밖. */
const fits = (pipe: (typeof pipes)[number], key: string, spec: Record<string, unknown>) =>
key === facilityKey(pipe.facility ?? "pipe") &&
(key !== "culvert" || (spec.hidden_pipe === true) === (pipe.facility === "revetment"));
const stale = pipes.filter((pipe) => {
const here = sections.flatMap((section) =>
FACILITY_KEYS.flatMap((key) => {
const spec = section[key] as Record<string, unknown> | undefined;
return spec && near(spec, section, pipe.chainage_m) ? [[key, spec] as const] : [];
}),
);
return here.length > 0 && !here.some(([key, spec]) => fits(pipe, key, spec));
});
if (!stale.length) return;
const types = await fetchStructureTypes().catch(() => []);
const registry = registryDefaults(types);
for (const section of sections) {
for (const key of FACILITY_KEYS) {
const spec = section[key] as Record<string, unknown> | undefined;
if (spec && stale.some((pipe) => near(spec, section, pipe.chainage_m))) delete section[key];
}
// 카드 제목 구조물 이름 — 서버 `resolve_extra_stations` 라벨 규칙(배관 = 관종 D관경 · 물넘이 = 없음)
// 라벨 자리 = 이름 있는 측점 · 관 자리 그 측점(물넘이로 지웠다 되돌린 때)
const pipe = stale.find((entry) => {
const gap = Math.abs(entry.chainage_m - Number(section.chainage_m));
return section.structure ? gap < PIPE_MATCH_M : gap < 0.01;
});
if (!pipe) continue;
const facility = pipe.facility ?? "pipe";
const values = { ...registry.pipe, ...pipe.options };
if (facility === "ford_pavement") delete section.structure;
else if (facility === "pipe")
section.structure = `${values.pipe_kind} D${Math.trunc(Number(values.pipe_diameter_mm))}`;
else section.structure = types.find((type) => type.type_id === facility)?.name ?? facility;
}
attachCulvertSets(sections, buildCulvertSets(stale, registry));
}
/**
* 구조물이 선 측점의 절·성토 면적을 **읽어 오는 자리에서 한 번** 다시 얹는다.
*
+50 -12
View File
@@ -57,11 +57,23 @@ const SIDE_ROWS = [
".b06-structure-panel__struct--wall-height",
].join(", ");
/** 이식 자리가 지금 화면에 서 있는지 — 숨겨진 그룹(다른 시설)이면 옮기지 않는다. */
/** 배관 칸 = 폼에 자리 없는 집수정 내공 · 유입 단 수만 — 목록에서 골라도 같은 글(54-29).
* 유출 단 수는 폼 「추가 흙막이(단)」 칸(54-27) · 읽기 · 옵션 줄은 안 받음. */
const PIPE_INLET_ROWS = [
".b06-structure-panel__struct--tier",
".b06-structure-panel__struct--basin-size",
].join(", ");
const PIPE_OUTLET_ROWS = ".b06-structure-panel__struct--basin-size";
/** 받을 칸에 맞는 줄 — 배관 유입 · 유출 칸이 아니면 옛 줄 그대로. */
function rowsFor(slot: HTMLElement): string {
if (slot === sideSlots?.outlet) return PIPE_OUTLET_ROWS;
return slot === sideSlots?.inlet ? PIPE_INLET_ROWS : SIDE_ROWS;
}
/** 이식 자리가 지금 화면에 서 있는지 — 그 위 어느 줄이든 숨었으면(다른 시설 명세 폼 등) 옮기지 않는다. */
function slotUsable(target: HTMLElement | undefined): target is HTMLElement {
if (!target) return false;
const group = target.closest("fieldset");
return !!group && !group.hidden;
return !!target?.closest("fieldset") && !target.closest("[hidden]");
}
/** 배관이면 유입구·유출구 칸, 독립 기슭막이면 좌·우 칸, 세월교면 날개벽 칸 —
@@ -111,6 +123,13 @@ function clearSideSlots(): void {
// 추가 기슭막이 칸은 고른 다단 벽이 있을 때만 서 있는다 — 비면 그룹째 내린다.
if (target === sideSlots?.extra) group.hidden = true;
}
// 칸이 다른 명세로 옮겨 간 뒤 옛 상자에 남은 강조까지 끔(53-1)
document
.querySelectorAll<HTMLElement>("fieldset.is-active > legend[data-base-label]")
.forEach((legend) => {
legend.parentElement!.classList.remove("is-active");
setGroupLabel(legend.parentElement!, "");
});
}
/** 행 DOM을 제자리 표식과 함께 옮긴다 — 숨은 행은 그대로 둔다. */
@@ -129,7 +148,7 @@ function moveRows(panelRoot: HTMLElement, selector: string, target: HTMLElement)
* 조정창 사본의 단 수·옵션 행을 고른 벽 쪽(유입/유출) 그룹으로 옮긴다. 행 DOM을
* 그대로 옮기므로 배선·값 동기는 손대지 않는다. 자리가 없으면 사본에 그대로 둔다.
*/
function relocateSideRows(panelRoot: HTMLElement): void {
function relocateSideRows(panelRoot: HTMLElement, scroll = true): void {
clearSideSlots();
const side = panelRoot.dataset.side;
if (!sideSlots || (side !== "inlet" && side !== "outlet" && side !== "extra")) return;
@@ -140,16 +159,33 @@ function relocateSideRows(panelRoot: HTMLElement): void {
const group = target.closest<HTMLElement>("fieldset");
if (!group) return;
const ownerSlot = slotOf(panelRoot.dataset.extraSide === "inlet" ? "inlet" : "outlet");
// 배관 유출 다단 = 그 단의 「흙막이」 컨테이너(54-10) — 옛 추가 기슭막이 칸 대신 그 상자를 켬 ·
// 단 수 · 옵션은 부모(유출) 칸에 그대로
const soil =
ownerSlot === sideSlots.outlet && slotUsable(ownerSlot)
? ownerSlot
.closest(".b05-structure__spec")
?.querySelectorAll<HTMLElement>('fieldset[data-spec-container="soil_add"]')[
Number(panelRoot.dataset.extraIndex)
]
: undefined;
if (soil) {
moveRows(panelRoot, PIPE_OUTLET_ROWS, ownerSlot);
setGroupLabel(soil, "");
soil.classList.add("is-active");
if (scroll) soil.scrollIntoView({ block: "nearest" });
return;
}
const owner = ownerSlot.closest("fieldset");
if (owner && owner !== group) owner.after(group);
group.hidden = false;
moveRows(panelRoot, EXTRA_ROWS, target);
// 단 수·옵션은 그 단이 딸린 부모 벽의 값이라 부모 칸에 그대로 세운다 — 다단을
// 고를 때 그 두 행이 사라지던 것을 막는다(2026-08-30 사용자).
if (slotUsable(ownerSlot)) moveRows(panelRoot, SIDE_ROWS, ownerSlot);
if (slotUsable(ownerSlot)) moveRows(panelRoot, rowsFor(ownerSlot), ownerSlot);
} else {
if (!slotUsable(target)) return;
moveRows(panelRoot, SIDE_ROWS, target);
moveRows(panelRoot, rowsFor(target), target);
}
// 고른 구조물이 어느 쪽인지 그룹 테두리로 알린다(2026-08-29 사용자 지시 3).
const group = target.closest<HTMLElement>("fieldset");
@@ -157,9 +193,11 @@ function relocateSideRows(panelRoot: HTMLElement): void {
group.classList.add("is-active");
// 이름표에 지금 만지는 구조물을 적는다 — "유입구 (기슭막이)", "유출구 (기슭막이(독립))".
// 추가 기슭막이 칸은 이름 자체가 그 단이라 괄호 안에 단 번호가 온다(2026-08-30 지시 1).
setGroupLabel(group, panelRoot.dataset.panelTitle ?? "");
// 다단은 칸이 새로 서는 것이라 화면 밖일 수 있다 — 그 자리로 스크롤한다(지시 2).
if (side === "extra") group.scrollIntoView({ block: "nearest", behavior: "smooth" });
// 배관 칸은 이름표를 안 바꿈 — 목록에서 고른 글과 같게 · 강조만(54-29).
const pipe = target === sideSlots.inlet || target === sideSlots.outlet;
setGroupLabel(group, pipe ? "" : (panelRoot.dataset.panelTitle ?? ""));
// 고른 칸이 화면 밖일 수 있다 — 그 자리로 스크롤한다(지시 2 · 유입 · 유출도 53-1).
if (scroll) group.scrollIntoView({ block: "nearest" });
}
function ensureDock(): void {
@@ -210,9 +248,9 @@ export function adoptAdjustPanel(panelRoot: HTMLElement): void {
* 칸(배관 유입구·유출구 / 독립 좌·우)이 아직 이전 시설 것이다(2026-08-30 사용자:
* 다른 기슭막이를 고른 뒤 배관 유출을 고르면 강조가 없다).
*/
export function refreshAdjustSlots(): void {
export function refreshAdjustSlots(scroll = true): void {
const panel = slot?.firstElementChild as HTMLElement | null;
if (panel) relocateSideRows(panel);
if (panel) relocateSideRows(panel, scroll);
}
/** 이 사본이 슬롯에 서 있으면 내린다 — 다른 사본이 이미 대신 서 있으면 손대지 않는다. */
+1 -3
View File
@@ -14,7 +14,6 @@ import {
REVET_EMBED_DEPTH_M,
FILL_SLOPE_RATIO_MIN,
pipeWallThicknessM,
revetHeightLimit,
} from "./B06_Section_UI_Cross_Culvert_Geom";
import type {
BasinShape,
@@ -182,8 +181,7 @@ export function appendCulvertOverlay(
`${roleLabel(wall.role)} 기슭막이 ${wall.form ?? ""} H=${(
wall.height + REVET_EMBED_DEPTH_M
).toFixed(1)}m` +
`(상단 = 사면선 접점, 전면 1:${wall.lean}(품셈 13-4-4 [주]⑪ 표준경사)` +
`, 높이 한계 ${revetHeightLimit(wall.form).toFixed(1)}m — 교본 7-3)` +
`(상단 = 사면선 접점, 전면 1:${wall.lean}(품셈 13-4-4 [주]⑪ 표준경사))` +
(wall.floatGapM > 0.01
? ` · ⚠ 바닥 원지반 이격 ${wall.floatGapM.toFixed(2)}m — 하부 지지 구조물 별도(추가 예정)`
: ` · 근입 ${REVET_EMBED_DEPTH_M.toFixed(2)}m(실무 기초콘크리트 H=0.5 — 법정 규정 없음)`) +
@@ -15,11 +15,17 @@
import {
PIPE_CONNECT_GRADE,
BASIN_INNER_HEIGHT_M,
BASIN_MAX_FILL_SLOPE_M,
BASIN_MEMBER_THICKNESS_M,
REVET_FREEBOARD_M,
REVET_LEAN_RATIO,
} from "./B06_Section_UI_Cross_Culvert_Const";
import { minShoulderWallOffset, slopeToeOffset } from "./B06_Section_UI_Cross_Culvert_Solve";
import type { CulvertSideSpec } from "./B06_Section_Api_Fetch";
import {
minShoulderWallOffset,
slopeLengthAlong,
slopeToeOffset,
} from "./B06_Section_UI_Cross_Culvert_Solve";
import type {
BasinLayout,
BasinAdjust,
@@ -29,19 +35,72 @@ import type {
InletStructureChoice,
} from "./B06_Section_UI_Cross_Culvert_Types";
/** 자동(기본) 집수정 모양(54-36) — 좌측 폼 「(기본)」 표시도 이 값. */
export const DEFAULT_BASIN_SHAPE: BasinShape = "L";
export function resolveBasinChoice(
choice: InletStructureChoice,
ruleReason: BasinLayout["reason"] | null,
luAllowed = true,
): { reason: BasinLayout["reason"] | null; shape: BasinShape } {
const selected = choice === "I" || choice === "L" || choice === "U";
return {
reason: choice === "revet" ? null : selected ? (ruleReason ?? "manual") : ruleReason,
// 자동(기본) 집수정은 **I형**(2026-08-23 사용자) — 종전 L형 기본은 ㄴ·ㄷ형이
// 선택지에서 숨는 지형(basinLUAllowed=false)에서 선택지 밖 구조물이 그려졌다.
shape: selected ? choice : "I",
// 자동(기본) 집수정 = **L형**(54-36) · ㄴ·ㄷ형이 선택지에서 숨는 지형(basinLUAllowed=false)은
// I형 — 선택지 밖 구조물을 그리지 않음.
shape: selected ? choice : luAllowed ? DEFAULT_BASIN_SHAPE : "I",
};
}
/** 유입 집수정 판정 — 모양 · 까닭(null = 안 세움). 기하 본체에서 분리(700줄 제한).
* 유입 성토사면 ≤3m면 기본(절토측 포함). */
export function decideInletBasin(args: {
sectionMode: string | null | undefined;
inletSide: "left" | "right";
inlet: CulvertSideSpec;
hiddenPipe: boolean;
designAt: ((offset: number) => number) | null;
groundAt: (offset: number) => number;
edgeOffset: number;
limitOffset: number;
patchChoice: InletStructureChoice | undefined;
luAllowed: boolean;
}): { reason: BasinLayout["reason"] | null; shape: BasinShape } {
const { sectionMode: mode, inletSide, inlet, designAt, groundAt, edgeOffset } = args;
const inletIsCut =
mode === "both_cut" ||
(mode === "left_cut" && inletSide === "left") ||
(mode === "right_cut" && inletSide === "right");
const inletFillSlopeLen =
!inletIsCut && designAt
? slopeLengthAlong(
designAt,
edgeOffset,
slopeToeOffset(designAt, groundAt, edgeOffset, args.limitOffset),
)
: 0;
const ruleReason: BasinLayout["reason"] | null = inletIsCut
? "cut"
: inlet.structure === "집수정"
? "cut"
: inletFillSlopeLen <= BASIN_MAX_FILL_SLOPE_M + 1e-6
? "short"
: null;
// 횡단 patch 형식이 없으면 폼이 고른 집수정 모양(54-39)
const patch = args.patchChoice;
const choice: InletStructureChoice =
patch && patch !== "auto"
? patch
: ((inlet.basin_form as InletStructureChoice | null | undefined) ?? patch ?? "auto");
// 독립 기슭막이(관 숨김)는 집수정을 세우지 않는다 — 설치 측이 상단(유입 역할)일 때만
// 집수정이 서서 좌·우가 갈리던 원인(2026-08-29 사용자: 양쪽 다 성토 로직).
const { shape, reason } = resolveBasinChoice(choice, ruleReason, args.luAllowed);
// 유입 구조 · 집수정 모양을 안 고름 = 집수정 없음(54-39 · 기본 모양으로 안 세움)
const kind = inlet.structure;
const unset = !kind || (kind === "집수정" && !["I", "L", "U"].includes(choice));
return { shape, reason: args.hiddenPipe || unset ? null : reason };
}
export function basinApproachPoints(
edge: { offset_m: number; elevation_m: number },
outward: number,
@@ -94,6 +153,8 @@ export interface BasinBuildInput {
* (2026-08-30 사용자 확정: 집수정은 그대로 두고 세월교만 세운다).
*/
leanRatio?: number;
/** 벽 높이(m) — 좌측 폼 집수정 「높이」. 없으면 I형 노견 접점 · ㄴ·ㄷ형 내공 높이. */
heightM?: number | null;
}
/** 집수정 구성 결과 — 본체가 트림·관 끝단면·관 시작점에 나눠 꽂는다. */
@@ -143,10 +204,12 @@ export function buildBasin(input: BasinBuildInput): BasinBuildResult {
const memberT = input.memberThicknessM ?? BASIN_MEMBER_THICKNESS_M;
const floorThickness = input.floorThicknessM ?? memberT;
// 벽 높이: I형은 노견 접점까지 성장, ㄴ·ㄷ형은 내부 높이 1.2m 고정(임시값).
// 폼 「높이」를 적으면 세 형태 모두 그 높이.
const wallHeight =
shape === "I"
input.heightM ??
(shape === "I"
? Math.max(diameterM + REVET_FREEBOARD_M, edge.elevation_m - anchor.elevation)
: adjust.innerHeightM;
: adjust.innerHeightM);
// 기움은 **수직 기준 반전** — 상단이 도로측(내공 쪽)으로 1:0.3 물러난다(2026-08-20).
// bottomElevation을 내리면 면 기울기를 그대로 연장한다(I형 근입용).
const defaultBottom = anchor.elevation - floorThickness;
@@ -75,35 +75,15 @@ export function pipeWallThicknessM(kind: string | null, diameterM: number): numb
*/
export const REVET_EMBED_DEPTH_M = 0.5;
/**
* 기슭막이 형태별 높이 한계(m) — 지식DB `돌쌓기.md` §1 / `흙막이.md` §2:
* 돌 **찰쌓기 3.0m 이하**, 돌 **메쌓기 2.0m 이하**(교본 7-3 돌흙막이 기준),
* 돌망태 2m 정도. 큰돌쌓기는 총높이 한계 없음(1일 시공 1.5m 제한만).
* 초과 시 콘크리트 옹벽 등 상위 구조물 검토 대상이다.
* 통나무·목재틀·바자는 지식DB에 수치가 없어 **2.0m**로 둔다(2026-08-29 사용자 확정).
*/
export function revetHeightLimit(form: string | null | undefined): number {
if (!form) return 3.0;
if (form.includes("메")) return 2.0;
if (form.includes("찰")) return 3.0;
if (form.includes("돌망태")) return 2.0;
if (form.includes("통나무") || form.includes("목재") || form.includes("바자")) return 2.0;
if (form.includes("콘크리트")) return 5.0; // 프로젝트 확정값 — materialLimit과 동일
return 3.0;
}
/* ── 기슭막이 재질·높이 조작(2026-08-22 사용자 확정) ─────────────────────
* 높이 조작이 교본 형태별 한계와 부딪히면 **재질을 바꿔야** 더 올릴 수 있다:
* 메쌓기 2.0 / 찰쌓기 3.0(돌쌓기.md §1) / 콘크리트 5.0(프로젝트 기본값,
* 외부 기준 미확인). 높이 제어·표기·한계 기준은 모두 **순수 높이**(벽 바닥~상단,
* 근입 0.5m 포함) — 배관 기슭막이 2026-08-23, 추가·독립 기슭막이 2026-08-29
* 사용자 확정으로 기준을 하나로 맞췄다. */
/* 기슭막이 높이는 형태와 무관하게 **사용자 입력 그대로** — 형태별 높이 한계·원지반 맞춤
* 자동 자르기 없음. 형태가 바꾸는 것은 안 무늬뿐. 높이 기준은 **순수 높이**(벽 바닥~상단,
* 근입 0.5m 포함). 단 하나 — 벽 윗면은 노면 위로 올라오지 않음(`buildRevetWallGeometry`). */
export type RevetMaterial = "dry" | "wet" | "concrete";
/**
* 기슭막이 **형태** — B05 폼(`B05_Profile_UI_Drainage_Facility_Fields`)과 같은 한 벌이다.
* 조정창 선택지도 이 목록을 쓴다(2026-08-29 사용자: "B05 폼 형태로 가는 게 맞다").
* 높이 한계는 `revetHeightLimit(form)`, 도형의 돌 표현은 `materialFromForm(form)`이 정한다.
* 도형의 돌 표현은 `materialFromForm(form)`이 정한다.
*/
export const REVET_FORMS = [
"돌쌓기(찰)",
@@ -130,10 +110,6 @@ export function revetFormOf(m: string | null | undefined, specForm?: string | nu
export const REVET_MATERIALS: RevetMaterial[] = ["dry", "wet", "concrete"];
export function materialLimit(material: RevetMaterial): number {
return material === "dry" ? 2.0 : material === "wet" ? 3.0 : 5.0;
}
export function materialLabel(material: RevetMaterial): string {
return material === "dry" ? "메쌓기" : material === "wet" ? "찰쌓기" : "콘크리트";
}
@@ -149,7 +125,7 @@ export function materialFromForm(form: string | null | undefined): RevetMaterial
* 벽 한 매의 제원(형태·재질·높이) — 배관 벽과 독립 기슭막이가 같이 쓴다.
*
* 조정창이 고르는 값은 **형태**(B05 폼과 같은 6종 — 2026-08-29 사용자)이고, 재질(돌
* 표현)과 높이 한계는 형태에서 파생된다. 높이 기준은 **순수 높이**(바닥~상단, 근입
* 표현)은 형태에서 파생된다. 높이 기준은 **순수 높이**(바닥~상단, 근입
* 0.5m 포함). 독립 기슭막이(관 숨김)는 관경이 없어 하한이 근입뿐이고 기본 높이는
* 사용자가 고른 형태 높이(`revet_height_m`)다 — 배관은 관이 벽 밖으로 삐져나오지
* 않도록 관경 기준 최소 높이를 하한·기본으로 쓴다.
@@ -159,16 +135,16 @@ export function revetWallSpec(
adjust: { h?: number | null; m?: string | null },
hiddenPipe: boolean,
diameterM: number,
): { form: string; material: RevetMaterial; limit: number; pureHeight: number; height: number } {
): { form: string; material: RevetMaterial; pureHeight: number; height: number } {
const form = revetFormOf(adjust.m, spec.revet_form);
const limit = revetHeightLimit(form);
const floor = hiddenPipe ? REVET_EMBED_DEPTH_M : pipeWallMinPureHeight(diameterM);
const preferred = hiddenPipe ? (spec.revet_height_m ?? floor) : floor;
const pureHeight = Math.min(Math.max(adjust.h ?? preferred, floor), Math.max(limit, floor));
// 관경 기준 높이는 기본값만 — 하한은 그림이 서는 값뿐(54-51 · 사용자가 고름).
const preferred = hiddenPipe
? (spec.revet_height_m ?? REVET_EMBED_DEPTH_M)
: pipeWallMinPureHeight(diameterM);
const pureHeight = Math.max(adjust.h ?? preferred, WALL_MIN_PURE_HEIGHT_M);
return {
form,
material: materialFromForm(form),
limit,
pureHeight,
height: pureHeight - REVET_EMBED_DEPTH_M,
};
@@ -187,8 +163,8 @@ export const PIPE_CONNECT_GRADE = Math.tan((3 * Math.PI) / 180);
export function pipeWallMinPureHeight(diameterM: number): number {
return revetTargetHeight(diameterM) + REVET_EMBED_DEPTH_M;
}
/** 일반(추가) 기슭막이 높이 조작 하한(m) — 프로젝트 기본값 0.5m. */
export const EXTRA_WALL_MIN_HEIGHT_M = 0.5;
/** 벽 순수 높이 하한(m) — 0 이하는 그림이 안 섬. 관경 · 근입 하한 없음(54-51). */
export const WALL_MIN_PURE_HEIGHT_M = 0.1;
/** 일반(추가) 기슭막이 기본 높이(m). */
export const EXTRA_WALL_DEFAULT_HEIGHT_M = 1.5;
+23 -142
View File
@@ -14,24 +14,22 @@
import {
EXTRA_WALL_DEFAULT_HEIGHT_M,
PIPE_CONNECT_GRADE,
EXTRA_WALL_MIN_HEIGHT_M,
FILL_SLOPE_MAX_LENGTH_M,
FILL_SLOPE_RATIO_MIN,
materialFromForm,
materialLabel,
revetFormOf,
revetHeightLimit,
REVET_EMBED_DEPTH_M,
REVET_LEAN_RATIO,
REVET_THICKNESS_M,
WALL_MIN_PURE_HEIGHT_M,
} from "./B06_Section_UI_Cross_Culvert_Const";
import type { RevetMaterial } from "./B06_Section_UI_Cross_Culvert_Const";
import type {
OffsetPoint,
OutletFillSegment,
WallAdjust,
WallLayout,
} from "./B06_Section_UI_Cross_Culvert_Types";
import { buildRevetWallGeometry } from "./B06_Section_UI_Cross_Wall";
export interface OutletExtrasInput {
/** 성토부선 시작점 = 관 유출 하단 꼭짓점(배관 벽의 성토선 시작 자리). */
@@ -215,64 +213,10 @@ function trailingFill(
};
}
/**
* 추가 기슭막이 벽 1매 — 배관용 기슭막이와 같은 형상(배면 수직·전면 1:0.3,
* 수평 기초 근입 0.5m), 배관·마감면만 없다. 높이는 눈금 없이 **정확값**을 쓴다 —
* 0.1m 올림을 하면 상단이 1:1.2 사면선을 벗어난다(사이 물매 정확 유지가 우선).
*/
function buildExtraWall(
index: number,
anchor: OffsetPoint,
outward: number,
height: number,
material: RevetMaterial,
floatGapM: number,
form: string | null = null,
lean: number = REVET_LEAN_RATIO,
): WallLayout {
const thickness = REVET_THICKNESS_M;
const baseWidth = thickness * 1.5 + lean * height;
const backOffset = anchor.offset - outward * (baseWidth / 2);
const topJoint = backOffset + outward * (thickness / 2);
const topElevation = anchor.elevation + height;
const topBack: OffsetPoint = { offset: backOffset, elevation: topElevation };
const topFront = topJoint + outward * thickness;
const frontXAt = (elevation: number): number =>
topFront + outward * lean * (topElevation - elevation);
// 하단 = 기준선(anchor) 아래 근입 0.5m **고정** — 원지반에 묻혀도 바닥을 더
// 내리지 않는다. 벽 형상은 높이값으로만 정한다(2026-08-23 사용자 확정 —
// 종전 전면 발끝 지반 추적 수렴 삭제).
const bottomElevation = anchor.elevation - REVET_EMBED_DEPTH_M;
const bottomBack: OffsetPoint = { offset: backOffset, elevation: bottomElevation };
const bottomFront: OffsetPoint = {
offset: frontXAt(bottomElevation),
elevation: bottomElevation,
};
return {
role: "extra",
extraIndex: index,
form: form ?? materialLabel(material),
lengthM: null,
backOffset,
outerOffset: bottomFront.offset,
base: anchor.elevation,
height,
floatGapM,
material,
lean,
outward,
topBack,
topJoint: { offset: topJoint, elevation: topElevation },
bottomBack,
bottomFront,
points: [bottomBack, topBack, { offset: topFront, elevation: topElevation }, bottomFront],
};
}
/**
* 유출측 성토부선·다단 기슭막이 일괄 계산 (2026-08-22 4축 조작 체계).
*
* 단별 벽 높이 h = 사용자 설정 ?? 기본 1.5m (0.5~재질 한계로 절삭). 벽 상단은
* 단별 벽 높이 h = 사용자 설정 ?? 기본 1.5m (하한 0.5 · 형태별 상한 없음). 벽 상단은
* 항상 src에서 내려오는 **1:1.2 성토선 위** — 자동 자리는 높이 h 벽이 지반에
* 앉으며 상단이 선에 닿는 지점(heightAt(x)=h 교차점, 닫힌식):
* heightAt(x) = (src.elev − 지반(x) − (D − 0.25t)/1.2) / (1 − 0.15/1.2)
@@ -294,30 +238,19 @@ export function buildOutletExtras(input: OutletExtrasInput): OutletExtrasResult
let prevBottom = input.startBottomElevation;
for (let i = 0; i < input.adjusts.length; i += 1) {
// 시작점이 원지반 아래 = 윗단 벽이 0.5m 이상 묻힘 → 성토 불필요, 다단 종료.
if (groundAt(src.offset) >= src.elevation - 0.01) break;
// 원지반은 단을 끊지 않는다 — 요청한 단 수 그대로 세운다(54-45).
const trailing = trailingFill(src, outward, groundAt);
if (trailing.lengthM < 0.7) break;
const adjust = input.adjusts[i];
// 형태(B05 폼 6종)가 재질·높이 한계를 정한다 — 조작이 없으면 소유 벽 형태를 따른다
// (2026-08-29 사용자: 조정창 선택지를 형태로 통일).
const form = revetFormOf(adjust.m, input.ownerForm);
const material = materialFromForm(form);
const limit = revetHeightLimit(form);
// 높이 기준 = **벽 바닥~상단**(근입 0.5 포함) — 배관 기준벽과 같은 기준으로
// 통일했다(2026-08-29 사용자: 추가 기슭막이 높이가 하단~상단이 아니었다).
const height = Math.min(
Math.max(
adjust.h ?? EXTRA_WALL_DEFAULT_HEIGHT_M,
EXTRA_WALL_MIN_HEIGHT_M,
REVET_EMBED_DEPTH_M + 0.1,
),
limit,
);
/** 기준선(근입 위)~상단 — 도형·자리 계산은 종전대로 이 값으로 한다.
* 지형이 요청 높이만큼 안 나오면 아래 스캔 뒤 **낮춰서** 바닥을 지반에 앉힌다. */
let exposed = height - REVET_EMBED_DEPTH_M;
// 높이 기준 = **벽 바닥~상단**(근입 0.5 포함) — 배관 기준벽과 같은 기준.
// 형태별 높이 한계 없음 — 사용자 입력 그대로(하한만 둠).
const height = Math.max(adjust.h ?? EXTRA_WALL_DEFAULT_HEIGHT_M, WALL_MIN_PURE_HEIGHT_M);
/** 기준선(근입 위)~상단 — 도형·자리 계산은 이 값으로 한다. */
const exposed = height - REVET_EMBED_DEPTH_M;
// 전면 기울기 — 형태·요청 높이로 표준경사(2026-09-14 B5). 자리 닫힌식의 분모도 따라감.
const lean = input.leanFor?.(form, height) ?? REVET_LEAN_RATIO;
const heightDenominator = 1 - lean / 2 / FILL_SLOPE_RATIO_MIN;
@@ -354,8 +287,8 @@ export function buildOutletExtras(input: OutletExtrasInput): OutletExtrasResult
bestOffset = x;
}
}
if (autoOffset === null) autoOffset = bestOffset;
if (autoOffset === null) break; // 세울 만한 지형이 아니다 — 되는 만큼만.
// 앉을 지형이 없으면(묻힘) 이음선이 시작점 바로 밖 — 원지반과 무관하게 선다.
autoOffset ??= bestOffset ?? src.offset + outward * jointRunOf(exposed, lean);
const autoJointRun = (autoOffset - src.offset) * outward - jointRunOf(exposed, lean);
/** 자동 자리(선반 0·수직 0)의 벽 상단 표고 — 조작은 여기서부터 잰다. */
const autoTop = src.elevation - autoJointRun / FILL_SLOPE_RATIO_MIN;
@@ -375,81 +308,29 @@ export function buildOutletExtras(input: OutletExtrasInput): OutletExtrasResult
FILL_SLOPE_RATIO_MIN
: (plan[i] ?? 0);
const requestedX = plan === "user" ? adjust.x : 0;
/** 후보 자리의 바닥 — buildExtraWall과 같은 근입 0.5m 고정(2026-08-23). */
const bottomAt = (_anchorX: number, baseElevation: number): number =>
baseElevation - REVET_EMBED_DEPTH_M;
// 이동 한계 = 원지반 매몰 자리 금지(2026-08-22 사용자 확정): ① 이음선 상단이
// 지반 아래(벽이 통째로 묻힘) ② 자기 성토선 시작점(실바닥+0.5 전면 교차점)이
// 지반 아래 0.05m 이상(= 0.5m 이상 매몰 → 성토 불필요 자리).
const placeable = (xShift: number, vShift: number): boolean => {
const topE = autoTop - vShift;
const aX = autoOffset + outward * xShift;
const jointX = aX - outward * jointRunOf(exposed, lean);
if (
Math.max(groundAt(jointX), groundAt(jointX + outward * REVET_THICKNESS_M)) >=
topE - 0.01
)
return false;
const baseE = topE - exposed;
const bottom = bottomAt(aX, baseE);
const startE = bottom + REVET_EMBED_DEPTH_M;
const topFrontX = jointX + outward * REVET_THICKNESS_M;
const startX = topFrontX + outward * lean * (topE - startE);
if (groundAt(startX) < startE + 0.05) return true;
// 매몰 — 3도 절토선(계류 쪽 내림)이 원지반과 다시 만나면 허용, 아니면 이동 금지.
return (
slopedCrossing(
{ offset: startX, elevation: startE },
outward,
-PIPE_CONNECT_GRADE,
groundAt,
limitOffset,
) !== null
);
};
let appliedD = Math.max(requestedD, minV);
/** 선반 길이가 음수가 되면 각도가 깨진다 — x가 최소 1.2·d까지 따라 나간다. */
const shelfFloor = (v: number): number => FILL_SLOPE_RATIO_MIN * v;
// 원지반은 자리를 막지 않는다 — 묻히든 뜨든 입력 그대로(54-45).
let appliedX = Math.max(requestedX, 0, shelfFloor(appliedD));
for (let pass = 0; pass < 400 && !placeable(appliedX, appliedD); pass += 1) {
// 매몰 자리 — 요청을 자동 자리 쪽으로 0.05m씩 되돌린다(상하 먼저, 다음 좌우).
if (appliedD > minV + 1e-9) {
appliedD = Math.max(minV, appliedD - 0.05);
appliedX = Math.max(appliedX, shelfFloor(appliedD));
} else if (appliedX > shelfFloor(appliedD) + 1e-9) {
appliedX = Math.max(shelfFloor(appliedD), appliedX - 0.05);
} else break;
}
if (!placeable(appliedX, appliedD)) break; // 자동 자리조차 매몰 — 이 단은 불가.
appliedD = Math.round(appliedD * 10) / 10;
appliedX = Math.round(appliedX * 10) / 10;
const topElevation = autoTop - appliedD;
const anchorX = autoOffset + outward * appliedX;
// 바닥을 **원지반에 앉힌다**(2026-09-06 사용자 지적: 연계 기슭막이가 사면과 안 맞음).
// 상단은 1:1.2 성토선에 붙어 있어야 하므로 자리는 그대로 두고 **키만** 지반까지
// 맞춘다 — 지반이 낮으면 키우고(형태 한계까지), 높으면 줄인다(최소 높이까지).
// 예전에는 요청 높이를 그대로 써 바닥이 최대 0.87m 떠 있었다(실측 264.06·731.31).
// 높이는 입력 그대로 — 원지반에 맞춰 키우거나 줄이지 않는다(뜨면 floatGap 경고).
const groundBase = groundAt(anchorX);
const fitted = Math.min(
Math.max(topElevation - groundBase, EXTRA_WALL_MIN_HEIGHT_M - REVET_EMBED_DEPTH_M),
limit - REVET_EMBED_DEPTH_M,
);
const appliedExposed = Number.isFinite(fitted) ? fitted : exposed;
const base = topElevation - appliedExposed; // 근입 0.5 위 기준선
const wall = buildExtraWall(
i,
{ offset: anchorX, elevation: base },
const base = topElevation - exposed; // 근입 0.5 위 기준선
const wall = buildRevetWallGeometry({
anchor: { offset: anchorX, elevation: base },
outward,
appliedExposed,
height: exposed,
material,
Math.max(0, base - groundBase),
role: "extra",
form,
extraIndex: i,
floatGapM: Math.max(0, base - groundBase),
lean,
);
// 요청한 좌우 이동을 지형이 막았으면 그 양을 남긴다 — 「눌러도 안 움직인다」의 까닭을
// 툴팁으로 알리기 위함이다(2026-09-06 실측: 다섯 측점 중 넷이 1.0m 요청에 0.0m 이동).
const blocked = Math.max(0, (requestedX ?? 0) - appliedX);
if (blocked > 0.005) wall.shiftBlockedM = Math.round(blocked * 100) / 100;
});
// 하한에 눌려 요청이 통째로 무시된 경우 — 지형이 아니라 **선반 길이**가 원인이다
// (2026-09-07 실측: d 2.6m 이면 x 하한이 3.12m 라 1.0m 요청이 아무 변화도 못 냄).
// 사용자가 실제로 넣었을 때만 알린다 — 요청이 없으면(0) 하한은 그냥 기본 자리라
@@ -459,11 +340,11 @@ export function buildOutletExtras(input: OutletExtrasInput): OutletExtrasResult
wall.shiftFloorM = Math.round(floor * 100) / 100;
}
walls.push(wall);
// 되받기 — 지반에 맞춰 조정한 값이 **실제 적용 높이**다(조정창이 그대로 받아 적는다).
// 되받기 — 적용 높이(하한만 걸림)를 조정창이 그대로 받아 적는다.
appliedAdjusts.push({
x: appliedX,
d: appliedD,
h: adjust.h != null ? appliedExposed + REVET_EMBED_DEPTH_M : null,
h: adjust.h != null ? height : null,
m: adjust.m,
});
// 성토선: src → (수평 선반 x>0이면 선반 끝) → 이음선 상단점. 사면길이 = 경사부.
+87 -205
View File
@@ -2,14 +2,12 @@
* B06_Section_UI_Cross_Culvert_Geom.ts
* 배수관 세트(배관·기슭막이·성토부) **기하 계산** — 그리기(`_Cross_Culvert.ts`)와 분리.
* 백엔드 `section.culvert` 제원을 좌표로 옮긴다(치수 결정 금지). 기슭막이는 전면
* 1:n 평행사변형(n = 품셈 표준경사 · `leanOf`), 관 끝단면은 구조물 변과 평행, 성토 경사선은 벽 접점에서 끊는다
* 1:n 평행사변형(n = 품셈 표준경사 · `outlineLeanOf`), 관 끝단면은 구조물 변과 평행, 성토 경사선은 벽 접점에서 끊는다
* (designTrim). 유입 = 상단측. 집수정은 `_Basin.ts`, 성토부·다단은 `_Extra.ts`.
* ========================================================================== */
import type { CrossSection, CulvertSideSpec, SectionSample } from "./B06_Section_Api_Fetch";
import {
BASIN_MAX_FILL_SLOPE_M,
materialLabel,
revetWallSpec,
PIPE_WALL_DEFAULT_RUN_M,
FILL_SLOPE_MAX_LENGTH_M,
@@ -19,12 +17,11 @@ import {
REVET_EMBED_DEPTH_M,
REVET_LEAN_RATIO,
REVET_THICKNESS_M,
REVET_TRAP_TOP_M,
revetHeightLimit,
revetTargetHeight,
} from "./B06_Section_UI_Cross_Culvert_Const";
import type { RevetMaterial } from "./B06_Section_UI_Cross_Culvert_Const";
import { leanOf } from "./B06_Section_UI_Cross_Lean";
import { outlineLeanOf } from "./B06_Section_UI_Cross_Lean";
import { buildRevetWallGeometry } from "./B06_Section_UI_Cross_Wall";
import { ZERO_ADJUST } from "./B06_Section_UI_Cross_Culvert_Types";
import type {
BasinLayout,
@@ -46,23 +43,26 @@ import {
applyBasinPipeFill,
attachBasin,
clampBasinMove,
decideInletBasin,
BASIN_INNER_WIDTH_M,
inletChoiceAvailability,
resolveBasinChoice,
} from "./B06_Section_UI_Cross_Culvert_Basin";
import type { OutletExtrasResult } from "./B06_Section_UI_Cross_Culvert_Extra";
import { buildExtrasAt, inletGroundConnector } from "./B06_Section_UI_Cross_Culvert_Extra";
import { inletGroundConnector } from "./B06_Section_UI_Cross_Culvert_Extra";
import {
buildCulvertTiers,
drawnFillPoints,
outletPipeEnd,
slopeZeroAnchor,
} from "./B06_Section_UI_Cross_Culvert_Tiers";
import type { FillSlopeSegment, WallVertical } from "./B06_Section_UI_Cross_Culvert_Solve";
import {
cutLength,
fillWallBaseWidth,
outletSlopeFactory,
fillSlopeOf,
groundInterpolator,
designInterpolator,
slopeToeOffset,
pipeAxisSolver,
placeInletWall,
placePipeWall,
slopeLengthAlong,
} from "./B06_Section_UI_Cross_Culvert_Solve";
@@ -110,6 +110,8 @@ export function computeCulvertLayout(
};
const requestedBasin = basinAdjustment ?? DEFAULT_BASIN_ADJUST;
const basinAdjust = skipBasinClamp ? requestedBasin : clampBasinMove(requestedBasin, probeBasin);
const basinHeightM =
(culvert.inlet.basin_height_m ?? 0) > 0 ? culvert.inlet.basin_height_m : null;
// 좌표 규약: +offset = 좌측. 상단측 = 유입(미상이면 좌측 폴백).
const uphill = section.uphill_side ?? "left";
@@ -128,54 +130,17 @@ export function computeCulvertLayout(
const inletInvert = Math.min(groundAt(inletInfo.edge.offset_m), invertCap(inletInfo.edge));
const inlet: OffsetPoint = { offset: inletInfo.edge.offset_m, elevation: inletInvert };
// 집수정 판정: 유입 성토사면 ≤3m면 기본(절토측 포함).
const mode = section.design?.section_mode;
const inletSideName: "left" | "right" = uphill === "left" ? "left" : "right";
const inletIsCut =
mode === "both_cut" ||
(mode === "left_cut" && inletSideName === "left") ||
(mode === "right_cut" && inletSideName === "right");
const inletFillSlopeLen =
!inletIsCut && designAt
? slopeLengthAlong(
designAt,
inletInfo.edge.offset_m,
slopeToeOffset(designAt, groundAt, inletInfo.edge.offset_m, inletInfo.limit),
)
: 0;
const ruleReason: BasinLayout["reason"] | null = inletIsCut
? "cut"
: culvert.inlet.structure === "집수정"
? "cut"
: inletFillSlopeLen <= BASIN_MAX_FILL_SLOPE_M + 1e-6
? "short"
: null;
const choice: InletStructureChoice = inletStructure ?? "auto";
// 독립 기슭막이(관 숨김)는 집수정을 세우지 않는다 — 설치 측이 상단(유입 역할)일 때만
// 집수정이 서서 좌·우가 갈리던 원인(2026-08-29 사용자: 양쪽 다 성토 로직).
const { shape: basinShape, reason: choiceReason } = resolveBasinChoice(choice, ruleReason);
const basinReason = culvert.hidden_pipe ? null : choiceReason;
// ㄴ·ㄷ형은 사이즈 유지한 채 통째로 노견 끝점 일치 — 바닥(=관 invert)이 따라 오른다.
if (basinReason && basinShape !== "I") {
inlet.elevation = inletInfo.edge.elevation_m - basinAdjust.innerHeightM;
} else if (basinReason) {
// I형 — 관 시작점(내공 1.0m 자리) invert = 그 x의 원지반(토피 상한 이내).
const startOffset =
inlet.offset + inletInfo.outward * (BASIN_INNER_WIDTH_M + basinAdjust.lateralM);
inlet.elevation = Math.min(groundAt(startOffset), invertCap(inletInfo.edge));
}
// 벽 제원(4축): 재질이 높이 한계(메2/찰3/콘5)를 정한다. 높이 기준 = **순수 높이**
// 벽 제원(4축): 형태별 높이 한계 없음(사용자 입력 그대로). 높이 기준 = **순수 높이**
// (바닥~상단 — 2026-08-23 사용자). 하한·기본 = 관경 + 아래 0.5 + 위 0.5 —
// 관이 벽 위로 삐져나오거나 바닥에 붙으면 안 된다. 기하는 종전대로
// invert~상단 계산용 높이(= 순수 − 0.5)로 돈다.
const adjustOf = (value?: WallAdjust): WallAdjust => ({ ...ZERO_ADJUST, ...(value ?? {}) });
const adjInlet = adjustOf(revetShift?.inlet);
const adjOutlet = adjustOf(revetShift?.outlet);
// 전면 기울기 = 표준경사 표(단면유형 × 설치 측 × 형태 × 높이 — B08 과 한 벌, 2026-09-14 B5).
// 전면 기울기 = 표준경사 표(단면유형 × 설치 측 × 높이) — 형태는 안 무늬만(외곽 같음).
const pipeWallSpec = (spec: CulvertSideSpec, adjust: WallAdjust) => {
const wall = revetWallSpec(spec, adjust, culvert.hidden_pipe === true, diameter);
const lean = leanOf({
const lean = outlineLeanOf({
form: wall.form,
height_m: wall.pureHeight,
section_mode: section.design?.section_mode,
@@ -199,6 +164,29 @@ export function computeCulvertLayout(
diameterM: diameter,
cutSlopeRatio: section.design?.cut_slope_ratio ?? 1.0,
});
// 집수정 판정 — 모양 · 까닭(null = 안 세움). 판정은 Basin이 맡는다.
const { shape: basinShape, reason: basinReason } = decideInletBasin({
sectionMode: section.design?.section_mode,
inletSide: uphill === "left" ? "left" : "right",
inlet: culvert.inlet,
hiddenPipe: culvert.hidden_pipe === true,
designAt,
groundAt,
edgeOffset: inletInfo.edge.offset_m,
limitOffset: inletInfo.limit,
patchChoice: inletStructure,
luAllowed: inletOptions.basinLUAllowed,
});
// ㄴ·ㄷ형은 사이즈 유지한 채 통째로 노견 끝점 일치 — 바닥(=관 invert)이 따라 오른다.
if (basinReason && basinShape !== "I") {
inlet.elevation = inletInfo.edge.elevation_m - (basinHeightM ?? basinAdjust.innerHeightM);
} else if (basinReason) {
// I형 — 관 시작점(내공 1.0m 자리) invert = 그 x의 원지반(토피 상한 이내).
const startOffset =
inlet.offset + inletInfo.outward * (BASIN_INNER_WIDTH_M + basinAdjust.lateralM);
inlet.elevation = Math.min(groundAt(startOffset), invertCap(inletInfo.edge));
}
/** 한계에 잘린 뒤의 실제 조작값 — 조정창이 되받는다(높이는 순수 높이 기준). */
const appliedAdjust = {
inlet: { ...adjInlet, h: adjInlet.h != null ? inletWallSpec.pureHeight : null },
@@ -209,22 +197,11 @@ export function computeCulvertLayout(
inlet: null,
outlet: null,
};
// d의 0점 = **성토선 길이 0 지점**(벽 상단 = 노견 — 2026-08-23 사용자 확정).
// 그 자리(하단선 중점)는 이음선 상단점이 노견 끝에 오는 offset이고, 기본 자리는
// 성토선을 타고 경사길이 4m 내려간 지점(PIPE_WALL_DEFAULT_RUN_M)이다.
const slopeZeroAnchor = (
edge: { offset_m: number },
outward: number,
wallHeight: number,
lean: number,
): number =>
edge.offset_m + outward * (fillWallBaseWidth(wallHeight, lean) / 2 - REVET_TRAP_TOP_M);
if (!basinReason && designAt) {
const inletBaseAt = (offset: number): number =>
Math.min(groundAt(offset), invertCap(inletInfo.edge));
// 4축 배치는 공용 풀이(placeInletWall — Solve). 유입을 내리면 유출도 따라
// 내려가므로, 유출이 못 받으면 유입도 못 내려간다(outletGuard).
const placed = placeInletWall({
// 4축 배치는 공용 풀이(placePipeWall — Solve). 원지반은 자리를 막지 않는다(54-45).
const placed = placePipeWall({
autoOffset: slopeZeroAnchor(
inletInfo.edge,
inletInfo.outward,
@@ -235,30 +212,10 @@ export function computeCulvertLayout(
height: inletWallSpec.height,
baseElevation0: inletInfo.edge.elevation_m - inletWallSpec.height,
edgeElevation: inletInfo.edge.elevation_m,
// 독립 기슭막이(관 숨김)는 관 토피·역경사 제약이 없다 — 유입도 노견까지 자유롭게
// 오르내린다(관이 없어 유출 수용 검사 outletGuard도 뺀다 — 위 이동을 막던 원인).
// 독립 기슭막이(관 숨김)는 관 토피·역경사 제약이 없다 — 유입도 노견까지 자유롭게 오르내린다.
invertCap: culvert.hidden_pipe ? Number.POSITIVE_INFINITY : invertCap(inletInfo.edge),
adjust: adjInlet,
defaultD: PIPE_WALL_DEFAULT_RUN_M,
groundAt,
limitOffset: inletInfo.limit,
// 독립 기슭막이는 유출 벽과 같은 자리 규칙 — 매몰-무교차 자리 금지(2026-08-29).
requireCrossing: culvert.hidden_pipe === true,
outletGuard: culvert.hidden_pipe
? undefined
: {
edge: outletInfo.edge,
outward: outletInfo.outward,
height: outletWallSpec.height,
toeOffset: slopeToeOffset(
designAt,
groundAt,
outletInfo.edge.offset_m,
outletInfo.limit,
),
limitOffset: outletInfo.limit,
lean: outletWallSpec.lean,
},
});
appliedAdjust.inlet.x = placed.x;
appliedAdjust.inlet.d = placed.d;
@@ -343,6 +300,7 @@ export function computeCulvertLayout(
groundAt,
cutSlopeRatio: section.design?.cut_slope_ratio ?? 1.0,
adjust: basinAdjust,
heightM: basinHeightM,
});
basin = built.basin;
basinPipeEnd = built.pipeEnd;
@@ -361,50 +319,32 @@ export function computeCulvertLayout(
}
return null;
}
// 형상: 배면 수직 + 계류측 1:n 평행사변형 띠(n = 표준경사). 높이는 vertical(계산용)이 들고 온다.
const height =
vertical?.height ?? Math.min(revetTargetHeight(diameter), revetHeightLimit(spec.revet_form));
if (!(height > 0.05)) return null;
const floatGapM = vertical?.floatGapM ?? 0;
// 자리 기준 = **하단선 중점**(2026-08-21) — anchor.elevation은 그 자리 관 invert.
const baseWidth = thickness * 1.5 + lean * height;
const backOffset = anchor.offset - outward * (baseWidth / 2);
const topJoint = backOffset + outward * (thickness / 2);
const topElevation = anchor.elevation + height;
const topBack: OffsetPoint = { offset: backOffset, elevation: topElevation };
// 상단 변: 사다리꼴 상단(t/2) + 띠(t). 이음선은 상단 변 중간점에서 1:0.3으로 바닥까지.
const topFront = topJoint + outward * thickness;
// 하단선 = **수평 기초**, 깊이 = 기준선(관 invert) 아래 근입 0.5m 고정 —
// 원지반에 묻혀도 바닥을 더 내리지 않는다. 벽 형상은 높이값으로만 정한다
// (2026-08-23 사용자 확정 — 종전 전면 발끝 지반 추적 수렴 삭제).
const frontXAt = (elevation: number): number =>
topFront + outward * lean * (topElevation - elevation);
const bottomElevation = anchor.elevation - REVET_EMBED_DEPTH_M;
const bottomBack: OffsetPoint = { offset: backOffset, elevation: bottomElevation };
const bottomFront: OffsetPoint = {
offset: frontXAt(bottomElevation),
elevation: bottomElevation,
};
const wall: WallLayout = {
role: spec.role,
form: formLabel ?? materialLabel(material),
lengthM: spec.revet_length_m ?? null,
backOffset,
outerOffset: bottomFront.offset,
base: anchor.elevation,
// 높이 = **계산용 높이(관 invert~상단, 근입 제외)로 통일**(2026-08-22 사용자
// 확정 — 기초는 시공 시 묻히는 부분이라 높이·한계 검사 모두 이 기준).
height,
floatGapM,
material,
lean,
// 구조 · 형태를 안 고른 배관 벽 = 그리지 않음(54-39 · 조정창 형태가 있으면 그 값)
const pickedForm = (spec.role === "inlet" ? adjInlet : adjOutlet).m || spec.revet_form;
if (!culvert.hidden_pipe && (spec.structure !== "기슭막이" || !pickedForm)) return null;
// 형상 = 공용 `buildRevetWallGeometry`(추가·사면안정 흙막이·옹벽과 한 벌). 높이는
// vertical(계산용)이 들고 온다 — 형태별 높이 한계 없음, 윗면은 노면에서 멈춤.
const height = vertical?.height ?? revetTargetHeight(diameter);
// 근입 포함 순수 높이가 서면 그림 — 관경 · 근입보다 낮아도 그대로(54-51).
if (!(height + REVET_EMBED_DEPTH_M > 0.05)) return null;
const side = outward > 0 ? edges.left : edges.right;
const wall = buildRevetWallGeometry({
anchor,
outward,
topBack,
topJoint: { offset: topJoint, elevation: topElevation },
bottomBack,
bottomFront,
points: [bottomBack, topBack, { offset: topFront, elevation: topElevation }, bottomFront],
};
height,
material,
role: spec.role,
form: formLabel,
lengthM: spec.revet_length_m ?? null,
thickness,
floatGapM: vertical?.floatGapM ?? 0,
lean,
roadElevation: side.elevation_m,
});
const topJoint = wall.topJoint.offset;
const topElevation = wall.topJoint.elevation;
const topFront = wall.points[2].offset;
const bottomFront = wall.bottomFront;
walls.push(wall);
// 성토 사면선은 **이음선 상단점**에서 끊고, 끝단 표고도 그 점에 맞춘다(사용자 ②).
if (outward > 0) {
@@ -452,7 +392,7 @@ export function computeCulvertLayout(
? outletZeroInvert - ((offset - outletZeroAnchor) * outletInfo.outward) / FILL_SLOPE_RATIO_MIN
: invertAt(offset);
if (designAt) {
// 4축 배치(유입과 동일 풀이) + 유출 전용: 매몰-무교차 자리 금지(2026-08-22 ③).
// 4축 배치(유입과 동일 풀이).
const placed = placePipeWall({
autoOffset: outletZeroAnchor,
outward: outletInfo.outward,
@@ -463,9 +403,6 @@ export function computeCulvertLayout(
invertCap: culvert.hidden_pipe ? Number.POSITIVE_INFINITY : inlet.elevation,
adjust: adjOutlet,
defaultD: PIPE_WALL_DEFAULT_RUN_M,
groundAt,
limitOffset: outletInfo.limit,
requireCrossing: true,
});
appliedAdjust.outlet.x = placed.x;
appliedAdjust.outlet.d = placed.d;
@@ -489,17 +426,6 @@ export function computeCulvertLayout(
);
// ── 관 축 확정 — 관 하단선은 시작점과 유출 벽 전면 기준선 교차점을 잇는다.
const pipeStart = basinPipeEnd ?? inlet;
/** 유출 관 하단 끝점 목표 = 벽 바닥 기준 0.5m 상단(기준선)과 **전면 경사선의
* 교차점**(2026-08-22 사용자 ① — 성토부선 시작 규칙과 같은 자리). */
const outletPipeEnd = (wall: WallLayout): OffsetPoint => {
// 기준 = 바닥 +0.5(= 관 invert 자리 — 2026-08-23부터 바닥은 invert−0.5 고정).
const reference = wall.bottomBack.elevation + REVET_EMBED_DEPTH_M;
return {
offset:
wall.points[2].offset + wall.outward * wall.lean * (wall.topJoint.elevation - reference),
elevation: reference,
};
};
// 유출 벽이 사면 끝과 다른 자리면 관 끝도 그 자리 기준으로 맞춘다(올림 연장분은
// 유출 쪽 — 2026-08-20 확정). 관 하단선은 전면 기준선 교차점을 지나 정수 길이로.
if (outletWall) {
@@ -624,66 +550,26 @@ export function computeCulvertLayout(
)
: null;
// 다단 벽 기울기 — 같은 측점·같은 설치 측 규칙으로 형태·높이마다 표준경사(B08 은 다단을 안 셈).
const extraLean = (form: string, pureHeightM: number): number =>
leanOf({
form,
height_m: pureHeightM,
section_mode: section.design?.section_mode,
side: culvert.hidden_pipe ? culvert.inlet.face_side : null,
});
// 성토부선 + 다단 기슭막이(2026-08-22 — 보호공 삭제, 윗면 선만 성토부선으로).
// 유출측과 **집수정 계류측**이 같은 체계를 쓴다: 5m 넘으면 다단을 둘 수 있다.
const outletStart = outletWall ? pipeCorners.outlet.bottom : null;
const outletInput = {
startBottomElevation: outletWall?.bottomBack.elevation ?? 0,
outward: outletInfo.outward,
// 다단 흙막이(유출측 · 집수정 계류측) — `_Culvert_Tiers` 가 푼다.
const { extras, basinExtras, extrasForArea, basinExtrasForArea } = buildCulvertTiers({
section,
outletStart: outletWall ? pipeCorners.outlet.bottom : null,
outletBottom: outletWall?.bottomBack.elevation ?? 0,
basinStart: culvert.hidden_pipe
? inletWall
? pipeCorners.inlet.bottom
: null
: basinFillStart,
basinBottom: culvert.hidden_pipe ? (inletWall?.bottomBack.elevation ?? 0) : basinFillBottom,
outletInfo,
inletInfo,
groundAt,
limitOffset: outletInfo.limit,
adjusts: (revetShift?.extras ?? []).map(adjustOf),
ownerForm: outletWallSpec.form,
extras: (revetShift?.extras ?? []).map(adjustOf),
basinExtras: (revetShift?.basinExtras ?? []).map(adjustOf),
outletForm: outletWallSpec.form,
inletForm: inletWallSpec.form,
equalize: equalizeExtras === true,
leanFor: extraLean,
};
const extras = buildExtrasAt(outletStart, outletInput);
// 독립 기슭막이(관 숨김)는 집수정이 없어 이 채널이 **유입측 벽의 성토부선·다단**이다 —
// 유출측(`extras`)과 같은 시작점(관 하단 꼭짓점)·같은 `bextra` 키(2026-08-29 사용자).
const basinStart = culvert.hidden_pipe
? inletWall
? pipeCorners.inlet.bottom
: null
: basinFillStart;
const basinInput = {
startBottomElevation: culvert.hidden_pipe
? (inletWall?.bottomBack.elevation ?? 0)
: basinFillBottom,
outward: inletInfo.outward,
groundAt,
limitOffset: inletInfo.limit,
adjusts: (revetShift?.basinExtras ?? []).map(adjustOf),
ownerForm: inletWallSpec.form,
equalize: false,
leanFor: extraLean,
};
const basinExtras = buildExtrasAt(basinStart, basinInput);
/** ⭐ 면적용 다단 — **미확정 단(높이 안 적음)부터 아래는 없는 것**으로 봄(2026-09-14 브레인 판정
* 「미확정 벽은 성토도 안 깎음 · 벽 금액과 성토 감소가 함께」). 그림은 그대로 다 그림.
* B08 도 첫 미확정 단 아래는 미확정으로 셈(`facility_structures`) — 두 곳이 같은 선에서 끊김. */
const confirmedOnly = (
built: OutletExtrasResult,
start: OffsetPoint | null,
input: typeof outletInput,
): OutletExtrasResult => {
const firstUnset = built.appliedAdjusts.findIndex((applied) => applied.h == null);
if (firstUnset < 0) return built;
return buildExtrasAt(start, {
...input,
adjusts: input.adjusts.slice(0, firstUnset),
equalize: false,
});
};
const extrasForArea = confirmedOnly(extras, outletStart, outletInput);
const basinExtrasForArea = confirmedOnly(basinExtras, basinStart, basinInput);
});
// ── 성토 사면 구간 확정. 벽 자리가 굳은 뒤에 물매를 역산해야 관 길이 맞춤(벽 이동)이
// 접점을 다시 깨뜨리지 않는다 — 종전 어긋남의 직접 원인이 이 순서였다.
@@ -707,10 +593,6 @@ export function computeCulvertLayout(
// **물량이 안 바뀐다**(2026-09-07 사용자 확정). 기준벽 사면은 노견~벽 상단까지고, 그
// 바깥은 지금까지 원지반으로 봐서 면적이 0이었다. 화면이 그리는 선(`outletFill.segments`)과
// 같은 선을 면적도 보게 맞춘다 — 그리지 않는 `cut` 갈래(벽이 원지반에 묻힌 자리)는 뺀다.
const drawnFillPoints = (result: OutletExtrasResult): OffsetPoint[] =>
result.segments
.filter((segment) => segment.kind !== "cut")
.flatMap((segment) => segment.points);
// ↓ 되돌릴 자리(2026-09-07) — 「단이 2개 이상일 때만 반영」으로 좁히려면 아래 두 줄의
// `drawnFillPoints(extras)` 를 `extras.walls.length ? drawnFillPoints(extras) : []` 로
// 바꾸면 된다(basinExtras 도 같은 꼴). 다만 그러면 화면이 그리는 성토부선과 면적이
@@ -8,7 +8,6 @@ import type { SectionSample } from "./B06_Section_Api_Fetch";
import {
FILL_MIN_RISE_M,
FILL_SLOPE_MAX_LENGTH_M,
PIPE_CONNECT_GRADE,
FILL_SLOPE_RATIO_MIN,
REVET_HEIGHT_STEP_M,
REVET_LEAN_RATIO,
@@ -21,7 +20,6 @@ import type {
PipeEnd,
WallAdjust,
} from "./B06_Section_UI_Cross_Culvert_Types";
import { slopedCrossing } from "./B06_Section_UI_Cross_Culvert_Extra";
/** 기슭막이 하단선 폭(m) — 사다리꼴 밑변. 자리 기준(하단선 중점) 환산에 쓴다.
* `lean` = 그 벽의 전면 기울기(표준경사 · `revetWallSpec().lean`). */
@@ -370,8 +368,7 @@ export interface PipeWallPlacement {
* 지점**(벽 상단 = 노견)의 자리·invert. d는 그 점 기준 절대값(null = 기본
* defaultD, 경사길이 4m 지점), 위 한계 = 성토선 0 지점(d ≥ 0)·invert 상한.
* · x = 노견 연장 평행이동(안쪽 금지).
* · requireCrossing(유출): 매몰인데 0도 절토선이 원지반과 다시 못 만나는 자리는
* 금지 — 위쪽으로 0.05m씩 되돌린다(상하 먼저, 다음 좌우).
* · 원지반은 자리를 막지 않는다 — 묻히든 뜨든 입력 그대로(54-45).
*/
export function placePipeWall(input: {
/** 성토선 0 지점(벽 상단 = 노견)의 벽 자리(하단선 중점 offset). */
@@ -386,37 +383,14 @@ export function placePipeWall(input: {
adjust: WallAdjust;
/** d 미지정(null) 시의 기본 자리 — 성토사면 경사길이 4m 지점의 수평 성분. */
defaultD: number;
groundAt: (offset: number) => number;
limitOffset: number;
requireCrossing: boolean;
}): PipeWallPlacement {
const top0 = input.baseElevation0 + input.height;
const dLow = Math.max(
-FILL_SLOPE_RATIO_MIN * (input.edgeElevation - top0),
-FILL_SLOPE_RATIO_MIN * (input.invertCap - (top0 - input.height)),
);
let d = Math.max(input.adjust.d ?? input.defaultD, Math.ceil(dLow * 10) / 10);
let x = Math.max(input.adjust.x, 0);
if (input.requireCrossing) {
const placeable = (anchorOffset: number, invertE: number): boolean =>
invertE >= input.groundAt(anchorOffset) - 0.01 ||
slopedCrossing(
{ offset: anchorOffset, elevation: invertE },
input.outward,
-PIPE_CONNECT_GRADE,
input.groundAt,
input.limitOffset,
) !== null;
for (let pass = 0; pass < 400; pass += 1) {
const anchorOffset = input.autoOffset + input.outward * (x + d);
if (placeable(anchorOffset, top0 - d / FILL_SLOPE_RATIO_MIN - input.height)) break;
if (Math.abs(d) > 1e-9) d = d > 0 ? Math.max(0, d - 0.05) : Math.min(0, d + 0.05);
else if (x > 1e-9) x = Math.max(0, x - 0.05);
else break;
}
d = Math.round(d * 10) / 10;
x = Math.round(x * 10) / 10;
}
const d = Math.max(input.adjust.d ?? input.defaultD, Math.ceil(dLow * 10) / 10);
const x = Math.max(input.adjust.x, 0);
const topElevation = top0 - d / FILL_SLOPE_RATIO_MIN;
return {
x,
@@ -427,92 +401,6 @@ export function placePipeWall(input: {
};
}
/**
* 유입 invert를 그 높이로 내렸을 때 **유출 벽이 성립하는가**(2026-08-22 사용자 확정).
* 유입이 유출보다 높아야 하므로 유입을 내리면 유출도 따라 내려간다 — 그런데 유출이
* 원지반에 묻히고 3도 절토선이 지반과 다시 만나지 못하면 그 자리는 둘 수 없다.
* 이 경우 **유입도 더 내려가면 안 된다**(종전에는 유입만 내려가 유출이 깨졌다).
*/
export function outletReceivable(input: {
inletElevation: number;
edge: { offset_m: number; elevation_m: number };
outward: number;
height: number;
toeOffset: number;
limitOffset: number;
groundAt: (offset: number) => number;
/** 유출 벽 전면 기울기(표준경사). */
lean?: number;
}): boolean {
const invertAt = (offset: number): number =>
Math.min(input.groundAt(offset), input.inletElevation);
const auto =
minShoulderWallOffset(
input.edge,
input.outward,
input.height,
invertAt,
input.toeOffset,
input.limitOffset,
input.lean,
) ?? input.toeOffset;
const invert = invertAt(auto);
if (invert >= input.groundAt(auto) - 0.01) return true;
return (
slopedCrossing(
{ offset: auto, elevation: invert },
input.outward,
-PIPE_CONNECT_GRADE,
input.groundAt,
input.limitOffset,
) !== null
);
}
/**
* 유입 기슭막이 4축 배치 — placePipeWall에 **유출 수용 가능성 가드**를 얹은 것.
* 유입을 내리면 유출도 따라 내려가므로(유입 > 유출 조건), 유출이 못 받는 높이면
* 유입도 그만큼 못 내려간다(2026-08-22 사용자 확정).
*/
export function placeInletWall(input: {
autoOffset: number;
outward: number;
height: number;
baseElevation0: number;
edgeElevation: number;
invertCap: number;
adjust: WallAdjust;
defaultD: number;
groundAt: (offset: number) => number;
limitOffset: number;
/** 유출 쪽 수용 검사 인자 — 없으면 가드 없이 배치한다. */
outletGuard?: {
edge: { offset_m: number; elevation_m: number };
outward: number;
height: number;
toeOffset: number;
limitOffset: number;
lean?: number;
};
/** 매몰-무교차 자리 금지(유출 벽 규칙) — 독립 기슭막이는 유입도 같은 규칙을 탄다. */
requireCrossing?: boolean;
}): PipeWallPlacement {
const place = (adjust: WallAdjust): PipeWallPlacement =>
placePipeWall({ ...input, adjust, requireCrossing: input.requireCrossing === true });
let placed = place(input.adjust);
const guard = input.outletGuard;
if (!guard) return placed;
const receivable = (invert: number): boolean =>
outletReceivable({ inletElevation: invert, groundAt: input.groundAt, ...guard });
for (let pass = 0; pass < 400 && placed.d > 1e-9 && !receivable(placed.invert); pass += 1) {
placed = place({
...input.adjust,
d: Math.max(0, Math.round((placed.d - 0.05) * 100) / 100),
});
}
return placed;
}
/** 관 축·법선·양 끝단 꼭짓점을 한 번에 푸는 도구(본체 700줄 제한 — 2026-08-22). */
export interface PipeAxisSolver {
axis: OffsetPoint;
@@ -0,0 +1,128 @@
/* =============================================================================
* B06_Section_UI_Cross_Culvert_Tiers.ts
* 배수관 세트 기하(`_Cross_Culvert_Geom`)에서 떼어 낸 **벽 자리 도우미 + 다단 흙막이** 층.
* 다단 벽은 `buildExtrasAt`(공용 `buildRevetWallGeometry`)이 세우고, 여기서는 유출측과
* 집수정 계류측 두 채널의 입력을 짜고 면적용(미확정 단 제외) 결과를 함께 돌려준다.
* ========================================================================== */
import type { CrossSection } from "./B06_Section_Api_Fetch";
import { REVET_EMBED_DEPTH_M, REVET_TRAP_TOP_M } from "./B06_Section_UI_Cross_Culvert_Const";
import type { OutletExtrasResult } from "./B06_Section_UI_Cross_Culvert_Extra";
import { buildExtrasAt } from "./B06_Section_UI_Cross_Culvert_Extra";
import { fillWallBaseWidth } from "./B06_Section_UI_Cross_Culvert_Solve";
import type { OffsetPoint, WallAdjust, WallLayout } from "./B06_Section_UI_Cross_Culvert_Types";
import { outlineLeanOf } from "./B06_Section_UI_Cross_Lean";
// d의 0점 = **성토선 길이 0 지점**(벽 상단 = 노견 — 2026-08-23 사용자 확정).
// 그 자리(하단선 중점)는 이음선 상단점이 노견 끝에 오는 offset이고, 기본 자리는
// 성토선을 타고 경사길이 4m 내려간 지점(PIPE_WALL_DEFAULT_RUN_M)이다.
export const slopeZeroAnchor = (
edge: { offset_m: number },
outward: number,
wallHeight: number,
lean: number,
): number => edge.offset_m + outward * (fillWallBaseWidth(wallHeight, lean) / 2 - REVET_TRAP_TOP_M);
/** 유출 관 하단 끝점 목표 = 벽 바닥 기준 0.5m 상단(기준선)과 **전면 경사선의
* 교차점**(2026-08-22 사용자 ① — 성토부선 시작 규칙과 같은 자리). */
export const outletPipeEnd = (wall: WallLayout): OffsetPoint => {
// 기준 = 바닥 +0.5(= 관 invert 자리 — 2026-08-23부터 바닥은 invert−0.5 고정).
const reference = wall.bottomBack.elevation + REVET_EMBED_DEPTH_M;
return {
offset:
wall.points[2].offset + wall.outward * wall.lean * (wall.topJoint.elevation - reference),
elevation: reference,
};
};
// 다단 기슭막이의 성토부선까지 트림에 넣는다 — 넣지 않으면 단을 올려도 폐회로가 그대로라
// **물량이 안 바뀐다**(2026-09-07 사용자 확정). 화면이 그리는 선(`outletFill.segments`)과
// 같은 선을 면적도 보게 맞춘다 — 그리지 않는 `cut` 갈래(벽이 원지반에 묻힌 자리)는 뺀다.
export const drawnFillPoints = (result: OutletExtrasResult): OffsetPoint[] =>
result.segments.filter((segment) => segment.kind !== "cut").flatMap((segment) => segment.points);
interface SideInfo {
outward: number;
limit: number;
}
/** 다단 흙막이 두 채널 — 유출측(`extras`)과 집수정 계류측·독립 기슭막이 유입측(`basinExtras`). */
export function buildCulvertTiers(input: {
section: CrossSection;
outletStart: OffsetPoint | null;
outletBottom: number;
basinStart: OffsetPoint | null;
basinBottom: number;
outletInfo: SideInfo;
inletInfo: SideInfo;
groundAt: (offset: number) => number;
extras: WallAdjust[];
basinExtras: WallAdjust[];
outletForm: string;
inletForm: string;
equalize: boolean;
}): {
extras: OutletExtrasResult;
basinExtras: OutletExtrasResult;
extrasForArea: OutletExtrasResult;
basinExtrasForArea: OutletExtrasResult;
} {
const { section, groundAt } = input;
const culvert = section.culvert;
// 다단 벽 기울기 — 같은 측점·같은 설치 측 규칙으로 높이마다 표준경사(형태 무관 · B08 은 다단을 안 셈).
const extraLean = (form: string, pureHeightM: number): number =>
outlineLeanOf({
form,
height_m: pureHeightM,
section_mode: section.design?.section_mode,
side: culvert?.hidden_pipe ? culvert.inlet.face_side : null,
});
// 성토부선 + 다단 기슭막이(2026-08-22 — 보호공 삭제, 윗면 선만 성토부선으로).
// 유출측과 **집수정 계류측**이 같은 체계를 쓴다: 5m 넘으면 다단을 둘 수 있다.
const outletInput = {
startBottomElevation: input.outletBottom,
outward: input.outletInfo.outward,
groundAt,
limitOffset: input.outletInfo.limit,
adjusts: input.extras,
ownerForm: input.outletForm,
equalize: input.equalize,
leanFor: extraLean,
};
const extras = buildExtrasAt(input.outletStart, outletInput);
// 독립 기슭막이(관 숨김)는 집수정이 없어 이 채널이 **유입측 벽의 성토부선·다단**이다 —
// 유출측(`extras`)과 같은 시작점(관 하단 꼭짓점)·같은 `bextra` 키(2026-08-29 사용자).
const basinInput = {
startBottomElevation: input.basinBottom,
outward: input.inletInfo.outward,
groundAt,
limitOffset: input.inletInfo.limit,
adjusts: input.basinExtras,
ownerForm: input.inletForm,
equalize: false,
leanFor: extraLean,
};
const basinExtras = buildExtrasAt(input.basinStart, basinInput);
/** ⭐ 면적용 다단 — **미확정 단(높이 안 적음)부터 아래는 없는 것**으로 봄(2026-09-14 브레인 판정
* 「미확정 벽은 성토도 안 깎음 · 벽 금액과 성토 감소가 함께」). 그림은 그대로 다 그림.
* B08 도 첫 미확정 단 아래는 미확정으로 셈(`facility_structures`) — 두 곳이 같은 선에서 끊김. */
const confirmedOnly = (
built: OutletExtrasResult,
start: OffsetPoint | null,
channel: typeof outletInput,
): OutletExtrasResult => {
const firstUnset = built.appliedAdjusts.findIndex((applied) => applied.h == null);
if (firstUnset < 0) return built;
return buildExtrasAt(start, {
...channel,
adjusts: channel.adjusts.slice(0, firstUnset),
equalize: false,
});
};
return {
extras,
basinExtras,
extrasForArea: confirmedOnly(extras, input.outletStart, outletInput),
basinExtrasForArea: confirmedOnly(basinExtras, input.basinStart, basinInput),
};
}
@@ -11,8 +11,6 @@ import type { BasinAdjust, CulvertDesignTrim } from "./B06_Section_UI_Cross_Culv
import {
basinSpanOfSpec,
FILL_SLOPE_RATIO_MIN,
materialLabel,
materialLimit,
revetSpanOfSpec,
} from "./B06_Section_UI_Cross_Culvert_Const";
import { EXTRA_SPAN_DEFAULT } from "./B06_Section_UI_Cross_Culvert_Const";
@@ -156,6 +154,9 @@ export interface CulvertLink {
* 키에 세워진 단 수를 넣어, 지형·조작이 바뀌어 결과가 달라지면 다시 알린다. */
const extraLimitNotified = new Set<string>();
/** 벽마다 직전에 적용된 자리 — 자리 조작이 한계에 막혀 벽이 그대로일 때만 알리려고 둠. */
const lastApplied = new Map<string, WallAdjust>();
/** 요청 단 수보다 적게 섰음을 알린다 — 조정창을 열지 않은 경로(좌측 폼 등)에서도 뜬다.
* 종전에는 `activeRevet` 이 그 벽일 때만 떠서, 다른 길로 단 수를 바꾸면 조용히 잘렸다
* (2026-09-07). 문구는 종전 그대로 쓴다. */
@@ -539,17 +540,19 @@ export function computeCardCulvert(
applied,
]),
];
const wallOf = (role: RevetKey) =>
role.startsWith("bextra")
? layout.basinExtras[Number(role.slice(6))]
: role.startsWith("extra")
? layout.extraWalls[Number(role.slice(5))]
: layout.walls.find((wall) => wall.role === role);
for (const [role, applied] of roles) {
const requested = revetOffset.adjustFor(section, role);
const memoKey = `${section.chainage_m.toFixed(2)}|${role}`;
const before = lastApplied.get(memoKey);
lastApplied.set(memoKey, applied);
// 높이 · 지형 때문에 자리가 따라 옮겨진 것은 알리지 않음 — 벽이 그대로일 때만(54-51).
const held = (axis: "x" | "d"): boolean =>
before?.[axis] != null &&
applied[axis] != null &&
Math.abs(Number(before[axis]) - Number(applied[axis])) < 0.05;
// 축별로 요청이 잘렸으면 왜 안 됐는지 토스트로 알린다(조작 중인 벽만).
if (activeRevet === role) {
if (Math.abs(requested.x - applied.x) > 0.05) {
if (held("x") && Math.abs(requested.x - applied.x) > 0.05) {
showToast(
L(
requested.x < applied.x
@@ -559,26 +562,17 @@ export function computeCardCulvert(
"info",
);
}
if (requested.d != null && applied.d != null && Math.abs(requested.d - applied.d) > 0.05) {
if (
held("d") &&
requested.d != null &&
applied.d != null &&
Math.abs(requested.d - applied.d) > 0.05
) {
showToast(
L(requested.d < applied.d ? "B06_Cross_Revet_Limit_Up" : "B06_Cross_Revet_Limit_Down"),
"info",
);
}
// 높이가 재질 한계에 잘렸으면 재질 변경을 안내(2026-08-22 사용자 — 경고와
// 높이 해제는 재질 선택으로).
const wall = wallOf(role);
if (requested.h != null && applied.h != null && requested.h > applied.h + 0.05 && wall) {
showToast(
L("B06_Cross_Height_Limit")
.replace("{mat}", materialLabel(wall.material))
.replace("{limit}", materialLimit(wall.material).toFixed(1)),
"info",
);
}
if (requested.h != null && applied.h != null && requested.h < applied.h - 0.05) {
showToast(L("B06_Cross_Height_Floor"), "info");
}
}
// d = null(기본 자리)은 null로 되돌려 담는다 — 적용 좌표를 그대로 저장하면
// 자동 자리가 "사용자 지정"으로 굳어 지형·높이 변경을 따라가지 못한다.
+8 -3
View File
@@ -546,6 +546,8 @@ export function appendCrossDesignOverlay(
minSlope?: { points: Array<{ offset: number; elevation: number }> };
maxSlope?: { points: Array<{ offset: number; elevation: number }> };
},
// 노폭 라벨 고정 자리(B06 카드 — X 축 라벨 바로 위 가운데). 없으면 노면 위.
labelAt?: { layer: SVGElement; x: number; y: number },
): void {
const line = design.design_line;
if (!line || line.length < 2) return;
@@ -754,8 +756,11 @@ export function appendCrossDesignOverlay(
const shoulderLeft = roadEdges ? roadEdges.left.offset_m - edges.left.offset_m : null;
const shoulderRight = roadEdges ? edges.right.offset_m - roadEdges.right.offset_m : null;
const label = document.createElementNS(SVG_NS, "text");
label.setAttribute("x", String((x(edges.left.offset_m) + x(edges.right.offset_m)) / 2));
label.setAttribute("y", String(toDisplayY(edges.left.elevation_m) - 6));
label.setAttribute(
"x",
String(labelAt?.x ?? (x(edges.left.offset_m) + x(edges.right.offset_m)) / 2),
);
label.setAttribute("y", String(labelAt?.y ?? toDisplayY(edges.left.elevation_m) - 6));
label.setAttribute("class", "b06-chart__carriageway-label");
const widthText =
widened > 0.001 && typeof standardWidth === "number"
@@ -770,7 +775,7 @@ export function appendCrossDesignOverlay(
: `좌 ${shoulderLeft.toFixed(2)} / 우 ${shoulderRight.toFixed(2)}m`
}`
: widthText;
svg.append(label);
(labelAt?.layer ?? svg).append(label);
}
}
+6
View File
@@ -11,8 +11,14 @@
import { type WallLeanInput, wallLeanRatio } from "../common_util/common_util_masonry_slope";
import masonrySlope from "../resources/data_masonry/masonry_slope_2026-01-01.json";
import { REVET_FORM_DEFAULT } from "./B06_Section_UI_Cross_Culvert_Const";
/** 벽 전면 기울기 n — 표를 못 고르면 종전 0.3. */
export function leanOf(input: WallLeanInput): number {
return wallLeanRatio(masonrySlope, input);
}
/** 배관 흙막이 외곽 기울기 — 형태와 무관(형태는 안 무늬만) · 기본 형태의 표준경사. */
export function outlineLeanOf(input: WallLeanInput): number {
return leanOf({ ...input, form: REVET_FORM_DEFAULT });
}
+19 -53
View File
@@ -20,16 +20,15 @@ import { showToast } from "@ui/ui_template_elements";
import type { CrossSection } from "./B06_Section_Api_Fetch";
import {
FILL_SLOPE_RATIO_MIN,
PIPE_CONNECT_GRADE,
PIPE_WALL_DEFAULT_RUN_M,
REVET_EMBED_DEPTH_M,
REVET_THICKNESS_M,
revetHeightLimit,
WALL_MIN_PURE_HEIGHT_M,
} from "./B06_Section_UI_Cross_Culvert_Const";
import { leanOf } from "./B06_Section_UI_Cross_Lean";
import { outlineLeanOf } from "./B06_Section_UI_Cross_Lean";
import type { RevetMaterial } from "./B06_Section_UI_Cross_Culvert_Const";
import { fillWallBaseWidth, groundInterpolator } from "./B06_Section_UI_Cross_Culvert_Solve";
import { buildExtrasAt, slopedCrossing } from "./B06_Section_UI_Cross_Culvert_Extra";
import { buildExtrasAt } from "./B06_Section_UI_Cross_Culvert_Extra";
import {
ZERO_ADJUST,
type CulvertDesignTrim,
@@ -66,12 +65,6 @@ export interface RevetmentSpec {
face_slope_ratio?: number | string | null;
}
/** 표준경사 표를 읽는 벽 종류 → 형태. B08 이 돌쌓기 식으로 세는 것만(큰돌쌓기·옹벽은 종전 0.3). */
const TABLE_FORM_BY_TYPE: Record<string, string> = {
masonry_wet: "돌쌓기(찰)",
masonry_dry: "돌쌓기(메)",
};
/** 조정창 조작값 중 이 벽이 쓰는 축 — 배관 벽과 같은 형태(x 좌우·d 사면·h 높이). */
export interface RevetmentAdjust {
x?: number;
@@ -167,8 +160,10 @@ export function computeRevetmentLayout(
const spec = section.revetment;
const design = section.design;
if (!spec || !design) return null;
const requestedHeight = Number(adjust?.h ?? spec.height_m);
if (!Number.isFinite(requestedHeight) || requestedHeight <= 0) return null;
const rawHeight = adjust?.h ?? spec.height_m;
// 빈 칸만 안 그림 — 0 이하는 아래 하한(0.1)에서 멈춤(54-51).
if (rawHeight == null || !Number.isFinite(Number(rawHeight))) return null;
const requestedHeight = Number(rawHeight);
// 설치 측이 비어 있으면 **성토가 나는 쪽**에 세운다 — 좌측 「구조물 배치」의 C군 벽
// (옹벽·돌쌓기 등)에는 설치 측 칸이 없기 때문이다(2026-09-06). 양측 절토면 벽이 설
@@ -187,19 +182,15 @@ export function computeRevetmentLayout(
const limit = sampleLimit(section, outward);
if (!edge || !groundAt || limit === null) return null;
// 높이 기준 = **벽 바닥~상단**(근입 0.5 포함 — 배관·추가 벽과 같은 기준,
// 2026-08-29 사용자). 재질(형태) 한계도 이 기준으로 자른다.
const pureHeight = Math.min(
Math.max(requestedHeight, REVET_EMBED_DEPTH_M + 0.1),
revetHeightLimit(spec.form),
);
// 높이 기준 = **벽 바닥~상단**(근입 0.5 포함 — 배관·추가 벽과 같은 기준).
// 형태별 높이 한계 없음 — 사용자 입력 그대로(하한만 둠).
const pureHeight = Math.max(requestedHeight, WALL_MIN_PURE_HEIGHT_M);
/** 기준선(근입 위)~상단 — 도형 계산은 종전대로 이 값으로 한다. */
const height = pureHeight - REVET_EMBED_DEPTH_M;
// 전면 기울기 — B08 이 그 벽을 셀 때와 같은 칸(종류·요청 높이·단면유형·설치 측·사용자 칸)으로
// 표준경사를 고름(2026-09-14 B5). 높이는 형태 한계로 자르기 **전** 값 — B08 은 저장 높이를 씀.
const lean = leanOf({
form: TABLE_FORM_BY_TYPE[spec.type_id] ?? (spec.type_id === "revetment" ? spec.form : null),
// 전면 기울기 — 관 흙막이와 같은 `outlineLeanOf`(형태 무관 · 형태는 안 무늬만). 단면유형 ·
// 설치 측 · 높이 · 사용자 칸은 그대로 탐. 수량(B08)은 자기 칸으로 따로 셈.
const lean = outlineLeanOf({
height_m: requestedHeight,
section_mode: design.section_mode,
side: spec.side,
@@ -217,36 +208,12 @@ export function computeRevetmentLayout(
* (확장량 t는 아래 폴리라인에서 역산 — t ≥ 0이 각도 유지의 한계다).
*/
const defaultDrop = autoRun / FILL_SLOPE_RATIO_MIN;
/** 그 자리에 벽을 세울 수 있나 — 매몰(원지반 아래 daylight 없음) 금지. */
const placeable = (xShift: number, drop: number): boolean => {
const anchor = autoOffset + outward * (autoRun + xShift);
const invert = edge.elevation_m - drop - height;
return (
invert >= groundAt(anchor) - 0.01 ||
slopedCrossing(
{ offset: anchor, elevation: invert },
outward,
-PIPE_CONNECT_GRADE,
groundAt,
limit,
) !== null
);
};
const requestedX = Math.max(adjust?.x ?? 0, 0);
/** 각도(1:1.2)를 지키려면 그만큼은 밖으로 나가 있어야 하는 최소 수평 자리. */
const xFloor = (drop: number): number => Math.max(0, FILL_SLOPE_RATIO_MIN * drop - autoRun);
let appliedDrop = Math.max(adjust?.d ?? defaultDrop, 0);
let appliedX = Math.max(requestedX, xFloor(appliedDrop));
for (let pass = 0; pass < 400 && !placeable(appliedX, appliedDrop); pass += 1) {
// 매몰 자리 — 요청을 자동 자리 쪽으로 0.05m씩 되돌린다(상하 먼저, 다음 좌우).
if (appliedDrop > 1e-9) {
appliedDrop = Math.max(0, appliedDrop - 0.05);
appliedX = Math.max(Math.min(appliedX, requestedX), xFloor(appliedDrop));
} else if (appliedX > 1e-9) appliedX = Math.max(0, appliedX - 0.05);
else break;
}
appliedX = Math.round(appliedX * 10) / 10;
appliedDrop = Math.round(appliedDrop * 10) / 10;
// 원지반은 자리를 막지 않는다 — 묻히든 뜨든 입력 그대로(54-45). 노면 위 금지 = d ≥ 0.
const appliedDrop = Math.round(Math.max(adjust?.d ?? defaultDrop, 0) * 10) / 10;
const appliedX = Math.round(Math.max(requestedX, xFloor(appliedDrop)) * 10) / 10;
const anchorOffset = autoOffset + outward * (autoRun + appliedX);
const baseElevation = edge.elevation_m - appliedDrop - height;
@@ -264,6 +231,7 @@ export function computeRevetmentLayout(
lengthM,
floatGapM,
lean,
roadElevation: edge.elevation_m,
});
// 넣은 좌우 이동이 **각도 하한**에 눌려 통째로 무시됐으면 그 하한을 남긴다(2026-09-07).
// 실측 — d 2.6m 자리에서 하한이 1.0m 를 넘어 「1.0m 를 넣어도 0.00m 이동」이 났고,
@@ -288,7 +256,7 @@ export function computeRevetmentLayout(
ownerForm: spec.form,
equalize: false,
leanFor: (form, pureHeightM) =>
leanOf({
outlineLeanOf({
form,
height_m: pureHeightM,
section_mode: design.section_mode,
@@ -402,9 +370,7 @@ export function appendRevetmentOverlay(
const keyId = index === 0 ? "own" : `own-extra${index - 1}`;
const tooltip =
`독립 기슭막이 ${wall.form ?? ""} H=${(wall.height + REVET_EMBED_DEPTH_M).toFixed(1)}m` +
`(상단 = 성토선 접점, 전면 1:${wall.lean}(품셈 13-4-4 [주]⑪ 표준경사), 높이 한계 ${revetHeightLimit(
wall.form,
).toFixed(1)}m — 교본 7-3)` +
`(상단 = 성토선 접점, 전면 1:${wall.lean}(품셈 13-4-4 [주]⑪ 표준경사))` +
(wall.floatGapM > 0.01
? ` · ⚠ 바닥 원지반 이격 ${wall.floatGapM.toFixed(2)}m — 하부 지지 별도`
: ` · 근입 ${REVET_EMBED_DEPTH_M.toFixed(2)}m`) +
@@ -15,7 +15,7 @@
* ========================================================================== */
import type { InletStructureChoice, RevetKey } from "./B06_Section_UI_Cross_Culvert";
import { REVET_FORMS, revetHeightLimit } from "./B06_Section_UI_Cross_Culvert_Const";
import { REVET_FORMS } from "./B06_Section_UI_Cross_Culvert_Const";
import type { BasinAdjust, WallAdjust } from "./B06_Section_UI_Cross_Culvert_Types";
import type { SpanValues } from "./B06_Section_UI_Cross_Culvert_Wire";
import { L } from "./B06_Section_UI_Section_Common";
@@ -44,8 +44,6 @@ export interface StructurePanelDeps {
setForm: (key: RevetKey, form: string) => void;
/** 자동 자리로 되돌린다(4축 모두). */
reset: (key: RevetKey) => void;
/** 지금 관 길이(m) — 조정 단위가 관 길이 1m이라 창에 같이 적는다. */
pipeLengthM: () => number | null;
/** 창을 닫는다 = 구조물 선택 해제. */
close: () => void;
/** 유입측 구조물 형식(드롭다운 값 — 2026-08-22 사용자). */
@@ -155,16 +153,13 @@ export function buildStructurePanel(
const title = document.createElement("span");
title.className = "b06-structure-panel__title";
// 정보 표시(2026-08-22 사용자 — 항목당 한 행): 관 길이 / 좌우 / 상하.
// 끄는 동안 미리 보기 글만 — 관 길이 · 좌우 · 상하 자동 자리 글은 뺌(54-28).
const value = document.createElement("div");
value.className = "b06-structure-panel__value";
// 사본의 읽기 줄은 폼 칸으로 옮겨 붙는다 — 끌어 맞춘 좌우 · 상하가 폼에서도 보인다(24-4a).
if (opts?.dock) value.classList.add("b06-structure-panel__struct--readout");
const pipeLine = document.createElement("span");
const lateralLine = document.createElement("span");
const slopeLine = document.createElement("span");
const dragLine = dragReadout();
value.append(pipeLine, lateralLine, slopeLine, dragLine);
value.append(dragLine);
let current: RevetKey | null = null;
const act = (run: (key: RevetKey) => void) => () => {
@@ -235,7 +230,6 @@ export function buildStructurePanel(
const option = document.createElement("option");
option.value = form;
option.textContent = form;
option.title = `${L("B06_Cross_Height_Label")} ~${revetHeightLimit(form).toFixed(1)}m`;
materialSelect.append(option);
}
materialSelect.addEventListener("change", () => {
@@ -309,12 +303,12 @@ export function buildStructurePanel(
parts.row.classList.add("b06-structure-panel__struct--basin-size");
const readout = document.createElement("span");
readout.className = "b06-structure-panel__hval";
// 한계 1~2m 는 옛 9키 그대로.
// 한계 없음 — 그림이 안 서는 0 이하만 한 눈금에서 멈춤(54-51).
const step = (delta: number) =>
basinPatch(() => ({
[field]: Math.min(
2,
Math.max(1, Math.round((deps.basinAdjustFor()[field] + delta) * 10) / 10),
[field]: Math.max(
BASIN_STEP_M,
Math.round((deps.basinAdjustFor()[field] + delta) * 10) / 10,
),
}));
parts.controls.append(
@@ -545,7 +539,8 @@ export function buildStructurePanel(
basinReset.classList.toggle("is-hidden", !isBasin);
// I형은 내공(높이·폭) 개념이 없다 — 내공 줄을 숨긴다.
for (const entry of basinSizeRows) {
entry.row.classList.toggle("is-hidden", !isBasin || structure === "I");
// 화면에서 숨김(54-40 · 값 · 그림 계산은 그대로)
entry.row.classList.add("is-hidden");
if (isBasin)
entry.readout.textContent = `${deps.basinAdjustFor()[entry.field].toFixed(1)}m`;
}
@@ -588,6 +583,7 @@ export function buildStructurePanel(
// 이름 자체로(2026-08-30 사용자 지시 1). 어느 구조물을 만지는지 폼에서 읽힌다.
// 다단은 칸 이름이 이미 "추가 기슭막이"라 단 번호만 붙인다 — "추가 기슭막이 (2단)".
root.dataset.panelTitle = isExtra ? `${extraIndex + 1}단` : (title.textContent ?? "");
root.dataset.extraIndex = isExtra ? String(extraIndex) : ""; // 흙막이 컨테이너 차례(54-10)
const tiers =
tierChannel === "outlet"
? deps.extraState()
@@ -599,9 +595,12 @@ export function buildStructurePanel(
// 집수정 유입은 계류측 단이 설 자리가 있을 때만 — 벽이 아니라 구체다.
// 다단 벽도 포함한다 — 행은 부모 칸에 서 있고, 그 값(부모 단 수·옵션)을 그대로 쓴다.
const revetWall = ((key === "inlet" || key === "outlet") && !isBasin) || isExtra;
// 배관 유입 벽 = 다단 없음 — 이미 선 단이 있을 때만(목록에서 고른 글과 같게 · 54-29)
const pipeInlet = key === "inlet" && !isBasin && !deps.hiddenPipe();
extraRow.classList.toggle(
"is-hidden",
!revetWall && !(isBasin && tierChannel === "basin" && (tiers.canAdd || tiers.count > 0)),
(!revetWall || (pipeInlet && tiers.count === 0)) &&
!(isBasin && tierChannel === "basin" && (tiers.canAdd || tiers.count > 0)),
);
currentCount = tiers.count;
countValue.textContent = `${tiers.count}단`;
@@ -629,41 +628,6 @@ export function buildStructurePanel(
"is-hidden",
!revetWall && linkState === null && currentSpan === null,
);
const adjust = deps.adjustFor(key);
// 정보는 항목당 한 행(2026-08-22 사용자) — 0이면 "자동", 좌우는 안/바깥,
// 상하는 위/아래로 적는다.
const pipeLength = deps.pipeLengthM();
pipeLine.classList.toggle("is-hidden", pipeLength === null);
pipeLine.textContent =
pipeLength === null ? "" : `${L("B06_Cross_Revet_Pipe")} ${pipeLength}m`;
lateralLine.textContent =
`${L("B06_Cross_Lateral_Label")} ` +
(Math.abs(adjust.x) > 1e-9
? `${L(adjust.x > 0 ? "B06_Cross_Revet_Outward" : "B06_Cross_Revet_Inward")} ${Math.abs(adjust.x).toFixed(1)}m`
: L("B06_Cross_Revet_Auto"));
// d = null → 자동(기본 자리). 숫자는 성토선 0점(벽 상단=노견) 기준 절대값
// (배관 벽 — 2026-08-23). 0 = 성토선 0 지점.
slopeLine.textContent =
`${L("B06_Cross_Slope_Label")} ` +
(adjust.d == null
? L("B06_Cross_Revet_Auto")
: Math.abs(adjust.d) > 1e-9
? `${L(adjust.d > 0 ? "B06_Cross_Revet_DirDown" : "B06_Cross_Revet_DirUp")} ${Math.abs(adjust.d).toFixed(1)}m`
: "0m");
// 집수정은 벽 값이 아니라 **집수정 자리**를 적는다 — 끌어 맞춘 위치가 폼 칸에서도 보인다(24-4a).
if (isBasin) {
const basin = deps.basinAdjustFor();
lateralLine.textContent = `${L("B06_Cross_Lateral_Label")} ${
basin.lateralM > 1e-9
? `${L("B06_Cross_Revet_Outward")} ${basin.lateralM.toFixed(1)}m`
: L("B06_Cross_Revet_Auto")
}`;
slopeLine.textContent = `${L("B06_Cross_Slope_Label")} ${
basin.slopeM > 1e-9
? `${L("B06_Cross_Revet_DirDown")} ${basin.slopeM.toFixed(1)}m`
: L("B06_Cross_Revet_Auto")
}`;
}
// 행 표시가 다 끝난 뒤에 되살린다 — 숨김 토글로 창 높이가 바뀌기 전에 넣으면
// 브라우저가 잘라 버린다.
restoreScroll();
+6 -10
View File
@@ -184,7 +184,6 @@ export function createCrossSectionCard(
let highlightRevet: RevetKey | null = revetOffset?.highlightFor(section) ?? activeRevet;
let setRevetActive: RevetHighlightSetter = () => undefined;
let showRevetControl: (visible: boolean) => void = () => undefined;
let culvertPipeLengthM: number | null = null; // 관 길이(m) — 조정창 표기용
let culvertInletIsBasin = false; // 유입이 집수정인가 — 조정창 표시·제목 분기
// 이 카드의 기준벽이 **독립 기슭막이**인가(관 없는 숨김 세트). 조정창 걸음이
// 배관(1m)과 다르다(0.1m — 2026-08-29 사용자).
@@ -469,7 +468,11 @@ export function createCrossSectionCard(
// (2026-09-06 사용자 확정: 구조물 자체 면적을 빼는 것이 아니다). 그림과 면적이
// 같은 트림 값을 쓰므로 "그림은 이런데 수량은 저렇다"가 생기지 않는다.
applyStructureAreas(section, designTrim);
appendCrossDesignOverlay(plotLayer, section.design, x, toDisplayY, drawSamples, designTrim);
appendCrossDesignOverlay(plotLayer, section.design, x, toDisplayY, drawSamples, designTrim, {
layer: svg,
x: (CROSS_PAD.left + widthPx - CROSS_PAD.right) / 2,
y: heightPx - CROSS_PAD.bottom - 4,
});
// 사토장(유용토운반작업장) — 교본 6장 3절이 횡단도 표시를 요구한다. 값은 설계 결과에서
// 그대로 오고 여기서 다시 세지 않는다. 선 종류는 터파기 파선과 갈라 둔다.
appendSpoilFillOverlay(plotLayer, section.design, x, toDisplayY);
@@ -483,13 +486,7 @@ export function createCrossSectionCard(
toDisplayY,
);
}
// 배수관 세트 — 조정창이 쓸 카드 상태를 받아 둔다(2026-08-19). 관은 소유 측점
// 전용이라 링크 카드에서는 길이를 비우고, 나머지는 링크 카드도 채운다(2026-08-24).
// 숨김 기슭막이·링크 카드는 관이 없거나 옆에서 이어져 온 것 — 관 길이 표기 숨김.
culvertPipeLengthM =
isLinkedCulvert || culvertLayout?.culvert.hidden_pipe
? null
: (culvertLayout?.pipe.lengthM ?? null);
// 배수관 세트 — 조정창이 쓸 카드 상태를 받아 둔다(2026-08-19) · 링크 카드도 채운다(2026-08-24).
culvertInletIsBasin = !!culvertLayout?.basin;
culvertHiddenPipe = culvertLayout?.culvert.hidden_pipe === true;
if (culvertLayout) {
@@ -621,7 +618,6 @@ export function createCrossSectionCard(
drawnWallKeys: () => [...culvertWallSpecs.keys()],
formOfWall,
appliedD: () => culvertAppliedD,
pipeLengthM: () => culvertPipeLengthM,
inletIsBasin: () => culvertInletIsBasin,
hiddenPipe: () => culvertHiddenPipe,
inletOptions: () => culvertInletOptions,
@@ -7,7 +7,11 @@
import type { CrossSection } from "./B06_Section_Api_Fetch";
import type { RevetKey } from "./B06_Section_UI_Cross_Culvert";
import { REVET_EMBED_DEPTH_M, REVET_FORM_DEFAULT } from "./B06_Section_UI_Cross_Culvert_Const";
import {
REVET_EMBED_DEPTH_M,
REVET_FORM_DEFAULT,
WALL_MIN_PURE_HEIGHT_M,
} from "./B06_Section_UI_Cross_Culvert_Const";
import type { CulvertLayout } from "./B06_Section_UI_Cross_Culvert_Types";
import type { WallAdjust } from "./B06_Section_UI_Cross_Culvert_Types";
import type { StructurePanelDeps } from "./B06_Section_UI_Cross_Structure_Panel";
@@ -64,7 +68,6 @@ export interface StructurePanelContext {
formOfWall: (key: RevetKey) => string;
/** 마지막 계산의 실제 적용 d(상하) — d 미지정 벽의 ▲▼ 시작값. */
appliedD: () => Map<RevetKey, number>;
pipeLengthM: () => number | null;
inletIsBasin: () => boolean;
/** 기준벽이 독립 기슭막이(관 없는 숨김 세트)인가 — 조정창 걸음 분류에 쓴다. */
hiddenPipe: () => boolean;
@@ -96,14 +99,13 @@ export function structurePanelDeps(ctx: StructurePanelContext): StructurePanelDe
const current = ctx.adjustOf(key);
const base = current.h ?? ctx.heightOfWall(key);
ctx.revetOffset?.update(ctx.adjustChainage(), key, {
h: Math.round((base + deltaM) * 10) / 10,
h: Math.max(WALL_MIN_PURE_HEIGHT_M, Math.round((base + deltaM) * 10) / 10),
});
},
formFor: (key) => ctx.formOfWall(key),
setForm: (key, form) => ctx.revetOffset?.update(ctx.adjustChainage(), key, { m: form }),
heightFor: (key) => ctx.heightOfWall(key),
reset: (key) => ctx.revetOffset?.reset(ctx.adjustChainage(), key),
pipeLengthM: () => ctx.pipeLengthM(),
close: () => {
const active = ctx.activeRevet();
if (active) ctx.toggleRevet(active);
+11 -4
View File
@@ -5,9 +5,8 @@
* (2026-08-28 사용자: "배관용에서 배관만 빼면 대부분 동일해야"). 벽 1매의 합성 단면
* (하부 사다리꼴 + 상부 평행사변형, 배면 수직·전면 1:0.3)과 그 돌쌓기 표현은 여기 하나뿐.
*
* 배관 벽 계산은 아직 `_Cross_Culvert_Geom`이 자체 인라인으로 만든다 — 결과가 이 함수와
* 동일함을 화면으로 확인한 뒤 그쪽도 이 함수로 바꾼다(계획서 후속). 지금은 독립 기슭막이가
* 이 함수를 써서 배관 벽과 같은 모양·자리로 선다.
* 관 유입·유출 흙막이 · 추가 흙막이 · 사면안정 흙막이 · 옹벽이 모두 이 함수 하나로 선다.
* 형태가 바꾸는 것은 안 무늬(`_Cross_Wall_Hatch`)뿐 — 외곽은 높이·자리·기울기로만 정함.
* ========================================================================== */
import {
@@ -15,6 +14,7 @@ import {
REVET_EMBED_DEPTH_M,
REVET_LEAN_RATIO,
REVET_THICKNESS_M,
WALL_MIN_PURE_HEIGHT_M,
} from "./B06_Section_UI_Cross_Culvert_Const";
import type { RevetMaterial } from "./B06_Section_UI_Cross_Culvert_Const";
import type { OffsetPoint, WallLayout } from "./B06_Section_UI_Cross_Culvert_Types";
@@ -57,6 +57,8 @@ export interface RevetWallGeometryInput {
extraIndex?: number;
/** 전면 기울기 1:n 의 n — 표준경사(`leanOf`). 없으면 종전 0.3. */
lean?: number;
/** 노면(계획고) — 벽 윗면이 이보다 높으면 여기서 멈춤. 높이 한도는 이것 하나. */
roadElevation?: number | null;
}
/**
@@ -65,7 +67,12 @@ export interface RevetWallGeometryInput {
* 상단(t/2)+띠(t), 전면 1:0.3, 하단선 = 기준표고 −0.5m 수평 기초.
*/
export function buildRevetWallGeometry(input: RevetWallGeometryInput): WallLayout {
const { anchor, outward, height, material, role } = input;
const { anchor, outward, material, role } = input;
const road = input.roadElevation;
const height =
road != null && anchor.elevation + input.height > road + 1e-9
? Math.max(road - anchor.elevation, WALL_MIN_PURE_HEIGHT_M - REVET_EMBED_DEPTH_M)
: input.height;
const thickness = input.thickness ?? REVET_THICKNESS_M;
const lean = input.lean ?? REVET_LEAN_RATIO;
const baseWidth = thickness * 1.5 + lean * height;
@@ -8,7 +8,12 @@
* 원천이라 배수관 구간값과 같은 저장기로 되돌려 쓴다.
* ========================================================================== */
import { boxSpanM, pipeDiameterM, wingSlabExtendM } from "@util/common_util_culvert_sets";
import {
boxSpanM,
pipeDiameterM,
wingInstalled,
wingSlabExtendM,
} from "@util/common_util_culvert_sets";
import type { CrossDesign, CrossSection } from "./B06_Section_Api_Fetch";
import { DEFAULT_FORD_WALL_ADJUST } from "./B06_Section_UI_Cross_Ford";
import type { FordAdjust, FordWallAdjust, FordWallRole } from "./B06_Section_UI_Cross_Ford";
@@ -20,6 +25,8 @@ import type { BoxControl } from "./B06_Section_UI_Cross_Box_Panel";
/** 날개벽 한 벌의 저장 키 — 세월교·BOX암거가 같은 옵션 이름을 쓴다(`wing_in*`/`wing_out*`). */
type WingPatch = Partial<{
installed: boolean;
/** 폼이 낸 설치 글(날개벽 · 흙막이 …) — 있으면 저장에 그 글 그대로(있음/없음으로 안 바꿈). */
text: string;
height_m: number;
length_m: number;
angle_deg: number;
@@ -29,7 +36,8 @@ type WingPatch = Partial<{
function wingOptions(role: "inlet" | "outlet", patch: WingPatch): Record<string, number | string> {
const prefix = role === "inlet" ? "wing_in" : "wing_out";
const options: Record<string, number | string> = {};
if (patch.installed !== undefined) options[prefix] = patch.installed ? "있음" : "없음";
if (patch.installed !== undefined)
options[prefix] = patch.text ?? (patch.installed ? "있음" : "없음");
if (patch.height_m !== undefined) options[`${prefix}_height_m`] = patch.height_m;
if (patch.length_m !== undefined) options[`${prefix}_length_m`] = patch.length_m;
if (patch.angle_deg !== undefined) options[`${prefix}_angle_deg`] = patch.angle_deg;
@@ -76,8 +84,11 @@ function wingPatchFrom(patch: Record<string, number | string>, prefix: string):
return Number.isFinite(value) ? value : undefined;
};
const wing: WingPatch = {};
// 설치 값은 폼이 "있음"/"없음" 문자열로 낸다(백엔드 `_wing_spec`과 같은 규약).
if (patch[prefix] !== undefined) wing.installed = patch[prefix] !== "없음";
// 설치 값 글(있음 · 없음 · BOX 날개벽 · 흙막이) — 백엔드 `_wing_spec` 과 같은 판정.
if (patch[prefix] !== undefined) {
wing.installed = wingInstalled(patch[prefix]);
wing.text = String(patch[prefix]);
}
const heightM = num(`${prefix}_height_m`);
if (heightM !== undefined) wing.height_m = heightM;
const lengthM = num(`${prefix}_length_m`);
@@ -9,6 +9,15 @@
* 검증 → 담기 / 쓰기 → 통째 직렬화)이라 제어기마다 짝을 두던 것을 하나로 모았다.
* ========================================================================== */
import type { CrossSection } from "./B06_Section_Api_Fetch";
import {
culvertOwnerFor,
culvertReach,
culvertWallsStandAt,
type RevetLinkControl,
} from "./B06_Section_UI_Cross_Culvert_Wire";
import type { PipeRevetChoice } from "../A00_Common/design/design_structure_pipe_calc";
/** 세션에 담기는 측점별 조작값 한 겹 맵. */
export interface SessionMap<V> {
values: Map<string, V>;
@@ -101,3 +110,31 @@ export function createLinkFlagSession(sessionKey: () => string | null): LinkFlag
},
};
}
/**
* 좌측 관 보호공 [연동] · [경사](54-30) — 옛 연동 제어 그대로 읽고 씀. 연동 = 벽이 서는 옆 측점이
* 있을 때만 · 켬 = 그 측점이 모두 연동 · 끄면 모두 따로. 경사 = 보호공 구간이 있을 때만.
* ponytail: 연동을 풀 때 카드 단추가 하던 높이 굳히기는 안 함 — 필요하면 카드 높이 셈을 여기로.
*/
export function pipeRevetChoiceBridge(revetLink: RevetLinkControl) {
const linkCards = (owner: CrossSection, sections: readonly CrossSection[]) =>
sections.filter((s) => culvertOwnerFor(s, sections) === owner && culvertWallsStandAt(owner, s));
return {
read: (owner: CrossSection, sections: readonly CrossSection[]): PipeRevetChoice => {
const cards = linkCards(owner, sections);
return {
linked: cards.length ? cards.every((s) => revetLink.linkedFor(s)) : null,
grade: culvertReach(owner) ? revetLink.followGradeFor(owner) : null,
};
},
write: (
owner: CrossSection,
sections: readonly CrossSection[],
kind: "link" | "grade",
on: boolean,
): void => {
if (kind === "grade") revetLink.setFollowGrade(owner, on);
else linkCards(owner, sections).forEach((s) => revetLink.setLinked(s.chainage_m, on));
},
};
}

Some files were not shown because too many files have changed in this diff Show More