refactor(472-4 ① 시설 따라감): 서버 구조물 따라감도 TS followStructures 한 벌 — Node 입구 facility.follow
- common_util_route_follow.follow_structures = run_calc 겉(같은 계약 · 제자리 고침 · site 간격 = 서버 측점 간격) - 저장 때 좌표 맞춤 fill_structure_coordinates 는 파이썬 남음(옛 좌표 지킴 · 0.1 mm 반올림 — TS placeOnLine 과 규칙 달라 옮기면 값 바뀜) · 등록부 note - 등록부 node:facility.follow · NODE_IDS · 시험 test_472_4_follow_node(옛 코드 빨강) · 344_2 · 380_3 · 410 · 459 통과 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,7 @@ NODE_IDS = frozenset(
|
||||
"corridor.mesh",
|
||||
"profile.seat",
|
||||
"facility.plus_follow",
|
||||
"facility.follow",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
- `fill_structure_coordinates` — 저장 때 노선 위 기준 자리로 x · y 채움(자리가 그대로면 옛 좌표
|
||||
지킴 · 보낸 좌표가 그 누가거리를 낳으면 살림 · 410) · 옛 자료는 읽을 때 없는 것만 채움.
|
||||
- `follow_structures` — 좌표 → 새 노선 누가거리 · 구간 끝은 같은 만큼 밂 · 노선과의 거리.
|
||||
- `follow_structures` — 좌표 → 새 노선 누가거리 · 구간 끝은 같은 만큼 밂 · 노선과의 거리
|
||||
(셈 = TS `followStructures` · Node 입구 `facility.follow` · 472-4 ①).
|
||||
|
||||
- `route_outside` — 노선 밖(시점 앞 · 종점 뒤 0.51 m 넘음) · 측점 세울 때 셈(459 · 정본에 안 씀).
|
||||
|
||||
@@ -22,15 +23,17 @@ from typing import Any, Iterable, Sequence
|
||||
|
||||
from shapely.geometry import LineString, Point
|
||||
|
||||
from common_util.common_util_calc_runner import run_calc
|
||||
from common_util.common_util_structure_station import (
|
||||
SAME_STATION_M,
|
||||
route_general_stations,
|
||||
snap_existing_station,
|
||||
snap_structure_station,
|
||||
)
|
||||
from config.config_system import STRUCTURE_ROUTE_DRIFT_MAX_M
|
||||
from config.config_system import SECTION_STATION_INTERVAL_M, STRUCTURE_ROUTE_DRIFT_MAX_M
|
||||
|
||||
_POSITION_KEYS = ("chainage_m", "start_m", "end_m")
|
||||
_FOLLOW_KEYS = ("placement", *_POSITION_KEYS, "x", "y")
|
||||
#: 노선 밖 판정(m) — 투영이 시점 앞 · 종점 뒤로 이만큼 넘으면 측점 안 세움(459 · TS 짝).
|
||||
ROUTE_OUTSIDE_M = 0.51
|
||||
|
||||
@@ -125,33 +128,31 @@ def follow_structures(
|
||||
"""좌표를 새 노선에 투영해 누가거리를 다시 매긴다(제자리) → 항목마다 (노선과 거리, 멀어짐).
|
||||
|
||||
기준 자리 = 투영 → 정수 m(노선 끝 안) · 구간 끝(`start_m` · `end_m`)은 같은 만큼 밀고 0 ~ 연장
|
||||
안으로 자름. 좌표가 없는 옛 자료는 그대로(거리 None).
|
||||
site 꼴(사토장 · 토취장 · 새 측점 안 심음) = 새 노선 일반 측점 중 가장 가까운 곳(380-3).
|
||||
안으로 자름. 좌표가 없는 옛 자료는 그대로(거리 None) · site 꼴(사토장 · 토취장) = 새 노선 일반
|
||||
측점 중 가장 가까운 곳(380-3). 셈 = TS `followStructures`(Node 입구 `facility.follow` · 472-4).
|
||||
"""
|
||||
items = list(items)
|
||||
line = _line(xy)
|
||||
if line is None:
|
||||
if line is None or not items:
|
||||
return [(None, False)] * len(items)
|
||||
length = float(line.length)
|
||||
result: list[tuple[float | None, bool]] = []
|
||||
for item in items:
|
||||
x, y = getattr(item, "x", None), getattr(item, "y", None)
|
||||
anchor = getattr(item, "chainage_m", None)
|
||||
if x is None or y is None or anchor is None:
|
||||
result.append((None, False))
|
||||
continue
|
||||
point = Point(float(x), float(y))
|
||||
at = float(line.project(point))
|
||||
target = (
|
||||
snap_existing_station(at, route_general_stations(length))
|
||||
if getattr(item, "placement", None) == "site"
|
||||
else snap_structure_station(at, [length])
|
||||
)
|
||||
shift = target - float(anchor)
|
||||
rows = [{key: getattr(item, key, None) for key in _FOLLOW_KEYS} for item in items]
|
||||
results = run_calc(
|
||||
["facility.follow"],
|
||||
{
|
||||
"follow": {
|
||||
"items": rows,
|
||||
"line": [[x, y] for x, y in line.coords],
|
||||
"max_drift_m": max_drift_m,
|
||||
"interval_m": SECTION_STATION_INTERVAL_M,
|
||||
}
|
||||
},
|
||||
)
|
||||
if results is None:
|
||||
raise RuntimeError("구조물 따라감 실패 — 계산 Node 입구(facility.follow)")
|
||||
out: list[tuple[float | None, bool]] = []
|
||||
for item, row in zip(items, results["facility.follow"], strict=True):
|
||||
for key in _POSITION_KEYS:
|
||||
value = getattr(item, key, None)
|
||||
if value is not None:
|
||||
setattr(item, key, min(max(float(value) + shift, 0.0), length))
|
||||
drift = float(line.distance(point))
|
||||
result.append((drift, drift > max_drift_m))
|
||||
return result
|
||||
if getattr(item, key, None) is not None:
|
||||
setattr(item, key, float(row["item"][key]))
|
||||
out.append((row["drift_m"], bool(row["far"])))
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user