- 사용자 노선 조작 뒤 follow 가 좌표로 다시 매긴 관 · 구조물 = 가게 초안(pipes · structures) · 놓은 틱 안에 써 되돌리기 한 걸음 · 묶음 다시 돎 0(가게 메아리는 입력으로 안 받음) - 초안을 버리면(되돌리기 · 버림) 초안 전 가게 값으로 · 열기만 하면 안 씀(349-0c) - 새 노선에서 20 m 넘게 먼 구조물 = 알림 한 줄(구조물 N건이 새 노선에서 20 m 넘게 멀어짐) - 종단 보기 왼쪽 목록 · 구조물 알약 · 측점선 = 가게 측점(배수유역도 관 알림을 가게 관 측점으로 · 관 id 옮김) · 따라간 측점은 계획고 편집 안 옮김(follow 몫) - 시험 test_349_0d_follow_store 5건(검증_sub7 노선 · 관 · 옛 코드 2 실패 재현) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TteK8mfYZetk5P3bEZkyVZ
37 lines
1.8 KiB
TypeScript
37 lines
1.8 KiB
TypeScript
/* =============================================================================
|
|
* B05_Profile/logic/B05_Profile_Pipeline_Follow.ts
|
|
* 노선이 움직인 뒤 관 목록 화면 값(PLAN 349-0d) — 배수유역도가 알린 관 목록(옛 누가거리)을 가게 관 초안
|
|
* (계산 묶음 follow 가 좌표로 다시 매긴 누가거리)에 맞춤. 짝 = 누가거리 차례(따라감은 좌표 투영이라
|
|
* 차례가 거의 그대로) · 관 수가 다르면 그대로(배수유역도가 아직 안 받은 고침).
|
|
* 순수 계산(DOM · fetch · 세션 없음).
|
|
* ========================================================================== */
|
|
|
|
interface Span {
|
|
chainage_m: number;
|
|
start_m?: number | null;
|
|
end_m?: number | null;
|
|
}
|
|
|
|
/** 관 알림 목록의 측점 · 구간을 가게 관 초안 쪽으로 — 초안이 없으면(저장분) 그대로. */
|
|
export function followPipeReports<R extends Span>(
|
|
reports: ReadonlyArray<R>,
|
|
pipes: ReadonlyArray<Span> | null,
|
|
): R[] {
|
|
if (!pipes || pipes.length !== reports.length) return [...reports];
|
|
const byChainage = (a: Span, b: Span): number => a.chainage_m - b.chainage_m;
|
|
const to = [...pipes].sort(byChainage);
|
|
return [...reports].sort(byChainage).map((report, index) => {
|
|
const pipe = to[index];
|
|
const chainage = Math.round(pipe.chainage_m * 100) / 100; // 알림 목록 자릿수(`buildPipeReports`)
|
|
const shift = chainage - report.chainage_m;
|
|
const moved = (own: number | null | undefined, from: number | null | undefined) =>
|
|
own ?? (from == null ? from : from + shift);
|
|
return {
|
|
...report,
|
|
chainage_m: chainage,
|
|
...(report.start_m != null ? { start_m: moved(pipe.start_m, report.start_m) } : {}),
|
|
...(report.end_m != null ? { end_m: moved(pipe.end_m, report.end_m) } : {}),
|
|
};
|
|
});
|
|
}
|