Files
Aislo/B05_Profile/logic/B05_Profile_Util_Station.ts
T
eomsangdonandClaude Opus 5.5 f67bd52781 refactor(472-2 2-A B05 걷어내기): 안 쓰는 길 지움 — Ford 시설 칸 파일 · 노선 초기화 엔드포인트(replan/reset) · TS solveRoute · 바깥 부름 0 export 열
- B05_Profile_UI_Drainage_Facility_Ford.ts 통째 · 글 검사 시험 목록 한 줄
- POST /route/replan/reset(reset_route_plan) + TS resetRoutePlan · 머리 설명 줄
- TS solveRoute + 딸린 RouteSolveRequest · RouteSolveResponse 타입(엔드포인트 /route/solve 는 남김)
- defaultOptions · cutInnerTo · inletKindOf(+ 딸려 죽은 INLET_KINDS) · createBasinSplitFields · COLLAPSED_KEY · pointInRing · minCoverWarningText · designHalfWidths · segmentsIntersect · parseStationText — 파일 안 부름도 0 = 몸통째
- 위키 B05_Profile_Api_Fetch 의 solveRoute 줄

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:55:32 +09:00

57 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* =============================================================================
* B05_Profile_Util_Station.ts
* 측점 표기 공용 유틸 — 측점번호+잔여거리 ↔ 누가거리(chainage) 변환·서식.
*
* 구조물 위치는 저장은 누가거리(m)로 하되 **화면 입출력은 측점번호+잔여거리**로 한다
* (2026-08-17 사용자 확정). 근거: 중심선측량 측점 20m + 구조물 지점 보조말뚝
* (지식DB 설계제원_총괄 §8). 표기 예: "3+18" = 측점 3번에서 18m — 화면 표기는
* `common_util_station.stationLabel` 한 벌(거리는 정수로 보이기만 · 값은 소수).
*
* 변환식은 비정규 측점 UI(`B05_Profile_UI_IrregularStations.ts`)와 같다 —
* chainage_m = 측점번호 × 측점간격(m) + 잔여거리(m). 측점간격은 호출 시점에 받는다
* (프로젝트 설정에 따라 바뀌므로 상수로 굳히지 않는다).
* ========================================================================== */
/** 측점번호 X + 잔여거리 XX(m) → 누가거리(m). */
export function stationToChainage(station: number, remainder: number, intervalM: number): number {
return station * intervalM + remainder;
}
/** 누가거리(m) → 측점번호 + 잔여거리. 잔여거리는 [0, 간격) 범위로 정규화한다. */
export function chainageToStation(
chainageM: number,
intervalM: number,
): { station: number; remainder: number } {
if (!(intervalM > 0)) return { station: 0, remainder: Math.max(0, chainageM) };
const clamped = Math.max(0, chainageM);
let station = Math.floor(clamped / intervalM);
let remainder = clamped - station * intervalM;
// 부동소수 잔여가 간격과 사실상 같으면 다음 측점의 0으로 올린다 (19.999… → 1+0.0).
if (intervalM - remainder < 0.005) {
station += 1;
remainder = 0;
}
return { station, remainder };
}
/** 구조물 측점과 겹쳤다고 볼 거리(m) — 이보다 가까우면 규칙 측점을 지운다. */
export const STATION_MERGE_TOLERANCE_M = 0.1;
/**
* 구조물 측점과 **겹치는 규칙 측점을 지운다**(2026-09-06).
*
* 구조물은 보조말뚝을 박아 그 자리가 정본 측점이 된다. 규칙 격자(20m)와 0.1m 안에서
* 만나면 세로선·라벨이 두 겹으로 겹쳐 읽히지 않으므로 구조물 쪽만 남긴다.
*/
export function dropStationsNear<T extends { chainage_m: number }>(
stations: readonly T[],
anchors: ReadonlyArray<{ chainage_m: number }>,
toleranceM: number = STATION_MERGE_TOLERANCE_M,
): T[] {
if (anchors.length === 0) return [...stations];
return stations.filter(
(station) =>
!anchors.some((anchor) => Math.abs(anchor.chainage_m - station.chainage_m) <= toleranceM),
);
}