- 낡음 판정(B05 · B06 공용 isStaleSection)에 서버 _enforce_stored_designs 짝 셋: 포장 · 기울기(물넘이 · 맹암거) · 세월교 노면 하강 - 구조물 바뀐 뒤 횡단 다시 받으면 낡은 측점 다시 셈(refreshDetailForStructures) - 다시 셈의 세월교 노면 하강 = 그 측점에 얹힌 세월교 제원(옛 저장값 안 이음) - 물넘이포장: 옮기거나 지운 옛 자리 걷고 새 자리 · 걸친 기존 측점에 얹음(빈 관 목록도) - 월류 높이 기다림: 빈 글자도 빈칸(채우는 쪽과 같은 규칙) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C6BNBFXFndbqYxu6sZuknK
74 lines
3.3 KiB
TypeScript
74 lines
3.3 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";
|
|
import { PIPE_MATCH_M } from "../A00_Common/design/design_selection";
|
|
|
|
const FORD_KINDS: Record<string, number> = {
|
|
ford_bridge: FORD_BRIDGE_DEFAULT_WIDTH_M,
|
|
ford_pavement: FORD_PAVEMENT_DEFAULT_WIDTH_M,
|
|
};
|
|
|
|
/** 프로젝트마다 높이를 기다리는 측점 — 배수유역도 판 · B06 [추가] 가 같은 표를 씀(298-1). */
|
|
const waits = new Map<string, Set<number>>();
|
|
export function fordWaitsOf(projectId: string | null): Set<number> {
|
|
const key = projectId ?? "";
|
|
if (!waits.has(key)) waits.set(key, new Set());
|
|
return waits.get(key) as Set<number>;
|
|
}
|
|
|
|
/** 새로 놓으면 높이를 기다리는 종류 — 높이 칸이 빈 세월교 · 물넘이포장. */
|
|
export function waitsFordHeight(
|
|
facility: string | undefined,
|
|
options?: Record<string, string | number>,
|
|
): boolean {
|
|
// 빈 글자도 빈칸 — 채우는 쪽(`fillFordHeights`)과 같은 규칙(314)
|
|
const height = options?.ford_height_m;
|
|
return !!facility && facility in FORD_KINDS && (height === undefined || height === "");
|
|
}
|
|
|
|
/** 기다리는 측점의 빈 높이를 채움 — 채운(또는 사용자 값이라 그만 기다릴) 측점은 `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) < PIPE_MATCH_M);
|
|
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) < PIPE_MATCH_M,
|
|
);
|
|
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;
|
|
}
|