Files
Aislo/B05_Profile/logic/B05_Profile_Pipeline_Follow.ts
T
eomsangdonandClaude Opus 5.5 ccccb9f527 fix(B05 구조물 · 관 자리): 등고선 좌표 따라감 · 관 짝 id · B06 관 열쇠 pipe (410 · 411-B · 411-D)
- 좌표 낡음 판정 — 좌표가 그 누가거리를 안 낳으면(마커 · 방향키 · 폼으로 누가거리만 옮김) 노선 위 자리로 다시 적음 · TS placeOnLine ↔ 파이썬 fill_structure_coordinates 짝(보낸 좌표가 누가거리를 낳으면 살림)
- 따라감 단계 — 좌표 없는 관 초안은 앞 따라감 좌표 · site 간격 넘김
- 배수 편집기 — 노선 초안 follow 가 다시 매긴 관 자리를 id 짝으로 받음(시설 속성 · 고름 함께) · 초안 버림 = 저장분 다시 읽음
- 관 짝 차례 → id — 관 알림에 고정 id · followPipeReports · shownPipes(movePipeIds 한 번에 옮김) · followedMarks 같은 자리 먼저
- B06 측점 열쇠 — 서버 관 id 도 pipe: (계산 묶음과 같은 갈래)
- 시험 test_410_follow_xy · test_411_b_pipe_id_pairing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TteK8mfYZetk5P3bEZkyVZ
2026-10-18 09:26:18 +09:00

44 lines
2.2 KiB
TypeScript

/* =============================================================================
* B05_Profile/logic/B05_Profile_Pipeline_Follow.ts
* 노선이 움직인 뒤 관 목록 화면 값(PLAN 349-0d) — 배수유역도가 알린 관 목록(옛 누가거리)을 가게 관 초안
* (계산 묶음 follow 가 좌표로 다시 매긴 누가거리)에 맞춤. 짝 = 관 고정 id(411-B · 옮겨 차례가 바뀌어도
* 그 관) · id 없는 관(막 놓은 관)끼리는 누가거리 차례 · 관 수가 다르면 그대로(배수유역도가 아직 안 받은 고침).
* 순수 계산(DOM · fetch · 세션 없음).
* ========================================================================== */
interface Span {
chainage_m: number;
start_m?: number | null;
end_m?: number | null;
id?: string | 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 byId = new Map(pipes.flatMap((pipe) => (pipe.id ? [[pipe.id, pipe]] : [])));
const paired = (report: R): boolean => Boolean(report.id && byId.has(report.id));
const loose = [...pipes].filter((pipe) => !reports.some((r) => r.id && r.id === pipe.id));
const to = loose.sort(byChainage);
const sorted = [...reports].sort(byChainage);
let next = 0;
return sorted.map((report) => {
const pipe = paired(report) ? byId.get(report.id!)! : to[next++];
if (!pipe) return report;
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) } : {}),
};
});
}