feat(476-1 ③): 추천 후보 초기 종단 미리 셈 — 응답 칸 initial_profile · 저장본
- 새 `B05_Profile_Engine_InitialProfile` — 후보 노드 → 화면 펴기 짝(`draft_nodes` ↔ TS flattenServerPlan) → 노선 짜기(csv 4자리) → 관 · 구조물 · 추가 측점 따라감(새 세류선 교차 관 포함) → build_sections(438 1차 계획선) → 켬 = 1 m 균형 종단 얹기(seat_base_pvi)
- 새 `B05_Profile_Router_RouteInitial_Initial.initial_profile_of` — [적용] 체인과 같은 입력 모으기 · 지문(후보 · 지형 · 페이지 설정 · 시설 파일 · 측점 옵션 · 균형 인자 · 코드) · 저장본 `route_recommend/initial/<키>.json` · 실패 = {error}
- compute_initial 응답에 `initial_profile`(stations_m · ground_m · plan_m · line · pvi_count · curve_count · straightened · max_grade_pct · curve_length_m · warnings · with_profile · seconds)
- 시험 test_476_1_recommend_initial — 미리 셈 ↔ 체인 파일 길 꼭짓점 차 0 mm(끔 · 노선 바뀜 + 옹벽 + 추가 측점 · 켬) · 지문 · 응답 칸
- 위키 calculations N2 · rules 줄
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,263 @@
|
||||
"""추천 후보 초기 종단(476 · 요구 276) — [적용]하면 작업본 · 초기값에 설 종단을 미리 셈.
|
||||
|
||||
[적용] 체인(`B05_Profile_Route_Save.run_route_save_chain`)과 같은 조각을 메모리에서 부름(파일 안
|
||||
씀):
|
||||
후보 노드 → 화면 `flattenServerPlan` 꼴(`draft_nodes`) → `build_planned_polyline`(편집 갈래 · csv
|
||||
4자리) → 관 · 구조물 · 추가 측점 따라감(`followed_pipes` · `followed_structures` ·
|
||||
`followed_plus_rows` · 새 세류선 교차 관 포함) → 측점 틀 · 1차 계획선 438(`build_sections`) →
|
||||
「종단 반영」 켬이면 1 m 균형 종단을 꼭짓점에 얹음(`seat_base_pvi` → `rebuild_alignment_profile`).
|
||||
[적용]은 이 값을 받아 적지 않음 — 서버가 체인에서 같은 조각으로 다시 셈(CLAUDE.md 5).
|
||||
|
||||
저장본 = `B05_Profile/route_recommend/initial/<결과 키>.json` `{fingerprint, profile}` — 결과 정리
|
||||
(`*.json` glob)가 안 보는 하위 폴더 · 결과 짝 없는 파일은 쓸 때 지움 · 지문 다르면 다시 셈.
|
||||
응답 칸 `initial_profile`(화면 476-2) = `{stations_m, ground_m, plan_m, line: [[s, z]…], pvi_count,
|
||||
curve_count, straightened, max_grade_pct, curve_length_m, warnings, with_profile, seconds}` · 실패 =
|
||||
`{error}`.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from common_util.common_util_json import atomic_write_json
|
||||
|
||||
INITIAL_DIR = "B05_Profile/route_recommend/initial"
|
||||
# 초기 종단을 낳는 코드(저장소 뿌리 기준) — 바뀌면 저장본 다시 셈
|
||||
SOURCE_GLOBS = (
|
||||
"B05_Profile/B05_Profile_Engine_InitialProfile.py",
|
||||
"B05_Profile/B05_Profile_Engine_Grade*.py",
|
||||
"B05_Profile/B05_Profile_Engine_Sections*.py",
|
||||
"B05_Profile/B05_Profile_Engine_RouteInitial_Profile.py",
|
||||
"B05_Profile/B05_Profile_Route_Save_Parts.py",
|
||||
"B05_Profile/B05_Profile_Plus_Stations.py",
|
||||
"common_util/common_util_route_polyline.py",
|
||||
"common_util/common_util_route_follow.py",
|
||||
"common_util/common_util_structure_station.py",
|
||||
"common_util/common_util_drainage_pipes.py",
|
||||
"config/config_system_design.py",
|
||||
)
|
||||
# 직선 위 꼭짓점(438 직선화) 판정 — 앞뒤 기울기 차(비율)
|
||||
_STRAIGHT_EPS = 1e-5
|
||||
|
||||
|
||||
def draft_nodes(
|
||||
nodes: list[dict[str, Any]], curves: list[dict[str, Any]]
|
||||
) -> tuple[list[tuple[float, float]], list[bool], list[float | None]]:
|
||||
"""후보 노드 · 곡선 → [적용] 초안(노드 · 곡선 켬 · R) — 화면 `flattenServerPlan`(편집 없음) ·
|
||||
`snapshotOf` · `routeDraftOf` 와 같은 꼴(곡선 = 교각점 하나 · R 0.01 m 반올림 = Math.round)."""
|
||||
if not curves:
|
||||
return (
|
||||
[(float(n["x"]), float(n["y"])) for n in nodes],
|
||||
[n.get("curve") is not False for n in nodes],
|
||||
[n.get("radius_m") for n in nodes],
|
||||
)
|
||||
starts = {int(c["node_first"]): c for c in curves}
|
||||
inside = {i for c in curves for i in range(int(c["node_first"]) + 1, int(c["node_last"]) + 1)}
|
||||
points: list[tuple[float, float]] = []
|
||||
flags: list[bool] = []
|
||||
radii: list[float | None] = []
|
||||
for index, node in enumerate(nodes):
|
||||
if index in inside:
|
||||
continue
|
||||
curve = starts.get(index)
|
||||
points.append(
|
||||
(float(curve["apex"][0]), float(curve["apex"][1]))
|
||||
if curve
|
||||
else (float(node["x"]), float(node["y"]))
|
||||
)
|
||||
flags.append(curve is not None)
|
||||
radii.append(math.floor(float(curve["radius_m"]) * 100 + 0.5) / 100 if curve else None)
|
||||
return points, flags, radii
|
||||
|
||||
|
||||
def candidate_line(
|
||||
nodes: list[dict[str, Any]], curves: list[dict[str, Any]], radius_m: float
|
||||
) -> tuple[list[tuple[float, float]], list[dict[str, Any]]]:
|
||||
"""[적용]이 쓸 노선(csv 4자리 = 풀린 노선 geojson) · 곡선표 — `_write_planned_polyline` 짜기."""
|
||||
from common_util.common_util_route_polyline import build_planned_polyline
|
||||
|
||||
points, flags, radii = draft_nodes(nodes, curves)
|
||||
outline = build_planned_polyline(
|
||||
points, min_radius_m=radius_m, simplify=False, curve_flags=flags, radii=radii
|
||||
)
|
||||
line = [(round(x, 4), round(y, 4)) for x, y in outline.vertices]
|
||||
return line, [curve.as_dict() for curve in outline.curves]
|
||||
|
||||
|
||||
def followed_facilities(
|
||||
project_root: Path,
|
||||
line: list[tuple[float, float]],
|
||||
old_route_data_path: str | None,
|
||||
old_xy: list[list[float]],
|
||||
old_pipes: list,
|
||||
streams: list,
|
||||
) -> tuple[list, list, list[float] | None]:
|
||||
"""체인과 같은 따라감(파일 안 씀) → (관 · 구조물 · 추가 측점 누가거리 | 없음 None)."""
|
||||
from B05_Profile.B05_Profile_Plus_Stations import followed_plus_rows, load_plus_stations
|
||||
from B05_Profile.B05_Profile_Route_Save import followed_pipes
|
||||
from B05_Profile.B05_Profile_Structures_Repository import load_structures
|
||||
from B05_Profile.B05_Profile_Structures_Router import followed_structures
|
||||
from common_util.common_util_drainage_pipes import (
|
||||
ensure_pipe_ids,
|
||||
fill_pipe_coordinates,
|
||||
parse_pipe_points,
|
||||
)
|
||||
|
||||
points = [{"x": x, "y": y} for x, y in line]
|
||||
items = load_structures(str(project_root))[1]
|
||||
if items:
|
||||
followed_structures(project_root, items, old_route_data_path, points)
|
||||
rows = load_plus_stations(project_root)
|
||||
plus = (
|
||||
sorted({float(r["chainage_m"]) for r in followed_plus_rows(rows, line)["rows"]})
|
||||
if rows
|
||||
else None
|
||||
)
|
||||
pairs, _crossing, vertices = followed_pipes(old_pipes, old_xy, points, streams)
|
||||
pipes = [pipe for _, pipe in pairs]
|
||||
fill_pipe_coordinates(pipes, vertices)
|
||||
ensure_pipe_ids(pipes)
|
||||
# 체인은 관 정본을 쓰고 다시 읽음(지문 같음 = 저장분 그대로) — 같은 왕복
|
||||
return parse_pipe_points([pipe.as_dict() for pipe in pipes]), items, plus
|
||||
|
||||
|
||||
def initial_longitudinal(
|
||||
project_root: Path,
|
||||
line: list[tuple[float, float]],
|
||||
curves: list[dict[str, Any]],
|
||||
sampler: Any,
|
||||
facilities: tuple[list, list, list[float] | None],
|
||||
*,
|
||||
options: Any,
|
||||
grade_options: Any,
|
||||
source_snapshot: dict[str, Any],
|
||||
crs: str | None,
|
||||
target: tuple[list[float], list[float]] | None,
|
||||
) -> dict[str, Any]:
|
||||
"""[적용] 체인이 남길 종단(측점 · 계획선) — 측점 생성 · 균형 얹기와 같은 조각."""
|
||||
from B05_Profile.B05_Profile_Engine_Grade_Profile import rebuild_alignment_profile
|
||||
from B05_Profile.B05_Profile_Engine_Sections import build_sections, resolve_extra_stations
|
||||
from B05_Profile.B05_Profile_Router_RouteInitial import seat_base_pvi
|
||||
|
||||
polyline = [[x, y, 0.0] for x, y in line]
|
||||
pipes, structures, plus = facilities
|
||||
extras = resolve_extra_stations(project_root, pipes, polyline, structures=structures, plus=plus)
|
||||
result, _summary = build_sections(
|
||||
polyline,
|
||||
sampler,
|
||||
pipes,
|
||||
extras,
|
||||
options=options,
|
||||
grade_options=grade_options,
|
||||
source_snapshot=source_snapshot,
|
||||
crs=crs,
|
||||
design_curves=curves,
|
||||
station_snap=True, # [적용] = 스냅 켬 · 측점 No.(`saveRecommendedRoute`)
|
||||
station_snap_step=None,
|
||||
)
|
||||
longitudinal = result["longitudinal"]
|
||||
if target is not None and longitudinal.get("profile_alignment"):
|
||||
seat_base_pvi(longitudinal, *target)
|
||||
alignment, profile = rebuild_alignment_profile(longitudinal, {})
|
||||
longitudinal["profile_alignment"] = alignment
|
||||
longitudinal["design_profiles"][0] = profile
|
||||
return longitudinal
|
||||
|
||||
|
||||
def straightened_count(base: list[dict[str, Any]]) -> int:
|
||||
"""앞뒤 기울기가 같은 안쪽 꼭짓점 수 = 직선 위(438 직선화 · 종단곡선 없음)."""
|
||||
s = [float(p["chainage_m"]) for p in base]
|
||||
z = [float(p["elevation_m"]) for p in base]
|
||||
grades = [(z[i + 1] - z[i]) / (s[i + 1] - s[i]) for i in range(len(s) - 1)]
|
||||
return sum(abs(grades[i] - grades[i - 1]) < _STRAIGHT_EPS for i in range(1, len(grades)))
|
||||
|
||||
|
||||
def profile_summary(longitudinal: dict[str, Any]) -> dict[str, Any]:
|
||||
"""응답 칸 `initial_profile` — 측점 · 지반 · 계획고 · 계획선(종단곡선 포함) · 수."""
|
||||
alignment = longitudinal.get("profile_alignment")
|
||||
if not isinstance(alignment, dict) or not alignment.get("base_pvi"):
|
||||
return {"error": "계획선을 세우지 못했습니다(지반고 종단)."}
|
||||
summary = longitudinal["design_profiles"][0]["summary"]
|
||||
rows = alignment.get("stations") or []
|
||||
return {
|
||||
"stations_m": [round(float(r["chainage_m"]), 3) for r in rows],
|
||||
"ground_m": [round(float(r["ground_elevation_m"]), 3) for r in rows],
|
||||
"plan_m": [round(float(r["plan_elevation_m"]), 4) for r in rows],
|
||||
"line": [
|
||||
[round(float(p["chainage_m"]), 3), round(float(p["elevation_m"]), 4)]
|
||||
for p in alignment.get("samples") or []
|
||||
],
|
||||
"pvi_count": len(alignment["base_pvi"]),
|
||||
"curve_count": int(summary.get("vertical_curve_count") or 0),
|
||||
"straightened": straightened_count(alignment["base_pvi"]),
|
||||
"max_grade_pct": round(float(summary.get("max_grade_pct") or 0.0), 2),
|
||||
"curve_length_m": (alignment.get("policy") or {}).get("default_curve_length_m"),
|
||||
"warnings": list(alignment.get("warnings") or []),
|
||||
}
|
||||
|
||||
|
||||
def source_fingerprint() -> str:
|
||||
"""초기 종단 코드 지문 — `SOURCE_GLOBS` 내용(줄끝 LF)."""
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
digest = hashlib.blake2b(digest_size=8)
|
||||
for path in sorted({p for pattern in SOURCE_GLOBS for p in root.glob(pattern)}):
|
||||
digest.update(path.name.encode())
|
||||
digest.update(path.read_bytes().replace(b"\r\n", b"\n"))
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def file_marks(paths: list[Path]) -> list[str]:
|
||||
"""지문에 드는 파일 자국 — 내용 해시(작은 정본) · 없음 「-」."""
|
||||
marks = []
|
||||
for path in paths:
|
||||
try:
|
||||
marks.append(hashlib.blake2b(path.read_bytes(), digest_size=8).hexdigest())
|
||||
except OSError:
|
||||
marks.append("-")
|
||||
return marks
|
||||
|
||||
|
||||
def stat_marks(paths: list[Path]) -> list[str]:
|
||||
"""큰 자료(지형 npz · 도엽) 자국 — 이름 · 크기 · 수정시각."""
|
||||
marks = []
|
||||
for path in sorted(paths):
|
||||
try:
|
||||
info = path.stat()
|
||||
marks.append(f"{path.name}:{info.st_size}:{info.st_mtime_ns}")
|
||||
except OSError:
|
||||
marks.append(f"{path.name}:-")
|
||||
return marks
|
||||
|
||||
|
||||
def fingerprint(parts: dict[str, Any]) -> str:
|
||||
text = json.dumps({**parts, "source": source_fingerprint()}, sort_keys=True, default=str)
|
||||
return hashlib.blake2b(text.encode(), digest_size=16).hexdigest()
|
||||
|
||||
|
||||
def _path(project_root: Path, key: str) -> Path:
|
||||
return Path(project_root) / INITIAL_DIR / f"{key}.json"
|
||||
|
||||
|
||||
def read_initial(project_root: Path, key: str, mark: str) -> dict[str, Any] | None:
|
||||
"""저장본 — 없거나 지문 다르면 None."""
|
||||
try:
|
||||
data = json.loads(_path(project_root, key).read_text(encoding="utf-8"))
|
||||
except (OSError, ValueError):
|
||||
return None
|
||||
return (
|
||||
data.get("profile") if isinstance(data, dict) and data.get("fingerprint") == mark else None
|
||||
)
|
||||
|
||||
|
||||
def write_initial(project_root: Path, key: str, mark: str, profile: dict[str, Any]) -> None:
|
||||
"""한 결과에 하나(덮어씀) · 결과 저장본 짝 없는 파일 지움."""
|
||||
path = _path(project_root, key)
|
||||
atomic_write_json(path, {"fingerprint": mark, "profile": profile})
|
||||
results = path.parent.parent
|
||||
for other in path.parent.glob("*.json"):
|
||||
if not (results / other.name).exists():
|
||||
other.unlink(missing_ok=True)
|
||||
@@ -66,6 +66,7 @@ async def compute_initial(
|
||||
request_fingerprint,
|
||||
write_stored,
|
||||
)
|
||||
from B05_Profile.B05_Profile_Router_RouteInitial_Initial import initial_profile_of
|
||||
from common_util.common_util_surface_confirmation import (
|
||||
analysis_terrain_params,
|
||||
get_surface_confirmation_params,
|
||||
@@ -175,6 +176,13 @@ async def compute_initial(
|
||||
profile.update(cover_shortfall(profile, line, pipes))
|
||||
except (FileNotFoundError, ValueError) as error:
|
||||
return JSONResponse(status_code=409, content={"status": "error", "message": str(error)})
|
||||
# [적용]하면 설 초기 종단(476) — 같은 조각으로 미리 셈 · 저장본 · 실패 = {error}(추천은 그대로)
|
||||
result = {
|
||||
**result,
|
||||
"initial_profile": await initial_profile_of( # 476
|
||||
project_id, project_root, paths[1], result, request, selection, key
|
||||
),
|
||||
}
|
||||
logger.info(
|
||||
"초기 계획노선 %s(%s): project_id=%s %.1fs 연장 %.0fm 이격 평균 %.1fm",
|
||||
request.mode,
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
"""추천 후보 초기 종단 모으기(476) — `POST /route/initial` 결과에 `initial_profile` 을 붙임.
|
||||
|
||||
입력 모으기(DB · 파일) · 지문 · 저장본 = 여기 · 셈 조각 = `B05_Profile_Engine_InitialProfile`(머리에
|
||||
흐름 · 응답 칸). `B05_Profile_Router_RouteInitial`(700줄)에서 나눔 — `compute_initial` 이 부름.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import functools
|
||||
import logging
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from uuid import UUID
|
||||
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from config.config_db import get_db_pool
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def initial_profile_of(
|
||||
project_id: UUID,
|
||||
project_root: Path,
|
||||
stored_path: str,
|
||||
result: dict[str, Any],
|
||||
request: Any,
|
||||
selection: dict[str, Any],
|
||||
key: str,
|
||||
) -> dict[str, Any]:
|
||||
"""추천 후보 초기 종단(476 · `B05_Profile_Engine_InitialProfile` 머리) — [적용] 체인과 같은
|
||||
입력 · 같은 조각 · 지문 같으면 저장본 꺼냄. 실패 = `{error}`."""
|
||||
from dataclasses import asdict
|
||||
|
||||
import aiomysql
|
||||
|
||||
from B03_FileInput.B03_FileInput_Service_Chain import redesign_solve_request
|
||||
from B04_PreProcess.B04_PreProcess_Router_Watershed import STREAM_FILE, _prepare, _sheet_dir
|
||||
from B05_Profile import B05_Profile_Engine_InitialProfile as ip
|
||||
from B05_Profile import B05_Profile_Router_Replan as replan
|
||||
from B05_Profile.B05_Profile_Engine_Sections import _MODELS_SUBDIR
|
||||
from B05_Profile.B05_Profile_Plus_Stations import plus_stations_path
|
||||
from B05_Profile.B05_Profile_Repository import get_latest_route
|
||||
from B05_Profile.B05_Profile_Route_Save import _xy, section_seed
|
||||
from B05_Profile.B05_Profile_Router_RouteInitial import balanced_profile_of, project_standard
|
||||
from B05_Profile.B05_Profile_Structures_Repository import structures_file_path
|
||||
from B06_Section.B06_Section_Repository import (
|
||||
get_latest_section_options,
|
||||
get_route_generation_source,
|
||||
)
|
||||
from B06_Section.B06_Section_Router_Regenerate_Options import (
|
||||
_regeneration_grade_options,
|
||||
_regeneration_options,
|
||||
)
|
||||
from common_util.common_util_drainage_pipes import pipe_points_path, read_pipe_points_file
|
||||
from common_util.common_util_surface_sampler import build_surface_sampler
|
||||
from common_util.common_util_workflow_state import get_workflow_state
|
||||
|
||||
started = time.perf_counter()
|
||||
try:
|
||||
radius_m, _, _ = await replan._plan_criteria(project_id) # [적용] 노선 짜기와 같은 R
|
||||
line, curves = ip.candidate_line(result["nodes"], result.get("curves") or [], radius_m)
|
||||
pool = get_db_pool()
|
||||
async with pool.acquire() as connection:
|
||||
latest = await get_latest_route(connection, project_id)
|
||||
source = (
|
||||
await get_route_generation_source(connection, project_id, int(latest["id"]))
|
||||
if latest
|
||||
else None
|
||||
)
|
||||
old_options = await get_latest_section_options(connection, project_id)
|
||||
async with connection.cursor(aiomysql.DictCursor) as cursor:
|
||||
state = await get_workflow_state(cursor, str(project_id))
|
||||
if not latest:
|
||||
return {"error": "저장된 노선이 없어 초기 종단을 셀 수 없습니다(자동설계 먼저)."}
|
||||
stage2 = next((s for s in state.get("stages", []) if int(s.get("stage_no", -1)) == 2), None)
|
||||
params = dict((stage2 or {}).get("params") or {})
|
||||
first, last = line[0], line[-1]
|
||||
# 체인 = 새 노선 점으로 stage 2 를 세움 — 측점 간격 · 계획선 기준엔 무관
|
||||
params["points"] = {
|
||||
"bp": {"x": first[0], "y": first[1]},
|
||||
"ep": {"x": last[0], "y": last[1]},
|
||||
}
|
||||
model_id = int(latest.get("surface_model_id") or 0)
|
||||
seed = section_seed(redesign_solve_request(params, selection, model_id), old_options)
|
||||
options = _regeneration_options(seed, params, float(seed["cross_half_width_m"]))
|
||||
grade_options = _regeneration_grade_options(params)
|
||||
epsg = (source or {}).get("crs_epsg")
|
||||
crs = f"EPSG:{epsg}" if epsg is not None else None
|
||||
surface = {k: selection.get(k) for k in ("source_filter", "method", "smooth")}
|
||||
models = project_root / _MODELS_SUBDIR
|
||||
route_path = str(latest.get("route_data_path") or "")
|
||||
mark = ip.fingerprint(
|
||||
{
|
||||
"key": key,
|
||||
"nodes": result["nodes"],
|
||||
"curves": result.get("curves"),
|
||||
"radius": radius_m,
|
||||
"surface": surface,
|
||||
"models": ip.stat_marks(list(models.glob(f"*_{surface['source_filter']}*.npz"))),
|
||||
"streams": ip.stat_marks([_sheet_dir(stored_path) / STREAM_FILE]),
|
||||
"files": ip.file_marks(
|
||||
[
|
||||
pipe_points_path(stored_path),
|
||||
Path(structures_file_path(str(project_root))),
|
||||
plus_stations_path(project_root),
|
||||
project_root / route_path,
|
||||
]
|
||||
),
|
||||
"options": asdict(options),
|
||||
"grade": grade_options.as_dict() if grade_options else None,
|
||||
"crs": crs,
|
||||
"with_profile": request.with_profile,
|
||||
"criteria": request.criteria.model_dump() if request.criteria else None,
|
||||
"standard": await project_standard(project_id),
|
||||
"road": await replan._road_settings(project_id),
|
||||
}
|
||||
)
|
||||
stored = await asyncio.to_thread(ip.read_initial, project_root, key, mark)
|
||||
if stored is not None:
|
||||
return stored
|
||||
prepared = await _prepare(project_id)
|
||||
streams = [] if isinstance(prepared, JSONResponse) else prepared["streams"]
|
||||
facilities = await asyncio.to_thread(
|
||||
ip.followed_facilities,
|
||||
project_root,
|
||||
line,
|
||||
route_path or None,
|
||||
_xy(project_root, route_path),
|
||||
read_pipe_points_file(pipe_points_path(stored_path)),
|
||||
streams,
|
||||
)
|
||||
target = None
|
||||
if request.with_profile: # [적용] `balanced_target` 과 같은 셈(노선 정점 · 새 곡선표)
|
||||
points = [{"x": x, "y": y} for x, y in line]
|
||||
balanced = await balanced_profile_of(
|
||||
project_id, project_root, points, request.criteria, curves
|
||||
)
|
||||
target = None if balanced is None else (balanced["stations_m"], balanced["plan_m"])
|
||||
sampler = await asyncio.to_thread(
|
||||
build_surface_sampler,
|
||||
models,
|
||||
str(surface["source_filter"]),
|
||||
str(surface["method"] or "dtm"),
|
||||
bool(surface["smooth"]),
|
||||
)
|
||||
longitudinal = await asyncio.to_thread(
|
||||
functools.partial(
|
||||
ip.initial_longitudinal,
|
||||
project_root,
|
||||
line,
|
||||
curves,
|
||||
sampler,
|
||||
facilities,
|
||||
options=options,
|
||||
grade_options=grade_options,
|
||||
source_snapshot={
|
||||
"filter": surface["source_filter"],
|
||||
"method": surface["method"],
|
||||
"smooth": bool(surface["smooth"]),
|
||||
},
|
||||
crs=crs,
|
||||
target=target,
|
||||
)
|
||||
)
|
||||
summary = {
|
||||
**ip.profile_summary(longitudinal),
|
||||
"with_profile": bool(request.with_profile),
|
||||
"seconds": round(time.perf_counter() - started, 2),
|
||||
}
|
||||
await asyncio.to_thread(ip.write_initial, project_root, key, mark, summary)
|
||||
logger.info(
|
||||
"추천 초기 종단 셈: project_id=%s %s 꼭짓점 %s 직선화 %s %.2fs",
|
||||
project_id,
|
||||
request.mode,
|
||||
summary.get("pvi_count"),
|
||||
summary.get("straightened"),
|
||||
summary["seconds"],
|
||||
)
|
||||
return summary
|
||||
except Exception as error: # noqa: BLE001 — 추천은 그대로 · 화면이 이유 한 줄
|
||||
logger.exception("추천 초기 종단 셈 실패: project_id=%s", project_id)
|
||||
return {"error": f"초기 종단을 셈하지 못했습니다: {error}"}
|
||||
@@ -345,6 +345,9 @@ export interface RouteNodeEdit {
|
||||
*
|
||||
* `edits`(430 · 노드 수와 같을 때만 서버가 줌)가 있으면 곡선 켬끔 · R · 고정 · 고정 길이는 **넣은 값**으로 —
|
||||
* 그린 R 로 열면 접선 자리에 눌린 R 이 넣은 값으로 굳고 R · 길이 고정이 [저장] 뒤 사라짐.
|
||||
*
|
||||
* 짝(edits 없음) = 파이썬 `B05_Profile_Engine_InitialProfile.draft_nodes`(추천 초기 종단 476) ·
|
||||
* 거울 `test_476_1_recommend_initial`.
|
||||
*/
|
||||
export function flattenServerPlan(
|
||||
nodes: ServerNode[],
|
||||
|
||||
Reference in New Issue
Block a user