feat(B05 노선 추천 측점 맞춤): 거리 한도 걷어 내고 직접 잼 · 합친 꼴부터 놓기 · ALGO_VERSION 6 (406-2)
- 큰 R(widen) · 측점 맞춤(Station) — 추천 후보는 이탈 한도(4 m · 6 m) 대신 Guard 직접 잼 · 예상노선 추적 · 새 초기 노선은 그대로 - 측점 맞춤 — 같은 쪽으로 가장 많이 합친 꼴부터 · 자리 = 기울기 → 가까운 측점 → 토공 가늠 나은 곳 · 잼 못 지나면 덜 나쁜 놓기 0 → 1 → 3 %p 단계 · 그래도 못 놓으면 기울기 먼저(그 자리) - Pool._trace 큰 R 판 뒤 합치기 → 측점 맞춤 · 엔진 grade_excess 걷음 - 검증_sub4 v5 대비: gradeline · earthwork · gentle 측점 밖 0 · 기울기 위반 5/4/4 → 1 · 같은 쪽 짧은 직선 15/17/14 → 8 · 절성토 ±1 % · weighted 곡선 35 → 26 · 측점 밖 1 → 5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014utrjfoW831Vc5wJUd13kL
This commit is contained in:
@@ -56,16 +56,8 @@ from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
from scipy.interpolate import RegularGridInterpolator
|
||||
|
||||
from B05_Profile.B05_Profile_Engine_RouteInitial_Metrics import (
|
||||
GRADE_SMOOTH_M,
|
||||
SAMPLE_M,
|
||||
STATION_M,
|
||||
_resample,
|
||||
route_metrics,
|
||||
smoothed_ground,
|
||||
)
|
||||
from B05_Profile.B05_Profile_Engine_RouteInitial_Metrics import GRADE_SMOOTH_M, route_metrics
|
||||
from B05_Profile.B05_Profile_Engine_RouteInitial_Pool import (
|
||||
Pool,
|
||||
build_pool,
|
||||
@@ -328,30 +320,10 @@ def generate_initial_route(
|
||||
target_grade=goal_grade,
|
||||
)
|
||||
|
||||
smooth_z = RegularGridInterpolator(
|
||||
(terrain.y, terrain.x),
|
||||
smoothed_ground(terrain, grade_smooth),
|
||||
bounds_error=False,
|
||||
fill_value=None,
|
||||
)
|
||||
|
||||
def grade_excess(points: list[tuple[float, float]]) -> float:
|
||||
# 측점 맞춤(351-2)이 옮긴 조각 — 20 m 사이 고른 지반 기울기(비교값과 같은 잣대)가 상한을
|
||||
# 넘은 만큼. 20 m 보다 짧으면 양 끝 사이.
|
||||
xy, chain = _resample(points, SAMPLE_M)
|
||||
z = smooth_z(xy[:, ::-1])
|
||||
span = min(int(round(STATION_M / SAMPLE_M)), len(z) - 1)
|
||||
if span < 1:
|
||||
return 0.0
|
||||
run = np.maximum(chain[span:] - chain[:-span], 1e-9)
|
||||
return max(0.0, float((np.abs(z[span:] - z[:-span]) / run).max()) - max_grade)
|
||||
|
||||
def fit(outline: Any, follow: bool = False) -> Any:
|
||||
# R = 일반측점(383-1) — 갈래는 옮긴 조각이 원래보다 더 가파르면 그 곡선만 그 자리(추적은
|
||||
# 제약을 안 따짐 · 새 초기 노선 `snapped_initial` 과 같은 잣대).
|
||||
moved = snap_curves_to_stations(
|
||||
outline, min_radius_m, excess=None if follow else grade_excess
|
||||
)
|
||||
def fit(outline: Any, guard: Any = None) -> Any:
|
||||
# R = 일반측점(383-1) — 갈래 후보는 직접 잼(`guard` · 406 · 거리 한도 없음) · 추적은 제약을
|
||||
# 안 따짐(새 초기 노선 `snapped_initial` 과 같은 잣대 · 거리 한도 그대로).
|
||||
moved = snap_curves_to_stations(outline, min_radius_m, guard=guard)
|
||||
return outline if moved is None else moved
|
||||
|
||||
unsnapped: dict[int, Any] = {}
|
||||
@@ -361,9 +333,7 @@ def generate_initial_route(
|
||||
# 규칙 · 같은 입력 → 같은 선. 제약은 따지지 않고 넘은 곳만 목록에 뜸.
|
||||
outline = build_planned_polyline(expected, min_radius_m=min_radius_m)
|
||||
route = (outline, measure(outline, bound=None, follow=True))
|
||||
return settle(
|
||||
route, lambda line: fit(line, True), measure, unsnapped, bound=None, follow=True
|
||||
)
|
||||
return settle(route, fit, measure, unsnapped, bound=None, follow=True)
|
||||
|
||||
def profiled(route: Any, exact: bool = True) -> None:
|
||||
if route is not None:
|
||||
|
||||
Reference in New Issue
Block a user