Files
Aislo/A00_Common/design/logic/design_pipeline_stations.ts
T
eomsangdonandClaude Opus 5.5 281c71b55b refactor(logic): 348-1 순수 계산 TS 49 파일 <페이지>/logic/ 로 옮김 — 이름 앞머리 그대로 · 동작 고침 없음
- 옮김: B04 2 · B05 23 · B06 11 · A00_Common/design 13 (9,299 줄) · 이미 logic/ 에 있던 16 파일 그대로
- 안 옮김: 묶음 입구(package.json build:*) · 파이썬 · 순수지만 계산 아닌 8 (보기 결선 · 콜백 · API 타입 · 갈아끼움 알림판)
- import 266 줄(142 파일) · 시험 · 주석 · 짝 표시 문자열 경로 고침 · B05 · B06 CLAUDE.md 짝 줄 logic/
- 시험 도우미 새 경로: 가짜 require 열쇠 · B05()/B06() 부름 · 형제 import 자리 · tsc 묶어 돌리는 시험 · 정규식 · rglob
- design_view_cross 줄 한도 시험 685 → 688 (긴 import 경로 줄바꿈 3줄)
- 확인: typecheck 0 · 서버 묶음 넷(corridor · server-calc · b07-extent · b07-note) 다시 지어 코드 같음(//#region 경로 주석만 다름) · 관련 시험 270 파일 — 남은 실패 19 는 옮기기 전과 같음

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014utrjfoW831Vc5wJUd13kL
2026-10-16 13:44:50 +09:00

57 lines
2.2 KiB
TypeScript

/* =============================================================================
* A00_Common/design/logic/design_pipeline_stations.ts
* 계산 묶음 stations 단계(PLAN 346-1) — 측점 계산은 `B05_Profile/logic/B05_Profile_Sections_Stations.ts`
* (서버 `generate_sections` 짝) · 여기는 단계 꼴 · 범위 밖 앞 값 재사용만.
* ========================================================================== */
import {
buildStations,
REUSE_MARGIN_M,
type StationsOptions,
} from "../../../B05_Profile/logic/B05_Profile_Sections_Stations";
import type {
PlanPipe,
PlanStructure,
PlanType,
} from "../../../common_util/common_util_structure_station";
import type { PipelineStation, StageContext, StageFn } from "./design_pipeline_types";
/** 범위 밖 측점은 앞 값(같은 열쇠 · 같은 자리)을 그대로 — 뒤 단계가 같은 객체로 「안 바뀜」을 앎. */
export function reuseOutside(
next: PipelineStation[],
prev: ReadonlyArray<PipelineStation> | null,
range: { fromM: number; toM: number } | null,
): PipelineStation[] {
if (!prev || !range) return next;
const old = new Map(prev.map((station) => [station.key, station]));
return next.map((station) => {
const inside =
station.chainageM >= range.fromM - REUSE_MARGIN_M &&
station.chainageM <= range.toM + REUSE_MARGIN_M;
const before = old.get(station.key);
return !inside && before && Math.abs(before.chainageM - station.chainageM) < 1e-9
? before
: station;
});
}
/** stations 단계 — 입력 관 · 구조물(follow 뒤 누가거리) · 그린 노선 · 곡선표 · 노선 초안 스냅. */
export function createStationsStage(
options: Omit<StationsOptions, "stationSnap" | "types"> & {
types: () => ReadonlyArray<PlanType>;
},
): StageFn<"stations"> {
return (ctx: StageContext<"stations">) => {
const route = ctx.out.route;
if (!route) return [];
const next = buildStations(
route.line,
route.curves,
(ctx.inputs.pipes as PlanPipe[] | null) ?? [],
(ctx.inputs.structures as PlanStructure[] | null) ?? [],
{ ...options, types: options.types(), stationSnap: ctx.inputs.route?.stationSnap ?? false },
);
return reuseOutside(next, ctx.prev, ctx.range);
};
}