Files
Aislo/A00_Common/design/design_pipeline_probe.ts
T
eomsangdonandClaude Opus 5.5 2454bd4ba0 feat(B05 종단): 원지반 점 작은 창 = 지금 계획선(초안 포함 · 묶음 같은 계산) (368-4)
- 묶음 출력 읽기만 · ground · cross 단계 함수를 그 자리 측점 하나로 다시 부름(파생 저장 · 캐시 안 씀)
- 그 자리 측점 = [측점 추가] 뒤 묶음 측점과 같은 틀 · 반경 · 확폭(logic/design_pipeline_probe_station)
- 격자 없음 · 분석 지형 다름 = 서버 미리 뜨기 + 「저장 계획선 기준」 한 줄 · 창 글에 계획고
- 묶음 cross 차례마다 떠 있는 창 다시 그림
- 거울 시험 test_368_4(곡선표 있음 · 없음 · 직선 · 곡선 안)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013QyNXY2TUKXCFMwAca2APG
2026-10-17 13:05:23 +09:00

95 lines
4.2 KiB
TypeScript

/* =============================================================================
* A00_Common/design/design_pipeline_probe.ts
* 계산 묶음 아무 누가거리 한 장(368-4 · 요구 240-21) — 종단 원지반 점 작은 창 = 지금 계획선(초안 포함).
*
* 묶음 출력(노선 · 측점 · 종단 · 횡단 입력 · 관 · 구조물)을 읽기만 하고, 같은 단계 함수(ground · cross ·
* `crossWithUphill` · `stationSection`)를 그 자리 측점 하나로 다시 부름 — [측점 추가] 뒤 묶음이 낼 측점과
* 같은 틀 · 반경 · 확폭(기존 측점 + 그 자리로 셈). 파생 저장 · 캐시 · 묶음 상태는 안 건드림.
* 지형 격자가 없거나 분석 지형 ≠ 설계 지형이면 null(부르는 쪽이 서버 미리 뜨기로).
* ========================================================================== */
import { pagePipeline } from "./design_pipeline_page";
import type {
CrossOutput,
GroundOutput,
StageContext,
StageName,
} from "./logic/design_pipeline_types";
import { probeStation } from "./logic/design_pipeline_probe_station";
import { groundStageDeps } from "../../B05_Profile/B05_Profile_Api_TerrainGrid";
import { createGroundStage } from "../../B05_Profile/logic/B05_Profile_Pipeline_RouteGround";
import {
crossWithUphill,
type CrossInput,
} from "../../B05_Profile/logic/B05_Profile_Pipeline_Detail";
import { createCrossStage } from "../../B06_Section/logic/B06_Section_Cross_Stage";
import { pipelineCrossAt } from "../../B05_Profile/B05_Profile_UI_RouteEdit_Cross";
import type { CrossPreviewResponse } from "../../B05_Profile/B05_Profile_Api_Replan";
const SAME_M = 1e-6;
/**
* 지금 계획선(초안 포함)으로 그 누가거리 임시 횡단 — 묶음이 아직 안 셌거나 격자 없음 · 분석 지형 ≠ 설계 지형이면 null.
*/
export async function pipelineCrossAtChainage(
projectId: string,
chainageM: number,
intervalM: number,
): Promise<CrossPreviewResponse | null> {
const pipe = pagePipeline(projectId);
const route = pipe?.output("route");
const profile = pipe?.output("profile");
const ground = pipe?.output("ground");
if (!pipe || !route || !profile || !ground) return null;
const deps = groundStageDeps(projectId);
const local = deps.grid();
const terrain = pipe.input("route")?.terrain ?? null;
if (!local || (terrain !== null && terrain !== local.design)) return null;
const inputs = {
route: pipe.input("route"),
alignment: pipe.input("alignment"),
cross: pipe.input("cross"),
pipes: pipe.input("pipes"),
structures: pipe.input("structures"),
};
const existing = ground.stations.find((s) => Math.abs(s.chainageM - chainageM) < SAME_M);
let station = existing ?? null;
if (!station) {
const probe = probeStation(route.line, route.curves, ground.stations, chainageM);
if (!probe) return null;
// ground 단계 그대로 — 측점 하나 · 종단 지반선은 안 뜸(노선 선 빼고 넘김)
const ctx = {
generation: 0,
range: null,
signal: new AbortController().signal,
inputs,
out: { stations: [probe], route: { ...route, line: null } },
before: {},
prev: null,
} as unknown as StageContext<"ground">;
const filled = (await createGroundStage(deps)(ctx)) as GroundOutput;
station = filled.stations[0] ?? null;
}
if (!station) return null;
const out = {
profile,
ground: { stations: [station], longitudinal: { chainageM: [], z: [] } },
} as Partial<Record<StageName, unknown>>;
const cross: CrossOutput = createCrossStage({ grid: deps.grid }).stage({
generation: 0,
range: null,
signal: new AbortController().signal,
inputs: { ...inputs, cross: crossWithUphill(inputs.cross as CrossInput | null, [station]) },
out,
before: {},
prev: null,
} as unknown as StageContext<"cross">);
// 평면 우측 횡단 판과 같은 꼴(그림 · 요약) — 이 측점 하나만 실은 묶음처럼 넘김
const one = {
output: (name: StageName) =>
name === "ground" ? { stations: [station] } : name === "cross" ? cross : null,
} as unknown as Parameters<typeof pipelineCrossAt>[0];
return pipelineCrossAt(one, chainageM, intervalM, undefined);
}