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:
@@ -33,6 +33,7 @@ from typing import Any
|
||||
import numpy as np
|
||||
from shapely.geometry import LineString
|
||||
|
||||
from B05_Profile.B05_Profile_Engine_RouteInitial_Merge import Guard, merge_same_side
|
||||
from B05_Profile.B05_Profile_Engine_RouteInitial_Metrics import (
|
||||
COST_CROSSING,
|
||||
COST_EARTH_M3,
|
||||
@@ -80,8 +81,8 @@ TRACE_DENSIFY_M = 2.0
|
||||
|
||||
Measure = Callable[..., dict[str, Any]]
|
||||
Route = tuple[Any, dict[str, Any]]
|
||||
# 선 → 곡선 MC 를 일반측점에 맞춘 선(못 맞추면 그 선 그대로)
|
||||
Snap = Callable[[Any], Any]
|
||||
# (선, 직접 잼) → 곡선 MC 를 일반측점에 맞춘 선(못 맞추면 그 선 그대로)
|
||||
Snap = Callable[[Any, Any], Any]
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -105,6 +106,8 @@ class Pool:
|
||||
follow: Route | None = None
|
||||
# 제약 안에서 갈 수 있는 띠 폭 어림 — 후보끼리 가장 먼 거리(m)
|
||||
band_width_m: float = 0.0
|
||||
# 큰 R · 합치기 · 측점 맞춤이 거리 한도 대신 쓰는 직접 잼(406 · `..._Merge.Guard`)
|
||||
guard: Guard | None = None
|
||||
|
||||
|
||||
def settle(route: Route, snap: Snap, measure: Measure, raw: dict[int, Route], **kw: Any) -> Route:
|
||||
@@ -125,8 +128,13 @@ def _trace(
|
||||
# 경로를 예정노선 규칙으로 단순화 · 묶음 · R 맞춤) 차례로, 위반이 최소 R 판(노드마다 곡선 ·
|
||||
# 옛 규칙)보다 많지 않은 첫 판. 모두 화면이 [확인] 때 같은 선으로 다시 짜는 꼴.
|
||||
# 같은 노드 · 같은 잼이면 다시 재지 않음(쓸기는 이웃 비중이 같은 길을 자주 냄 · 묶음마다 따로).
|
||||
# 고른 판을 측점에 맞춤(`settle` · 383-1).
|
||||
# 고른 판의 같은 쪽 이웃 곡선을 합치고(406 · `..._Merge`) 측점에 맞춤(`settle` · 383-1).
|
||||
# 큰 R · 합치기 · 측점 맞춤 모두 거리 한도 대신 직접 잼(`pool.guard`) · 비중 계산은 예상노선
|
||||
# 이격도(그 갈래 잣대 — 예상 몫을 줄이면 이격이 늘기만).
|
||||
traced = pool.traced
|
||||
guard = pool.guard
|
||||
if guard is not None and kw.get("weighted"):
|
||||
guard = guard.keeping_offset()
|
||||
key = (tuple(nodes), tuple(sorted(kw.items())))
|
||||
if key not in traced:
|
||||
floor = build_planned_polyline(
|
||||
@@ -135,7 +143,11 @@ def _trace(
|
||||
least = (floor, measure(floor, **kw))
|
||||
path = densify_route(nodes, TRACE_DENSIFY_M)
|
||||
fitted = build_planned_polyline(path, min_radius_m=min_radius_m)
|
||||
larger = (widen(fitted, path, min_radius_m), widen(floor, path, min_radius_m), fitted)
|
||||
larger = (
|
||||
widen(fitted, path, min_radius_m, guard=guard),
|
||||
widen(floor, path, min_radius_m, guard=guard),
|
||||
fitted,
|
||||
)
|
||||
chosen = next(
|
||||
(
|
||||
route
|
||||
@@ -144,7 +156,9 @@ def _trace(
|
||||
),
|
||||
least,
|
||||
)
|
||||
traced[key] = settle(chosen, pool.snap, measure, pool.raw, **kw)
|
||||
if guard is not None:
|
||||
chosen = merge_same_side(chosen, guard, min_radius_m, lambda line: measure(line, **kw))
|
||||
traced[key] = settle(chosen, lambda line: pool.snap(line, guard), measure, pool.raw, **kw)
|
||||
return traced[key]
|
||||
|
||||
|
||||
@@ -224,7 +238,7 @@ def build_pool(
|
||||
snap: Snap,
|
||||
) -> Pool:
|
||||
"""후보 묶음 — 제약 탐색 후보 → 끝 노선 셋으로 비중 크기 맞춤 → 토공 ↔ 기울기 쓸기를 더함."""
|
||||
pool = Pool(graph, snap, follow=follow)
|
||||
pool = Pool(graph, snap, follow=follow, guard=Guard(graph.grid, max_grade))
|
||||
pool.candidates, pool.bound, pool.limit = _candidates(pool, max_grade, min_radius_m, measure)
|
||||
candidates, bound, limit = pool.candidates, pool.bound, pool.limit
|
||||
ends = [follow[0], pick("earthwork", candidates)[0], pick("gentle", candidates)[0]]
|
||||
|
||||
Reference in New Issue
Block a user