- POST /sections/{r}/cross-design 엔드포인트 · CrossDesignResponse(파이썬 · TS) · CrossDesignRequest(TS) · TS computeCrossDesign 지움 — 부름 0(파이썬 CrossDesignRequest 는 test_316 이 써서 둠)
- 바깥 부름 0 export 지움 — readCrossDesignChoice · currentStationScope · culvertRequiredHalfWidth · calculateYScale · mountSectionStructureMenu · Culvert_Const 다섯 · outletSlopeFactory
- PIPE_DISPLAY_NAME = common_util_structure_catalog 로 — Section_Common 이 IrregularStations(화면) 안 끔
- Api_Fetch 세션 · 사진첩 창구 = 새 B06_Section_Api_Context.ts(fetchSectionContext · fetchCurrentRouteId · seedStandardCross) — Api_Fetch 가 b_page_state · Profile_History 안 끔
- 시험 경로 따라 고침(seedStandardCross 글 검사 · 헬퍼 흉내 모듈 이름 · 라우터 목록 시험)
- 위키 줄 번호 · 지운 엔드포인트 줄
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
120 lines
5.1 KiB
TypeScript
120 lines
5.1 KiB
TypeScript
/* =============================================================================
|
|
* B06_Section_Cross_Design_Session.ts
|
|
* 횡단 카드 버튼(지반유형·단면유형·측구·포장·2단 비탈) 선택의 **세션 보관소**.
|
|
*
|
|
* 왜 생겼나(2026-09-06 사용자 확정) — 예전에는 버튼을 누를 때마다
|
|
* `POST …/sections/{route}/cross-design` 이 나가 서버가 계산하고 **바로 저장**했다.
|
|
* 조작은 캐시에 쌓이고 [저장]·[확정]에서만 정본으로 나가야 한다는 규칙에 어긋난다.
|
|
* 계산은 브라우저가 하고(`common_util_cross_design.ts`), 선택값은 여기 담긴다.
|
|
*
|
|
* 담는 것은 **사용자가 고른 것만**이다 — 계산 결과(면적·설계선)는 담지 않는다.
|
|
* 세션 열쇠 = 측점 열쇠(344-3 · `B06_Section_Station_Keys`) · 부르는 쪽에는 누가거리로 내줌.
|
|
* ========================================================================== */
|
|
|
|
import { chainageKey } from "@util/common_util_station_key";
|
|
import { readKeyed, writeKeyed } from "./B06_Section_Station_Keys";
|
|
|
|
/** 카드에서 고를 수 있는 값 한 벌 — 서버 `CrossDesignRequest` 와 같은 이름을 쓴다. */
|
|
export interface CrossDesignChoice {
|
|
ground_type: string;
|
|
section_mode: string;
|
|
ditch_side?: string | null;
|
|
ditch_type?: string | null;
|
|
paved?: boolean;
|
|
two_stage_slope?: boolean;
|
|
/** 측구를 둘지 **사용자가 정한 선택**(`null` = 자동 판정). 결과(`ditch_enabled`)가 아니다.
|
|
* ⚠ 이 칸이 없으면 측구 토글이 눌려도 캐시에 안 담겨 **화면에서 안 돈다**(2026-09-09). */
|
|
ditch_choice?: boolean | null;
|
|
}
|
|
|
|
/** 누가거리(0.01 m 글) → 선택값 — 지금 측점에 있는 것만. */
|
|
const readAll = (projectId: string, routeId: number) =>
|
|
readKeyed<CrossDesignChoice>("crossdesign", projectId, routeId);
|
|
|
|
/** 선택값을 세션에 담는다. 같은 측점의 앞선 값은 덮어쓴다. */
|
|
export function writeCrossDesignChoice(
|
|
projectId: string,
|
|
routeId: number,
|
|
chainageM: number,
|
|
choice: CrossDesignChoice,
|
|
): void {
|
|
const at = chainageKey(chainageM);
|
|
writeKeyed("crossdesign", projectId, routeId, new Map([[at, choice]]), [at]);
|
|
}
|
|
|
|
/** [저장]·[확정]이 patch 로 실을 목록 — 누가거리(숫자) → 선택값. */
|
|
export function crossDesignChoices(
|
|
projectId: string | null,
|
|
routeId: number | null,
|
|
): Map<number, CrossDesignChoice> {
|
|
const choices = new Map<number, CrossDesignChoice>();
|
|
if (!projectId || routeId === null) return choices;
|
|
for (const [key, value] of readAll(projectId, routeId)) {
|
|
const chainage = Number(key);
|
|
if (Number.isFinite(chainage) && value) choices.set(chainage, value);
|
|
}
|
|
return choices;
|
|
}
|
|
|
|
/* ── 설계선 쉬프트 = 쪽마다 노견 확장(m · ≥ 0 · 139-6) — 카드 버튼 선택과 따로 담음(버튼 선택이
|
|
* 통째로 덮어써도 안 지워지게). [저장]·[확정] 이 patch 로 싣고, 브라우저 재계산이 입력으로 씀. */
|
|
export type ShoulderSide = "left" | "right";
|
|
export type ShoulderExtends = Map<number, Partial<Record<ShoulderSide, number>>>;
|
|
|
|
type SideState = "shoulderext" | "bermdepth";
|
|
|
|
/** 누가거리(숫자) → 쪽마다 값(세션에 있는 쪽만). */
|
|
function readSides(name: SideState, projectId: string | null, routeId: number | null) {
|
|
const out: ShoulderExtends = new Map();
|
|
if (!projectId || routeId === null) return out;
|
|
for (const [key, value] of readKeyed<Partial<Record<ShoulderSide, number>>>(
|
|
name,
|
|
projectId,
|
|
routeId,
|
|
)) {
|
|
const chainage = Number(key);
|
|
if (Number.isFinite(chainage) && value) out.set(chainage, value);
|
|
}
|
|
return out;
|
|
}
|
|
|
|
function writeSide(
|
|
name: SideState,
|
|
projectId: string,
|
|
routeId: number,
|
|
chainageM: number,
|
|
side: ShoulderSide,
|
|
valueM: number,
|
|
): void {
|
|
const at = chainageKey(chainageM);
|
|
const own = readKeyed<Partial<Record<ShoulderSide, number>>>(name, projectId, routeId).get(at);
|
|
const next = { ...(own ?? {}), [side]: Math.max(valueM, 0) };
|
|
writeKeyed(name, projectId, routeId, new Map([[at, next]]), [at]);
|
|
}
|
|
|
|
/** 누가거리(숫자) → 쪽마다 노견 확장(세션에 있는 쪽만). */
|
|
export const readShoulderExtends = (projectId: string | null, routeId: number | null) =>
|
|
readSides("shoulderext", projectId, routeId);
|
|
|
|
/** 한 측점 한 쪽 노견 확장을 담는다(0 = 되돌림 · 저장 때 정본의 옛 값을 지움). */
|
|
export const writeShoulderExtend = (
|
|
projectId: string,
|
|
routeId: number,
|
|
chainageM: number,
|
|
side: ShoulderSide,
|
|
valueM: number,
|
|
) => writeSide("shoulderext", projectId, routeId, chainageM, side, valueM);
|
|
|
|
/* ── 소단 쪽마다 옮긴 깊이(노면 끝 아래 m · ≥ 0 · 194-1 · 횡단도 ▲▼) — 노견 확장과 같은 꼴.
|
|
* [저장]·[확정] 이 patch 로 싣고(서버가 다시 셈), 브라우저 재계산이 입력으로 씀. */
|
|
export const readBermDepths = (projectId: string | null, routeId: number | null) =>
|
|
readSides("bermdepth", projectId, routeId);
|
|
|
|
export const writeBermDepth = (
|
|
projectId: string,
|
|
routeId: number,
|
|
chainageM: number,
|
|
side: ShoulderSide,
|
|
depthM: number,
|
|
) => writeSide("bermdepth", projectId, routeId, chainageM, side, depthM);
|