42 lines
2.6 KiB
TypeScript
42 lines
2.6 KiB
TypeScript
/* =============================================================================
|
|
* A00_Common/design/design_pipeline_base.ts
|
|
* 묶음 planline 의 저장 노선 종단 기준(PLAN 386-3) — 측점 한 벌을 묶음 입력(관 · 구조물)으로 셈.
|
|
*
|
|
* 종단도 `listed()`(design_profile)와 같은 셈 — 저장 상세 측점 + 구조물 · 관이 심는 측점(`listedBase`).
|
|
* 심는 측점 = 종단 보기 구조물 칸(`syncCrossDrainStations`) · 횡단 보기(`planMarkStations`)와 같은
|
|
* `planStations` → `plannedIrregular` — 보기가 종단도에 늦게 심어도 묶음은 다시 안 돎(옛 `baseMoved` 지움).
|
|
* 종류 = 구조물 정의 전부(보기와 같음). 화면 모듈을 끌어 묶음 대신 페이지(`design_shared`)가 옵션으로 넘김.
|
|
* ========================================================================== */
|
|
|
|
import { listedBase } from "./design_profile_base";
|
|
import { plannedIrregular } from "./design_structure_status";
|
|
import { withPipeIds } from "./design_pipe_ids";
|
|
import { planStations, type PlanType } from "../../common_util/common_util_structure_station";
|
|
import type { PipelineInputs } from "./logic/design_pipeline_types";
|
|
import { readAlignment } from "../../B05_Profile/logic/B05_Profile_UI_Profile_Data";
|
|
import {
|
|
toAlignmentBase,
|
|
type AlignmentBase,
|
|
} from "../../B05_Profile/logic/B05_Profile_UI_Profile_Alignment";
|
|
import type { SectionDetailResponse } from "../../B06_Section/B06_Section_Api_Fetch";
|
|
|
|
/** 저장 상세(종단도가 그리는 것) + 지금 입력이 심는 측점 = 저장 노선 종단 기준. 상세가 없으면 종단도 기준. */
|
|
export function plantedBase(
|
|
source: { base: AlignmentBase | null; detail?: SectionDetailResponse | null },
|
|
inputs: Pick<PipelineInputs, "pipes" | "structures">,
|
|
types: ReadonlyArray<PlanType>,
|
|
/** 관 세션 id — 없으면 세션 장부(`withPipeIds`) · 서버 Node 는 장부 사본(511-B). */
|
|
pipeId?: (chainageM: number) => string,
|
|
): AlignmentBase | null {
|
|
const detail = source.detail ?? null;
|
|
const stored = detail && readAlignment(detail.longitudinal);
|
|
if (!detail || !stored) return source.base;
|
|
const list = (inputs.pipes ?? []) as Array<{ chainage_m: number }>;
|
|
const pipes = pipeId
|
|
? list.map((pipe) => ({ ...pipe, id: pipeId(pipe.chainage_m) }))
|
|
: withPipeIds(list);
|
|
const structures = (inputs.structures ?? []) as Parameters<typeof planStations>[1];
|
|
const planted = plannedIrregular(planStations(pipes, structures, types), 20); // 간격 = 이름 몫 · 기준 무관
|
|
return listedBase(toAlignmentBase(stored), detail, planted);
|
|
}
|