Files
Aislo/B05_Profile/B05_Profile_UI_Structures_Pavement.ts
T
eomsangdonandClaude Sonnet 5.5 33119bcc67 feat(B05): 노면공 확폭 구간 상자 · 물넘이 겹침 안내 문구 · 화면 시험 맞춤(87-3 · 87-4)
- 상세 내용 아래 「확폭 구간」 상자: 범위 안 확폭 > 0 측점을 이어진 구간으로 묶어 구간마다 켬/끔 단추(기본 켬) · 끈 구간 = options.widening_off "시작-끝,…"(측점 m) · 안 맞는 값 무시 · 횡단 자료 없으면 안내
- 횡단 측점 읽기 손잡이 pipeSections(design_structure_pipe_calc) · 구간 규칙 design_structure_widening(순수)
- 물넘이 겹침 안내 = 시작 · 종료 측점을 고치라는 문구
- 시험: test_87_widening_runs(새) · ui_checks 52-10 · 52-15 시작 · 종료 측점 꼴로 맞춤

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVPp2o6Mh2FZJr72yW3ofZ
2026-10-08 12:08:15 +09:00

79 lines
3.3 KiB
TypeScript

/* =============================================================================
* B05_Profile_UI_Structures_Pavement.ts
* 포장 구간과 물넘이포장의 겹침 정리(2026-08-28 사용자 확정).
*
* 물넘이포장은 그 자체가 콘크리트 노면이라 포장 구간이 그 위를 덮을 수 없다.
* · 포장 구간이 물넘이를 **통째로 품으면** → 알리고 앞·뒤 두 구간으로 나눈다
* (물넘이가 가운데 한 구간 — 합쳐서 3구간).
* · **끝만 걸치면** → 어디까지 겹치는지 알리고 저장을 멈춘다. 사용자가 값을 고친다.
* ========================================================================== */
import { FORD_PAVEMENT_DEFAULT_WIDTH_M } from "@config/config_frontend";
import { showConfirmDialog } from "@ui/ui_template_elements";
import type { PipeFacilityItem } from "./B05_Profile_UI_Structures_Panel";
/** 누가거리 비교 허용오차(m) — 정본이 0.01m로 끊어 쓴다. */
const EPS = 0.005;
export interface Span {
start: number;
end: number;
}
/** 물넘이포장이 차지하는 누가거리 구간 — 기준 측점 ± 월류 폭/2. */
export function fordSpans(pipes: PipeFacilityItem[]): Span[] {
return pipes
.filter((pipe) => pipe.facility === "ford_pavement")
.map((pipe) => {
const raw = Number(pipe.options?.ford_width_m);
const width = Number.isFinite(raw) && raw > 0 ? raw : FORD_PAVEMENT_DEFAULT_WIDTH_M;
return { start: pipe.chainage_m - width / 2, end: pipe.chainage_m + width / 2 };
})
.sort((left, right) => left.start - right.start);
}
const format = (value: number): string => `${value.toFixed(2)}m`;
/**
* 포장 구간에서 물넘이 몫을 덜어낸다.
* 반환: 저장할 구간 목록. `null`이면 저장하지 않는다(사용자가 값을 고쳐야 한다).
*/
export async function splitPavementRange(
start: number,
end: number,
pipes: PipeFacilityItem[],
): Promise<Span[] | null> {
const overlaps = fordSpans(pipes).filter(
(ford) => ford.end > start + EPS && ford.start < end - EPS,
);
if (!overlaps.length) return [{ start, end }];
// 끝만 걸친 물넘이 — 자르면 사용자가 찍은 구간이 조용히 줄어든다. 값을 고치게 안내한다.
const partial = overlaps.find((ford) => ford.start <= start + EPS || ford.end >= end - EPS);
if (partial) {
await showConfirmDialog(
`지정한 포장 구간(${format(start)}~${format(end)})이 물넘이포장` +
`(${format(partial.start)}~${format(partial.end)})의 끝에 걸칩니다.\n` +
"물넘이는 그 자체가 포장이라 겹칠 수 없습니다 — 시작·종료 측점을 고쳐 주세요.",
"확인",
);
return null;
}
const segments: Span[] = [];
let cursor = start;
for (const ford of overlaps) {
if (ford.start - cursor > EPS) segments.push({ start: cursor, end: ford.start });
cursor = ford.end;
}
if (end - cursor > EPS) segments.push({ start: cursor, end });
const inside = overlaps.map((ford) => `${format(ford.start)}~${format(ford.end)}`).join(", ");
const proceed = await showConfirmDialog(
`포장 구간 안에 물넘이포장(${inside})이 있습니다.\n` +
`물넘이는 그 자체가 포장이라 그 몫을 빼고 ${segments.length}개 구간으로 나눠 저장합니다.`,
"나눠 저장",
);
return proceed ? segments : null;
}