fix(D 예정노선): 토막 지움이 노드 기록(594-1 nodes)도 같이 자름 — 뒤쪽 첫 기록 = 없음 (PLAN 598-1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 14:59:19 +09:00
co-authored by Claude Opus 5.5
parent 2e6aa17648
commit b44066da61
2 changed files with 17 additions and 8 deletions
@@ -134,15 +134,13 @@ function nextPieceId(pieces: ReadonlyArray<PlanPiece>): string {
return `p${Math.max(0, ...used) + 1}`;
}
/** 꼭짓점 [a, b) 만 남긴 선 — 꼭짓점과 같은 길이 덧 칸(노드 기록 594-1)도 같이 자름 · 첫 기록 = 없음. */
/** 꼭짓점 [a, b) 만 남긴 선 — 노드 기록(594-1)도 같이 자름 · 뒤쪽 첫 기록 = 없음(앞 노드가 사라짐). */
function cutVertices(entry: PlanLine, a: number, b: number): PlanLine {
const out: PlanLine & { nodes?: unknown[] } = { ...entry, vertices: entry.vertices.slice(a, b) };
const nodes = (entry as { nodes?: unknown }).nodes;
if (Array.isArray(nodes) && nodes.length === entry.vertices.length) {
out.nodes = nodes.slice(a, b);
if (a > 0 && out.nodes.length) out.nodes[0] = null;
}
return out;
const vertices = entry.vertices.slice(a, b);
if (!entry.nodes) return { ...entry, vertices };
const nodes = entry.nodes.slice(a, b);
if (a > 0 && nodes.length) nodes[0] = null;
return { ...entry, vertices, nodes };
}
/** 토막 하나 지움 — 하나뿐 = 구역 지움 · 끝 토막 = 끝 점 뺌 · 가운데 = 구역 둘(뒤쪽 = 새 구역 · 갈래 아님) ·
@@ -52,6 +52,12 @@ writeFileSync(process.argv[2], JSON.stringify({
all: show(sel.removeAll(n)),
nodes: sel.nodesAt(n, [200, 0]),
moved: sel.movePointsAt([[200, 0], [5, 5]], [200, 0], [210, 5]),
nodes594: (() => {
const r = { kind: "length", length_m: 100, slope_pct: null };
const withNodes = { ...n, lines: n.lines.map((l, i) => (i ? l : { ...l, nodes: [null, r, r, r] })) };
const out = sel.removeSegment(withNodes, seg("main", 1));
return out.lines.filter((l) => l.id !== "branch-1").map((l) => [l.id, l.nodes]);
})(),
}));
"""
@@ -127,3 +133,8 @@ def test_끌어_고르기_전체_지점_노드(tmp_path: Path) -> None:
assert got["all"] == {"lines": [], "pieces": []}
assert got["nodes"] == [{"line": "main", "vertex": 2}] # 갈래 첫 점 뺌
assert got["moved"] == [[210, 5], [5, 5]]
rec = {"kind": "length", "length_m": 100, "slope_pct": None}
assert got["nodes594"] == [
["main", [None, rec]],
["line-2", [None, rec]],
] # 노드 기록 같이 · 뒤쪽 첫 = 없음