fix(계산묶음): 349-0u 좌표 없는 세션 관 · 구조물 초안도 노선 따라 측점 다시 매김
- 배수유역도 · 구조물 목록이 쓰는 세션 초안 = 정본 PUT 꼴(좌표 뺌) — follow 가 투영할 자리가 없어 측점 그대로이던 흠 - follow 앞에서 좌표 없는 것은 앞 노선 위 그 누가거리 자리를 붙임(placeOnLine · common_util_route_follow) - 시험 test_349_0u_follow_draft_xy — 앞쪽 꺾임점 끌기 = 길이 는 만큼 밂 · 되돌리기 = 초안 값 · 다시하기 = 다시 밂 · 조작 하나 = 묶음 한 번 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TteK8mfYZetk5P3bEZkyVZ
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
* - `followStructures` ↔ 파이썬 `common_util_route_follow.follow_structures`(+ 0 ~ 연장 자름 ·
|
||||
* 노선과 거리 · `STRUCTURE_ROUTE_DRIFT_MAX_M` 넘으면 「노선에서 멀어짐」 · 버리지 않음).
|
||||
* - `projectOnPolyline` = shapely `LineString.project`(가장 가까운 첫 선분) · `distance`.
|
||||
* - `placeOnLine` 은 TS 만 — 좌표 없는 세션 초안(정본 PUT 꼴)을 따라가기 전 노선 위 자리로(349-0u).
|
||||
* 거울 시험 = resources/tester/test_344_2_route_pairs.py.
|
||||
* ========================================================================== */
|
||||
|
||||
@@ -46,6 +47,29 @@ export function projectOnPolyline(
|
||||
return best && walked > 0 ? { ...best, length_m: walked } : null;
|
||||
}
|
||||
|
||||
/** 좌표 없는 관 · 구조물(세션 초안 = 정본 PUT 꼴 · 좌표 뺌)에 그 누가거리의 `line` 위 자리를 붙인 사본 —
|
||||
* 좌표가 있거나 누가거리가 없으면 그대로(같은 객체). 연장 밖 누가거리는 끝 선분 위로 자름. */
|
||||
export function placeOnLine<S extends FollowingStructure>(
|
||||
items: ReadonlyArray<S>,
|
||||
line: ReadonlyArray<XY>,
|
||||
): S[] {
|
||||
return items.map((item) => {
|
||||
if ((item.x != null && item.y != null) || item.chainage_m == null) return item;
|
||||
let walked = 0;
|
||||
for (let index = 1; index < line.length; index += 1) {
|
||||
const a = line[index - 1];
|
||||
const b = line[index];
|
||||
const span = Math.hypot(b.x - a.x, b.y - a.y);
|
||||
if (span > 0 && (walked + span >= item.chainage_m || index === line.length - 1)) {
|
||||
const t = Math.min(1, Math.max(0, (item.chainage_m - walked) / span));
|
||||
return { ...item, x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t };
|
||||
}
|
||||
walked += span;
|
||||
}
|
||||
return item;
|
||||
});
|
||||
}
|
||||
|
||||
export interface FollowingPoint {
|
||||
chainage_m: number;
|
||||
x?: number | null;
|
||||
|
||||
Reference in New Issue
Block a user