Files
Aislo/resources/tester/helper_455_arrow_auto_radius.cjs
T
eomsangdonandClaude Sonnet 5.5 8a3a145072 test(508-1b 옛 헬퍼 공용 불러오기 5/7): 헬퍼 28 곳 loadTs 베낌 걷고 makeLoader 로
- 헬퍼 동작 그대로(풀이 함수 본문은 옮겨 담음) · 제품 코드 안 고침
- 확인: 이 묶음 헬퍼를 쓰는 시험 233 개 전 233 통과 → 후 233 통과 (시험별 junit 대조 · 어긋남 0)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 17:12:59 +09:00

64 lines
2.1 KiB
JavaScript

/* 455 (433-13 ①) 종단 ▲▼ 자동 R — `B05_Profile_UI_Profile_Alignment.ts` adjustStation 을 Node 로 돌림.
* ① 누른 꼭짓점 R = 저장 자동 R → 지움 · 곡선 L = 기본 L ② 사용자 R(저장분과 다름) → 그대로
* ③ 자동 R 기준을 안 넘기면(옛 부름) → 그대로. 표준출력 = JSON.
*/
const fs = require("fs");
const path = require("path");
const { makeLoader } = require("./helper_ts_stub_loader.cjs");
const ROOT = path.join(__dirname, "..", "..");
const { loadTs } = makeLoader({
root: ROOT,
});
const align = loadTs(
path.join(ROOT, "B05_Profile", "logic", "B05_Profile_UI_Profile_Alignment.ts"),
);
// 20m 측점 · 100m 에 꺾임 하나(대수차 0.5 %)
const stations = Array.from({ length: 11 }, (_, i) => i * 20);
const ground = stations.map((s) => 100 + 0.02 * s + (s > 100 ? 0.005 * (s - 100) : 0));
const base = {
policy: {
station_interval_m: 20,
curve_radius_ratio: 1,
curve_tangent_max_ratio: 0.5,
curve_skip_legal_exception: false,
default_curve_length_m: 15,
default_curve_radius_m: 300,
balance_tolerance_percent: 10,
edit_step_m: 0.1,
grade_violation_policy: "warn",
max_grade_pct: 14,
curve_skip_delta_pct: 0,
paved: true,
},
onlyExplicitCurves: false,
basePvi: stations.map((s, i) => ({ chainage_m: s, elevation_m: ground[i] })),
chainage: stations,
ground,
stations: stations.map((s) => ({ station_id: `S${s}`, chainage_m: s })),
};
const KEY = "100.000";
const AUTO = 15 / 0.005; // 관 정착이 역산한 꼴(R = L / A)
function press(radius, autoRadii) {
const edits = { station_offsets: {}, curve_radii: { [KEY]: radius } };
const next =
autoRadii === undefined
? align.adjustStation(base, edits, 100, 0.1)
: align.adjustStation(base, edits, 100, 0.1, autoRadii);
const curve = align
.buildAlignment(base, next)
.curves.find((c) => Math.abs(c.chainage_m - 100) < 1e-6);
return { radius: next.curve_radii[KEY] ?? null, length: curve ? curve.l_m : null };
}
process.stdout.write(
JSON.stringify({
auto: press(AUTO, { [KEY]: AUTO }),
user: press(777, { [KEY]: AUTO }),
legacy: press(AUTO),
}),
);