Files
Aislo/B05_Profile/B05_Profile_UI_Drainage_Ford_Fill.ts
T
eomsangdonandClaude Opus 5.5 157111a094 feat(B05): 우클릭 세월교 · 물넘이포장도 바로 추가 · 빈 월류 높이는 재계산 유량이 오면 그 항목에 채움(126-1)
- 우클릭 바로 추가에서 세월교 · 물넘이포장을 폼만 갈래에서 뺌 · 추가 뒤 그 측점 관 고름 + 알림 한 줄
- 배수유역 패널 — 바로 놓은 빈 높이 측점을 기다렸다가 응답 유량으로 필요 수심 채움(`fordHeightM` · 서버 `ford_height_m` 짝) · 손 값은 안 덮음 · 유량 전엔 빈칸 · 채우면 세션 초안에 다시 담음
- 세부유역 요청은 최신 응답만 채택(requestSeq)
- 시험 test_126_ford_right_click(헬퍼 helper_126_ford_fill) · test_116 기대값 고침

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UoSr2sqvYtBf1dtQdus88s
2026-10-08 19:42:46 +09:00

61 lines
2.7 KiB
TypeScript

/* =============================================================================
* B05_Profile_UI_Drainage_Ford_Fill.ts
* 우클릭으로 바로 추가한 세월교 · 물넘이포장의 빈 월류 높이 = 배수유역 재계산이 준 설계유량의
* 필요 수심(PLAN 126-1 · 폼 쪽 65-4 와 같은 풀이 `fordHeightM`).
*
* 기다리는 측점만 채움 · 사용자가 넣은 높이(응답 옵션에 있음)는 안 덮음 · 유량이 아직 없으면 다음
* 응답까지 기다림. 응답 옵션을 고쳐 두면 보관소(`replaceFromResponse`)가 그 값을 정본으로 받음.
* ========================================================================== */
import {
FORD_BRIDGE_DEFAULT_WIDTH_M,
FORD_PAVEMENT_DEFAULT_WIDTH_M,
} from "@config/config_frontend";
import { fordHeightM } from "../A00_Common/design/design_structure_ford_calc";
const FORD_KINDS: Record<string, number> = {
ford_bridge: FORD_BRIDGE_DEFAULT_WIDTH_M,
ford_pavement: FORD_PAVEMENT_DEFAULT_WIDTH_M,
};
/** 새로 놓으면 높이를 기다리는 종류 — 높이 칸이 빈 세월교 · 물넘이포장. */
export function waitsFordHeight(
facility: string | undefined,
options?: Record<string, string | number>,
): boolean {
return !!facility && facility in FORD_KINDS && options?.ford_height_m === undefined;
}
/** 기다리는 측점의 빈 높이를 채움 — 채운(또는 사용자 값이라 그만 기다릴) 측점은 `pending` 에서 뺌.
* 채운 것이 있으면 true(세션 초안에 다시 담을 것). */
export function fillFordHeights(
points: Array<{
chainage_m: number;
facility?: string;
options?: Record<string, string | number>;
}>,
basins: ReadonlyArray<{ chainage_m: number; design_flow_m3s?: number | null }>,
pending: Set<number>,
): boolean {
let filled = false;
for (const wait of [...pending]) {
const point = points.find((entry) => Math.abs(entry.chainage_m - wait) < 0.51);
if (!point?.facility || !(point.facility in FORD_KINDS)) {
pending.delete(wait); // 관이 사라졌거나 종류가 바뀜
continue;
}
if (point.options?.ford_height_m !== undefined && point.options.ford_height_m !== "") {
pending.delete(wait); // 사용자가 넣은 값 — 안 덮음
continue;
}
const flow = basins.find((entry) => Math.abs(entry.chainage_m - point.chainage_m) < 0.51);
const width = Number(point.options?.ford_width_m) || FORD_KINDS[point.facility];
const need = fordHeightM(flow?.design_flow_m3s ?? null, width);
if (need === null) continue; // 유량 아직 없음 — 다음 응답까지 빈칸
point.options = { ...point.options, ford_height_m: need };
pending.delete(wait);
filled = true;
}
return filled;
}