refactor(472-4 ① 추가 측점 따라감): 서버 추가 측점 따라감도 TS 한 벌 — followPlusRows · Node 입구 facility.plus_follow
- common_util_route_follow.ts followPlusRows(땅 위 자리 → 새 노선 정수 m · 같은 m 하나) · followPlusStations 가 그것을 씀 - Plus_Stations.follow_plus_stations = run_calc 겉(옮긴 수 · 쓰기 그대로) · follow_structures 끌림 걷음 - 등록부 node:facility.plus_follow · NODE_IDS · 시험 test_472_4_follow_node(옛 코드 빨강) · 368_2 · 459 통과 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""추가 측점 정본(`B05_Profile/route/plus_stations.json`) — 구조물 정본 곁(368-2 · 요구 240-21).
|
||||
|
||||
사용자가 종단 원지반선에서 넣은 일반 측점(정수 m) · 이름 없음. 자리 정본 = 좌표(x · y) — 노선이
|
||||
바뀌면 관 · 구조물처럼 새 노선에 투영해 누가거리를 다시 매김(`follow_structures` 재사용).
|
||||
바뀌면 관 · 구조물처럼 새 노선에 투영해 누가거리를 다시 매김(TS `followPlusRows` · Node 입구).
|
||||
측점 계획에는 `resolve_extra_stations` → `plan_stations(plus=)` 로 들어감(TS `planStations` 짝).
|
||||
"""
|
||||
|
||||
@@ -10,11 +10,10 @@ from __future__ import annotations
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from typing import Any, Sequence
|
||||
|
||||
from common_util.common_util_calc_runner import run_calc
|
||||
from common_util.common_util_json import atomic_write_json
|
||||
from common_util.common_util_route_follow import follow_structures
|
||||
|
||||
PLUS_STATIONS_FILE_NAME = "plus_stations.json"
|
||||
|
||||
@@ -71,23 +70,26 @@ def save_plus_stations(
|
||||
|
||||
|
||||
def follow_plus_stations(project_root: str | Path, new_xy: Sequence[Sequence[float]]) -> int:
|
||||
"""노선이 바뀔 때 좌표를 새 노선에 투영해 누가거리를 다시 매김 → 옮긴 수(같은 m 는 하나)."""
|
||||
"""노선이 바뀔 때 좌표를 새 노선에 투영해 누가거리를 다시 매김 → 옮긴 수(같은 m 는 하나).
|
||||
셈 = TS `followPlusRows`(Node 입구 `facility.plus_follow` · 472-4 ①)."""
|
||||
rows = load_plus_stations(project_root)
|
||||
items = [
|
||||
SimpleNamespace(chainage_m=float(r["chainage_m"]), x=r.get("x"), y=r.get("y")) for r in rows
|
||||
]
|
||||
if not items:
|
||||
if not rows:
|
||||
return 0
|
||||
before = [item.chainage_m for item in items]
|
||||
follow_structures(items, new_xy)
|
||||
moved = sum(a != item.chainage_m for a, item in zip(before, items))
|
||||
if moved:
|
||||
seen: set[float] = set()
|
||||
kept = []
|
||||
for item in sorted(items, key=lambda i: i.chainage_m):
|
||||
if item.chainage_m in seen:
|
||||
continue
|
||||
seen.add(item.chainage_m)
|
||||
kept.append({"chainage_m": item.chainage_m, "x": item.x, "y": item.y})
|
||||
atomic_write_json(str(plus_stations_path(project_root)), {"stations": kept})
|
||||
return moved
|
||||
results = run_calc(
|
||||
["facility.plus_follow"],
|
||||
{
|
||||
"plus": {
|
||||
"rows": [
|
||||
{"chainage_m": float(r["chainage_m"]), "x": r.get("x"), "y": r.get("y")}
|
||||
for r in rows
|
||||
],
|
||||
"line": [[float(p[0]), float(p[1])] for p in new_xy],
|
||||
}
|
||||
},
|
||||
)
|
||||
if results is None:
|
||||
raise RuntimeError("추가 측점 따라감 실패 — 계산 Node 입구(facility.plus_follow)")
|
||||
followed = results["facility.plus_follow"]
|
||||
if followed["moved"]:
|
||||
atomic_write_json(str(plus_stations_path(project_root)), {"stations": followed["rows"]})
|
||||
return int(followed["moved"])
|
||||
|
||||
Reference in New Issue
Block a user