- 규칙: 구조물 · 관 기준 측점 = 정수 m 사사오입(일반 측점 1 m 붙기 뺌) · 측점 심는 자리 TS 짝(plantedChainages ↔ resolve_extra_stations) · 같은 m 면 구조물 측점 하나(격자 자리 grid) · 떠나면 일반 측점(oneStationList ↔ _merge_irregular_into_longitudinal) - 서버: B05 [저장] · B06 저장 · [측점 만들기]가 목록 전체 다시 맞춤(빈 목록도 · 옛 글 · 횡단 파일 글) · 계획선 측점 줄 다시 셈 · 정본에 없는 횡단 행은 0.5 m 안 새 측점으로 옮기고 나머지 지움 · 옛 소수 측점 꼭짓점 · 편집은 정수 자리로 · 맞춤 실패는 저장을 안 막음 - 화면: 종단 그래프 · 3D · 표 · ▲▼ 한 목록(초안 반영) · C군 구간형 · 독립 기슭막이 시작 · 끝 측점 · B06 카드는 초안에 없는 옛 구조물 측점 숨김 · 고름은 같은 m 구조물 측점 먼저 · 폼 거리 칸 정수 표기 · C군 계산 구간 · 포장 나눔 경계 정수 - 옛 자료: [정수 맞춤] 단추 없앰 · 종단 보기 열 때 한 번 자동 정수 · 알림 한 줄 · [저장]하면 남음 - 시험: test_272_1 · test_272_2 새로 · 234_1 · 238_1 · b05_extra_stations_supplier · b06_patch_station · b05_station_roundtrip · b05_b06_save_roundtrip 맞춤 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LLCk2y5xE8YGVgjbTntWsY
70 lines
2.9 KiB
Python
70 lines
2.9 KiB
Python
"""구조물 · 관 기준 측점 = 정수 m(반올림 · .5 는 올림) · 노선 끝 안쪽(요구 167 · 272).
|
|
|
|
측점 값(측점 + 거리 · 누가거리)에 소수를 안 씀 — 일반 측점(격자)과 같은 m 면 서버 측점
|
|
만들기가 한 측점으로 합침(구조물 측점이 위 · `B05_Profile_Engine_Sections_Core`).
|
|
234-1 의 「일반 측점 1 m 안 붙기」는 뺌(그냥 정수 · 사용자 167).
|
|
TS 짝 = `common_util/common_util_structure_station.ts`
|
|
(화면 입력 · 끌기 · 방향키 · 옛 자료 정수 옮김).
|
|
거울 시험 = `resources/tester/test_234_1_structure_station.py`.
|
|
일반 측점 = 격자(간격) · 시종점 — 끝(노선 길이)을 넘지 않게 자르는 데만 씀.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import math
|
|
from collections.abc import Sequence
|
|
from dataclasses import replace
|
|
from typing import TypeVar
|
|
|
|
from common_util.common_util_route_geometry import RouteVertex, interpolate_vertex
|
|
from config.config_system_design import SECTION_STATION_INTERVAL_M
|
|
|
|
_Candidate = TypeVar("_Candidate")
|
|
|
|
_EPS = 1e-6
|
|
|
|
|
|
def general_stations(total_m: float, interval_m: float) -> list[float]:
|
|
"""격자 측점 + 끝 측점(`Sections_Core._chainages` 와 같은 줄)."""
|
|
if not (total_m > 0 and interval_m > 0):
|
|
return [0.0]
|
|
values = [index * interval_m for index in range(int(total_m // interval_m) + 1)]
|
|
if total_m - values[-1] > _EPS:
|
|
values.append(float(total_m))
|
|
return values
|
|
|
|
|
|
def snap_structure_station(chainage_m: float, stations: Sequence[float]) -> float:
|
|
"""기준 측점 = 정수 m(.5 는 올림) · 0 ~ 노선 끝(소수 끝은 그 아래 정수) 안 · 멱등."""
|
|
value = float(chainage_m)
|
|
if not math.isfinite(value):
|
|
return value
|
|
end = max(stations) if stations else math.inf
|
|
whole = float(math.floor(value + 0.5))
|
|
return max(0.0, min(whole, float(math.floor(end + _EPS))))
|
|
|
|
|
|
def route_general_stations(total_m: float) -> list[float]:
|
|
"""노선 길이의 일반 측점 — 서버 측점 간격(`SECTION_STATION_INTERVAL_M`)."""
|
|
return general_stations(total_m, SECTION_STATION_INTERVAL_M)
|
|
|
|
|
|
def snap_candidates(
|
|
candidates: Sequence[_Candidate], vertices: Sequence[RouteVertex]
|
|
) -> list[_Candidate]:
|
|
"""자동 배치 관 자리 맞춤 — 좌표는 맞춘 자리로 다시 찍고, 같은 자리로 모이면 앞선 것만.
|
|
|
|
`candidates` 는 `chainage_m · x · y` 를 가진 dataclass(`StructureCandidate`)."""
|
|
total_m = float(vertices[-1].chainage_m)
|
|
stations = route_general_stations(total_m)
|
|
snapped: list[_Candidate] = []
|
|
taken: set[float] = set()
|
|
for candidate in candidates:
|
|
at = snap_structure_station(candidate.chainage_m, stations)
|
|
if at in taken:
|
|
continue
|
|
taken.add(at)
|
|
x, y, _ = interpolate_vertex(list(vertices), at)
|
|
snapped.append(replace(candidate, chainage_m=at, x=x, y=y))
|
|
return snapped
|