From 2aaad7fe32e9e38f0cf87dad13afa69bc5c5eefc Mon Sep 17 00:00:00 2001 From: umsangdon Date: Fri, 30 Oct 2026 14:37:39 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat(D=20=EC=98=88=EC=A0=95=EB=85=B8?= =?UTF-8?q?=EC=84=A0):=20=EB=8B=A8=EA=B3=84=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=E3=80=8C=EB=85=B8=EC=84=A0=20=EB=B6=84=EC=84=9D=E3=80=8D=20?= =?UTF-8?q?=E2=86=92=20=E3=80=8C=EC=98=88=EC=A0=95=EB=85=B8=EC=84=A0?= =?UTF-8?q?=E3=80=8D=20=E2=80=94=20=EC=82=AC=EC=A0=84=20=C2=B7=20=EB=8C=80?= =?UTF-8?q?=EC=8B=9C=EB=B3=B4=EB=93=9C=20=EB=8B=A8=EA=B3=84=20=C2=B7=20?= =?UTF-8?q?=EB=8B=A8=EC=B6=95=ED=82=A4=20=ED=91=9C=20(PLAN=20596-1=20?= =?UTF-8?q?=C2=B7=20=EC=9A=94=EA=B5=AC=20463)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 폴더 · 주소 · 열쇠 그대로 · 시험 547_1 단언 새 이름 Co-Authored-By: Claude Opus 5.5 --- A00_Common/key_registry.ts | 2 +- B01_Dashboard/B01_Dashboard_Summary.py | 2 +- resources/tester/test_547_1_project_summary.py | 4 ++-- ui_template/ui_template_locale_de.ts | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/A00_Common/key_registry.ts b/A00_Common/key_registry.ts index e9e624aa5..a42902472 100644 --- a/A00_Common/key_registry.ts +++ b/A00_Common/key_registry.ts @@ -47,7 +47,7 @@ export const KEY_SCOPES: Record = { routeEdit: { label: ["B05 노선 편집(평면)", "B05 route edit (plan)"], page: "b05" }, drainage: { label: ["B05 배수 · 3D", "B05 drainage · 3D"], page: "b05" }, section: { label: ["B06 횡단", "B06 cross section"], page: "b05" }, - plan: { label: ["D03 노선분석", "D03 route analysis"], page: "plan" }, + plan: { label: ["D03 예정노선", "D03 planned route"], page: "plan" }, b04: { label: ["B04 지도 · 3D", "B04 map · 3D"], page: "b04" }, cad: { label: ["CAD", "CAD"], page: "cad" }, b08: { label: ["B08 수량 · 이정표", "B08 quantity · milestones"], page: "b08" }, diff --git a/B01_Dashboard/B01_Dashboard_Summary.py b/B01_Dashboard/B01_Dashboard_Summary.py index e2a0b2089..2306927f4 100644 --- a/B01_Dashboard/B01_Dashboard_Summary.py +++ b/B01_Dashboard/B01_Dashboard_Summary.py @@ -25,7 +25,7 @@ THUMB_POINTS = 100 # 단계 이름 = 화면 단계 막대 글(ui_template_locale_common · _de) 한국어 · 모르는 종류 = 임도 STAGE_NAMES: dict[str, tuple[str, ...]] = { "ROAD": ("파일입력", "전처리", "노선설계", "횡단설계", "상세설계", "수량산출", "원가계산"), - "PLAN": ("노선 분석", "확정 · 내보내기"), + "PLAN": ("예정노선", "확정 · 내보내기"), "STABILITY": ("지반 조건", "2D 해석", "3D 해석", "암반 해석", "광역 위험", "보고서"), } diff --git a/resources/tester/test_547_1_project_summary.py b/resources/tester/test_547_1_project_summary.py index 05a7b296d..28c8acf69 100644 --- a/resources/tester/test_547_1_project_summary.py +++ b/resources/tester/test_547_1_project_summary.py @@ -22,7 +22,7 @@ def test_thumb_line_fits_unit_box_and_caps_points(): def test_stage_names_follow_step_bar(): assert len(summary.stage_names("ROAD")) == 7 - assert summary.stage_names("PLAN")[0] == "노선 분석" # 591-2 기준 지정 걷음 + assert summary.stage_names("PLAN")[0] == "예정노선" # 591-2 기준 지정 걷음 assert summary.stage_names("EROSION") == summary.stage_names("ROAD") @@ -122,7 +122,7 @@ def test_summaries_in_batch(monkeypatch, tmp_path): assert a["stale_days"] == 20 and a["owner_names"] == ["엄", "박"] assert a["metrics"] == {"length_m": 15.0, "stations": 3, "structures": 2} assert len(a["thumb"]) == 3 and a["done"] is False - assert b["thumb"] is None and b["metrics"] == {} and b["stage_name"] == "노선 분석" + assert b["thumb"] is None and b["metrics"] == {} and b["stage_name"] == "예정노선" assert db["queries"] == 5 diff --git a/ui_template/ui_template_locale_de.ts b/ui_template/ui_template_locale_de.ts index b23b12a3c..d9f51ecfe 100644 --- a/ui_template/ui_template_locale_de.ts +++ b/ui_template/ui_template_locale_de.ts @@ -10,7 +10,7 @@ import type { LocaleEntry } from "./ui_template_locale_common"; export const ui_locales_de = { /* --- 단계 막대 · 빈 단계 --- */ - DE_Step_PlanAnalysis: ["노선 분석", "Route Analysis"], + DE_Step_PlanAnalysis: ["예정노선", "Planned Route"], DE_Step_PlanConfirm: ["확정 · 내보내기", "Confirm · Export"], DE_Step_StabGround: ["지반 조건", "Ground"], DE_Step_StabSection: ["2D 해석", "2D Analysis"], @@ -28,7 +28,7 @@ export const ui_locales_de = { D04_Col_Chainage: ["측점", "Station"], D04_Col_Confirmed: ["확정", "Confirmed"], D04_Col_Assignees: ["지정 업체", "Assigned firms"], - D04_NotSaved: ["노선 분석 [저장] 전", "Route not saved"], + D04_NotSaved: ["예정노선 [저장] 전", "Route not saved"], D04_Company: ["업체(등록 회사 찾기 또는 이름)", "Firm (search or name)"], D04_Email: ["메일", "Email"], D04_Add: ["추가", "Add"], @@ -90,8 +90,8 @@ export const ui_locales_de = { DE_Reg_KindPlan: ["노선 계획", "Route plan"], DE_Reg_Site: ["기준점", "Reference point"], DE_Reg_SiteHint: [ - "지도를 눌러 기준점 하나를 찍습니다 — 노선분석이 처음 자료를 받는 기준(노선과 무관) · 표지를 끌어 옮깁니다.", - "Click the map to set one reference point — where route analysis first loads data (not part of the route). Drag the marker to move it.", + "지도를 눌러 기준점 하나를 찍습니다 — 예정노선 화면이 처음 자료를 받는 기준(노선과 무관) · 표지를 끌어 옮깁니다.", + "Click the map to set one reference point — where the planned route page first loads data (not part of the route). Drag the marker to move it.", ], DE_Reg_SiteEmpty: [ "주소 — 지도를 눌러 기준점을 찍으세요.", From 18fcb059ae2ef9a07783024aa356721ae17c72b2 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Fri, 30 Oct 2026 14:37:49 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat(D=20=EC=98=88=EC=A0=95=EB=85=B8?= =?UTF-8?q?=EC=84=A0):=20=EC=98=88=EC=83=81=20=ED=9A=A1=EB=8B=A8=20?= =?UTF-8?q?=EB=90=98=EC=82=B4=EB=A6=BC=20=C2=B7=20=EB=85=B8=EC=84=A0?= =?UTF-8?q?=EB=A7=9D=203D=20=EC=84=A0=EB=A7=88=EB=8B=A4=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=20=C2=B7=20=EA=B0=88=EB=9E=98=20=EB=A8=B8=EB=A6=AC=20?= =?UTF-8?q?=EC=9E=98=EB=9D=BC=20=EB=83=84=20(PLAN=20601-1=20=C2=B7=20?= =?UTF-8?q?=EC=9A=94=EA=B5=AC=20463-21)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - logic/D03_PlanAnalysis_Expect.ts 되살림(cdcdd5f59^) — 리핑암 · 산쪽 절토 · 일반 측구 · 계획고 = 지반고 - expectLine · branchTrimM 덧 — 갈래 머리 = 차도 반 + 노견(2.0 m) 잘라 냄 · 측점 = 원래 누가 - test_544_1 되살림 + 노선망 선 시험 하나 Co-Authored-By: Claude Opus 5.5 --- .../logic/D03_PlanAnalysis_Expect.ts | 162 +++++++++++++ resources/tester/test_544_1_plan_expect.py | 212 ++++++++++++++++++ 2 files changed, 374 insertions(+) create mode 100644 D03_PlanAnalysis/logic/D03_PlanAnalysis_Expect.ts create mode 100644 resources/tester/test_544_1_plan_expect.py diff --git a/D03_PlanAnalysis/logic/D03_PlanAnalysis_Expect.ts b/D03_PlanAnalysis/logic/D03_PlanAnalysis_Expect.ts new file mode 100644 index 000000000..d4c7cd419 --- /dev/null +++ b/D03_PlanAnalysis/logic/D03_PlanAnalysis_Expect.ts @@ -0,0 +1,162 @@ +/* ============================================================================= + * D03_PlanAnalysis_Expect.ts + * D03 예상 횡단(PLAN 544-1 · 601-1 · 요구 363-1 · 463-21) — 측점 지반 → 표준 횡단 기본값 설계선 · 절 · 성토 ㎡. + * 셈 = 공용 `computeCrossDesign`(① 짝 `compute_cross_design` · 거울 `test_b06_cross_design_mirror.py`) + * · 기본 = B 초기 설계와 같음(리핑암 · 산쪽 절토 · 일반 측구 · 암 경계 = 서버 기본) · 계획고 = 측점 중심 지반고 + * · 미교차 = `extendUnclosed`(격자 있을 때) · 곡선 확폭 없음 · 보기만(저장 없음). + * 3D = 같은 단면을 B05 `buildCorridor` 가 읽는 측점 꼴로(`expectSections`) · 노선망 전체 = 선마다(`expectLine`) · + * 갈래 머리 = 부모 노면(차도 반 + 노견)만큼 잘라 냄(두 노면 겹침 막음). + * 시험 `resources/tester/test_544_1_plan_expect.py`. + * ========================================================================== */ + +import { + computeCrossDesign, + type CrossDesignOptions, + type CrossDesignResult, + type StandardCrossSectionSpec, +} from "../../common_util/common_util_cross_design"; +import type { DtmGrid } from "../../common_util/common_util_surface_sampler"; +import { + extendUnclosed, + type CrossGroundPoint, + type StationGround, +} from "../../B05_Profile/logic/B05_Profile_Sections_Ground"; +import { lineLength, sliceLine, stationChainages, type Vertex } from "./D03_PlanAnalysis_Draw"; + +/** 서버 `sections/context` 의 표준 횡단(config) · 암 경계 기본 오프셋. */ +export interface ExpectStandard { + standard: StandardCrossSectionSpec; + rockBoundaryM: number | null; +} + +export interface ExpectCross { + design: CrossDesignResult; + /** 설계에 쓴 지반 표본(미교차로 넓혔으면 넓힌 것). */ + samples: CrossGroundPoint[]; +} + +/** B 초기 설계 기본 — 리핑암 · 산쪽 절토(모르면 좌) · 일반 측구. */ +export function expectOptions( + uphill: "left" | "right" | null, + std: ExpectStandard, +): CrossDesignOptions { + return { + groundType: "ripping_rock", + sectionMode: `${uphill ?? "left"}_cut`, + ditchType: "standard", + standard: std.standard, + rockBoundaryOffsetM: std.rockBoundaryM, + }; +} + +/** 측점 하나 예상 단면 — 지반고 · 표본이 없으면 null. */ +export function expectCross( + station: StationGround, + std: ExpectStandard, + grid?: DtmGrid | null, +): ExpectCross | null { + const elevation = station.center_z; + if (elevation === null) return null; + const options = expectOptions(station.uphill_side, std); + try { + let samples = station.samples; + let design = computeCrossDesign(samples, elevation, options); + const wide = + design.slope_unclosed && grid + ? extendUnclosed( + samples, + [station.center_x, station.center_y], + station.left_xy, + (next) => computeCrossDesign(next, elevation, options), + grid, + ) + : null; + if (wide) { + samples = wide.samples as CrossGroundPoint[]; + design = computeCrossDesign(samples, elevation, options); + } + return { design, samples }; + } catch { + return null; // 표본 부족 — B 와 같은 태도(그 측점 건너뜀) + } +} + +/** B06 `CrossSection` 중 `buildCorridor` 가 읽는 칸(B06 형 파일은 별칭 import 라 여기 안 끌어옴). */ +export interface ExpectSection { + station_id: string; + chainage_m: number; + label: string; + kind: "regular"; + center_z: number | null; + azimuth_deg: null; + center_x: number; + center_y: number; + uphill_side: "left" | "right" | null; + frame: { left_xy: [number, number] }; + samples: CrossGroundPoint[]; + design: CrossDesignResult; +} + +/** 3D 코리도 입력 — 측점마다 예상 단면(못 세운 측점 뺌) · 누가 = 연도 노선 위 누가. */ +export function expectSections( + stations: StationGround[], + std: ExpectStandard, + grid?: DtmGrid | null, +): ExpectSection[] { + return stations.flatMap((station) => { + const cross = expectCross(station, std, grid); + if (!cross) return []; + return [ + { + station_id: String(station.chainage_m), + chainage_m: station.chainage_m, + label: "", + kind: "regular", + center_z: station.center_z, + azimuth_deg: null, + center_x: station.center_x, + center_y: station.center_y, + uphill_side: station.uphill_side, + frame: { left_xy: station.left_xy }, + samples: cross.samples, + design: cross.design, + }, + ]; + }); +} + +/** 갈래 머리 잘라 낼 길이(m) — 리핑암 표준 차도 반 + 넓은 노견(부모 노면 안). */ +export function branchTrimM(std: ExpectStandard): number { + const rock = std.standard.rock; + if (!rock) return 0; + return ( + (rock.road_width_m ?? 0) / 2 + Math.max(rock.shoulder_left_m ?? 0, rock.shoulder_right_m ?? 0) + ); +} + +/** 3D 한 선 — 그릴 꺾은선 · 그 위 측점(꺾은선 첫 점 = 0) · 원래 누가 = 측점 + `offsetM`. */ +export interface ExpectLine { + line: Vertex[]; + offsetM: number; + stations: number[]; +} + +/** 선 하나 3D 입력 — 측점 = 원래 누가(`intervalM`) · `trimM` > 0(갈래)이면 머리를 잘라 낸 자리부터. + * 남는 길이가 1 m 안 되면 null. */ +export function expectLine( + vertices: ReadonlyArray, + trimM: number, + intervalM: number, +): ExpectLine | null { + const length = lineLength(vertices); + const offsetM = Math.max(0, trimM); + if (vertices.length < 2 || length - offsetM < 1) return null; + const line = offsetM > 0 ? sliceLine(vertices, offsetM, length) : [...vertices]; + const stations = [ + 0, + ...stationChainages(length, intervalM) + .filter((m) => m > offsetM + 1e-6) + .map((m) => m - offsetM), + ]; + return { line, offsetM, stations }; +} diff --git a/resources/tester/test_544_1_plan_expect.py b/resources/tester/test_544_1_plan_expect.py new file mode 100644 index 000000000..425003f08 --- /dev/null +++ b/resources/tester/test_544_1_plan_expect.py @@ -0,0 +1,212 @@ +"""D03 예상 횡단(PLAN 544-1 · 601-1) — TS `logic/D03_PlanAnalysis_Expect.ts` 값 = 파이썬 `compute_cross_design`. + +기본 = 리핑암 · 산쪽 절토(모르면 좌) · 일반 측구 · 암 경계 = config 기본 · 계획고 = 측점 중심 지반고. +미교차 = 격자로 넓힌 표본 · 넓힌 표본으로 파이썬이 다시 셈한 값과 같음 · 코리도 측점 꼴. +노선망 3D(601) = 선마다 측점 · 갈래 머리 = 리핑암 차도 반 + 노견만큼 잘라 냄. + +./venv/Scripts/python.exe -m pytest resources/tester/test_544_1_plan_expect.py -q +""" + +from __future__ import annotations + +import json +import re +import subprocess +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[2] +if str(ROOT) not in sys.path: + sys.path.insert(0, str(ROOT)) + +from B06_Section.B06_Section_Engine_Design import compute_cross_design # noqa: E402 +from config.config_system_design import ( # noqa: E402 + STANDARD_CROSS_SECTION, + STANDARD_ROCK_BOUNDARY_DEFAULT_OFFSET_M, +) + +TS_FILE = ROOT / "D03_PlanAnalysis" / "logic" / "D03_PlanAnalysis_Expect.ts" +TSC = ROOT / "config" / "node_modules" / "typescript" / "bin" / "tsc" + +_RUNNER = """ +import { readFileSync, writeFileSync } from "node:fs"; +import * as expect from "./D03_PlanAnalysis/logic/D03_PlanAnalysis_Expect.js"; +const job = JSON.parse(readFileSync(process.argv[2], "utf8")); +const std = { standard: job.standard, rockBoundaryM: job.rock }; +// 평면 격자 — z = 100 + slope * y(좌 축 = +y) · 1 m · ±100 m +const n = 201; +const axis = Float64Array.from({ length: n }, (_, i) => i - 100); +const z = new Float64Array(n * n); +for (let iy = 0; iy < n; iy += 1) + for (let ix = 0; ix < n; ix += 1) z[iy * n + ix] = 100 + job.wideSlope * axis[iy]; +const grid = { x: axis, y: axis, z, validBits: new Uint8Array(Math.ceil((n * n) / 8)).fill(255) }; +const cross = job.stations.map((s) => expect.expectCross(s, std)); +const wide = expect.expectCross(job.wide, std, grid); +const sections = expect.expectSections([...job.stations, job.wide], std, grid); +const trim = expect.branchTrimM(std); +const lines = [ + expect.expectLine([[0, 0], [50, 0]], 0, 20), + expect.expectLine([[0, 0], [30, 0], [30, 20]], trim, 20), + expect.expectLine([[0, 0], [1.5, 0]], trim, 20), +]; +writeFileSync(process.argv[3], JSON.stringify({ cross, wide, sections, trim, lines })); +""" + + +def _station(slope: float, uphill: str | None, *, half: float = 20.0) -> dict: + samples = [] + count = int(half * 2 / 0.5) + 1 + for i in range(count): + offset = -half + i * 0.5 + z = round(100.0 + slope * offset, 6) + samples.append( + {"offset_m": offset, "x": 0.0, "y": offset, "z": z, "elevation_m": z, "valid": True} + ) + return { + "chainage_m": 40.0, + "center_x": 0.0, + "center_y": 0.0, + "center_z": 100.0, + "tangent_xy": [1.0, 0.0], + "left_xy": [0.0, 1.0], + "uphill_side": uphill, + "samples": samples, + } + + +_STATIONS = [ + _station(0.30, "left"), + _station(-0.45, "right"), + _station(0.05, None), + {**_station(0.2, "left"), "center_z": None}, +] +_WIDE_SLOPE = 0.8 + + +def _run_ts(tmp_path: Path) -> dict: + out = tmp_path / "js" + subprocess.run( # noqa: S603 — 고정 실행 파일 + [ + "node", + str(TSC), + str(TS_FILE), + "--outDir", + str(out), + "--rootDir", + str(ROOT), + "--module", + "esnext", + "--target", + "es2022", + "--moduleResolution", + "bundler", + "--ignoreConfig", + ], + cwd=str(ROOT), + check=True, + capture_output=True, + ) + for emitted in out.rglob("*.js"): + emitted.write_text( + re.sub(r'(from\s+"\.\.?/[^"]+)"', r'\1.js"', emitted.read_text(encoding="utf-8")), + encoding="utf-8", + ) + (out / "runner.mjs").write_text(_RUNNER, encoding="utf-8") + job = tmp_path / "job.json" + result = tmp_path / "out.json" + job.write_text( + json.dumps( + { + "standard": STANDARD_CROSS_SECTION, + "rock": STANDARD_ROCK_BOUNDARY_DEFAULT_OFFSET_M, + "stations": _STATIONS, + "wide": _station(_WIDE_SLOPE, "left"), + "wideSlope": _WIDE_SLOPE, + } + ), + encoding="utf-8", + ) + subprocess.run( # noqa: S603 + ["node", str(out / "runner.mjs"), str(job), str(result)], + cwd=str(ROOT), + check=True, + capture_output=True, + ) + return json.loads(result.read_text(encoding="utf-8")) + + +def _python(samples: list[dict], elevation: float, uphill: str | None) -> dict: + return compute_cross_design( + samples, + elevation, + ground_type="ripping_rock", + section_mode=f"{uphill or 'left'}_cut", + ditch_type="standard", + standard=STANDARD_CROSS_SECTION, + rock_boundary_offset_m=STANDARD_ROCK_BOUNDARY_DEFAULT_OFFSET_M, + ) + + +def _same(ts: dict, py: dict) -> None: + assert ts["section_mode"] == py["section_mode"] + assert ts["ground_type"] == "ripping_rock" and ts["ditch_type"] == "standard" + assert abs(ts["cut_area_m2"] - py["cut_area_m2"]) < 1e-9 + assert abs(ts["fill_area_m2"] - py["fill_area_m2"]) < 1e-9 + assert len(ts["design_line"]) == len(py["design_line"]) + for a, b in zip(ts["design_line"], py["design_line"]): + assert abs(a["offset_m"] - b["offset_m"]) < 1e-9 + assert abs(a["elevation_m"] - b["elevation_m"]) < 1e-9 + + +def test_expect_matches_python(tmp_path: Path) -> None: + got = _run_ts(tmp_path) + for station, ts in zip(_STATIONS, got["cross"]): + if station["center_z"] is None: + assert ts is None # 지반고 없음 = 못 세움 + continue + py = _python(station["samples"], station["center_z"], station["uphill_side"]) + _same(ts["design"], py) + assert ts["design"]["design_elevation_m"] == station["center_z"] + # 산쪽 절토 · 모르면 좌 + assert [c and c["design"]["section_mode"] for c in got["cross"]] == [ + "left_cut", + "right_cut", + "left_cut", + None, + ] + # 비탈 표본 — 절토 · 성토 둘 다 섬 + assert got["cross"][0]["design"]["cut_area_m2"] > 0 + assert got["cross"][0]["design"]["fill_area_m2"] > 0 + + +def test_unclosed_extends_and_sections(tmp_path: Path) -> None: + got = _run_ts(tmp_path) + wide = got["wide"] + narrow = _python(_station(_WIDE_SLOPE, "left")["samples"], 100.0, "left") + assert narrow["slope_unclosed"] is True # ±20 m 안에선 안 닫힘 + assert wide["design"]["slope_unclosed"] is False + assert min(s["offset_m"] for s in wide["samples"]) < -20.0 + _same(wide["design"], _python(wide["samples"], 100.0, "left")) + # 코리도 측점 = 세운 측점만(지반고 없는 측점 뺌) · 좌 축 · 설계 실음 + sections = got["sections"] + assert len(sections) == 4 + assert all(s["frame"]["left_xy"] == [0.0, 1.0] and s["design"]["design_line"] for s in sections) + assert sections[-1]["samples"] == wide["samples"] + + +def test_network_lines_trim_branch_head(tmp_path: Path) -> None: + got = _run_ts(tmp_path) + rock = STANDARD_CROSS_SECTION["rock"] + trim = rock["road_width_m"] / 2 + max(rock["shoulder_left_m"], rock["shoulder_right_m"]) + assert abs(got["trim"] - trim) < 1e-12 # 3.0 / 2 + 0.5 = 2.0 + main, branch, short = got["lines"] + # 본선 — 그대로 · 측점 0 · 20 · 40 · 끝 50 + assert main["offsetM"] == 0 and main["line"] == [[0, 0], [50, 0]] + assert main["stations"] == [0, 20, 40, 50] + # 갈래 — 머리 2 m 잘라 냄 · 원래 누가 20 · 40 · 50 → 18 · 38 · 48 · 꺾임점 남음 + assert branch["offsetM"] == trim + assert branch["line"][0] == [trim, 0] and branch["line"][-1] == [30, 20] + assert [30, 0] in branch["line"] + assert [round(m + trim, 9) for m in branch["stations"]] == [trim, 20, 40, 50] + # 남는 길이 1 m 안 됨 = 못 그림 + assert short is None From 26c5c0343dd53fa5da8e62740dafc182aab5d7f4 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Fri, 30 Oct 2026 14:37:54 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat(D=20=EC=98=88=EC=A0=95=EB=85=B8?= =?UTF-8?q?=EC=84=A0):=20=EC=A7=80=EB=8F=84=20=EC=A0=84=EC=9A=A9=20?= =?UTF-8?q?=EA=B7=B8=EB=A6=BC=20=EC=83=89=20=C2=B7=20=EC=84=A0=EB=A7=88?= =?UTF-8?q?=EB=8B=A4=20=EC=B0=A8=EB=A1=80=20=EC=83=89=20=C2=B7=20=EA=B2=80?= =?UTF-8?q?=EC=9D=80=20=ED=85=8C=20(PLAN=20600-1=20=C2=B7=20=EC=9A=94?= =?UTF-8?q?=EA=B5=AC=20463-24)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 새 값 --draw-map-sketch · measure · warn · route-0~4 (테마 안 따름) · routeColor(index) 차례 색 함수 - planColors 가 지도 전용 색 + casing · 미리보기 · 거리재기 · 마커 · 핀 · 지점 검은 테 (strokeCased) - 시험 551_2 에 지도 전용 색 대비(어두운 바탕 · 검은 테 ≥ 3 : 1) 덧 Co-Authored-By: Claude Sonnet 5.5 --- .../D03_PlanAnalysis_UI_DrawPaint.ts | 51 ++++++++++++++----- D03_PlanAnalysis/D03_PlanAnalysis_UI_Map.ts | 23 ++++++--- .../D03_PlanAnalysis_UI_Measure.ts | 31 +++++------ resources/tester/test_551_2_draw_tokens.py | 24 ++++++++- ui_template/ui_template_palette.ts | 13 +++++ ui_template/ui_template_theme.css | 8 +++ 6 files changed, 112 insertions(+), 38 deletions(-) diff --git a/D03_PlanAnalysis/D03_PlanAnalysis_UI_DrawPaint.ts b/D03_PlanAnalysis/D03_PlanAnalysis_UI_DrawPaint.ts index a5ef6888a..0e81c63f5 100644 --- a/D03_PlanAnalysis/D03_PlanAnalysis_UI_DrawPaint.ts +++ b/D03_PlanAnalysis/D03_PlanAnalysis_UI_DrawPaint.ts @@ -33,6 +33,32 @@ export const LINE_HIT_PX = 8; /** 구간 길이 라벨을 보일 화면 길이(px). */ const LABEL_MIN_PX = 70; +/** 지도 위 그림 검은 테(600-1) — 지금 길을 검은 선 → 색 선 두 번 긋고 점선 무늬를 되돌림 · 길은 부르는 쪽이 먼저 만듦. */ +export function strokeCased( + context: CanvasRenderingContext2D, + color: string, + width: number, + dash: number[] = [], +): void { + context.setLineDash(dash); + context.lineWidth = width + 3; + context.strokeStyle = planColors().casing; + context.stroke(); + context.lineWidth = width; + context.strokeStyle = color; + context.stroke(); + context.setLineDash([]); +} + +/** 지도 위 점 — 색 채움 + 검은 테. */ +function fillCased(context: CanvasRenderingContext2D, color: string): void { + context.fillStyle = color; + context.fill(); + context.lineWidth = 1.5; + context.strokeStyle = planColors().casing; + context.stroke(); +} + export const fmt = (value: number): string => value.toFixed(1); const signed = (value: number): string => `${value >= 0 ? "+" : ""}${value.toFixed(1)}`; /** 기울기 % → 각(°) — 가상 종단 기울기를 두 단위로. */ @@ -151,6 +177,9 @@ export function pointLayer(points: () => Vertex[]): PlanMapLayer { context.closePath(); context.fillStyle = pointColor(i); context.fill(); + context.lineWidth = 5; + context.strokeStyle = planColors().casing; + context.stroke(); context.lineWidth = 2; context.strokeStyle = "#ffffff"; context.stroke(); @@ -218,6 +247,9 @@ export function paintMark( context.closePath(); context.fillStyle = hollow ? "#ffffff" : color; context.fill(); + context.lineWidth = hollow ? 5.5 : 4.5; + context.strokeStyle = planColors().casing; + context.stroke(); context.lineWidth = hollow ? 2.5 : 1.5; context.strokeStyle = hollow ? color : "#ffffff"; context.stroke(); @@ -235,31 +267,24 @@ export function paintPreview( const [ax, ay] = map.toScreen(from); const [bx, by] = map.toScreen(preview.point); if (compass) { - context.strokeStyle = colors.active; - context.lineWidth = 1; - context.setLineDash([3, 4]); context.beginPath(); context.arc(ax, ay, compass.lengthM * map.pxPerMeter, 0, Math.PI * 2); - context.stroke(); - context.fillStyle = colors.active; + strokeCased(context, colors.active, 1.5, [3, 4]); for (const c of compass.candidates) { const [cx, cy] = map.toScreen(c); context.beginPath(); - context.arc(cx, cy, 3, 0, Math.PI * 2); - context.fill(); + context.arc(cx, cy, 3.5, 0, Math.PI * 2); + fillCased(context, colors.active); } } - context.strokeStyle = preview.blocked ? colors.warn : colors.active; - context.lineWidth = 2; - context.setLineDash([6, 4]); + const color = preview.blocked ? colors.warn : colors.active; context.beginPath(); context.moveTo(ax, ay); context.lineTo(bx, by); - context.stroke(); - context.setLineDash([]); + strokeCased(context, color, 2.5, [6, 4]); context.beginPath(); context.arc(bx, by, 5, 0, Math.PI * 2); - context.stroke(); + strokeCased(context, color, 2.5); const value = `${fmt(preview.lengthM)} m · ` + (preview.slopePct === null ? "지형 밖" : slopeText(preview.slopePct)); diff --git a/D03_PlanAnalysis/D03_PlanAnalysis_UI_Map.ts b/D03_PlanAnalysis/D03_PlanAnalysis_UI_Map.ts index de02713cf..fc69c07cd 100644 --- a/D03_PlanAnalysis/D03_PlanAnalysis_UI_Map.ts +++ b/D03_PlanAnalysis/D03_PlanAnalysis_UI_Map.ts @@ -17,7 +17,7 @@ * ========================================================================== */ import { createMapTools, mapToolButton } from "@ui/ui_template_map_tools"; -import { themeColor } from "@ui/ui_template_palette"; +import { routeColor, themeColor } from "@ui/ui_template_palette"; import type { VWorldMeta } from "../B04_PreProcess/B04_PreProcess_Api_Fetch"; import { computeMapRect, @@ -26,7 +26,6 @@ import { createNormalizer, lonLatToScreen, normalizedToScreen, - routeLineColor, type ViewState, } from "../B04_PreProcess/B04_PreProcess_UI_MapRender"; import { bindRouteEditNavigation } from "../B05_Profile/B05_Profile_UI_RouteEdit_Input"; @@ -41,12 +40,22 @@ export const YEAR_MARK_DRAG = "application/x-aislo-year-mark"; /** 측점 간격(m) — B 규칙 측점과 같음. */ export const PLAN_STATION_INTERVAL_M = 20; -/** 겹 그림 색(그림 전용 값 `--draw-*` · 밝음 · 어두움 같음) — 선 · 그리는 중 · 경고 · 글 테두리. */ -export function planColors(): { line: string; active: string; warn: string; halo: string } { +/** 지도 위 그림 색(600-1) — 지도 전용 값 `--draw-map-*`(테마 안 따름 · 바탕 늘 어두움) + 검은 테 `casing`. + * `line` = 첫 선 색 · 선마다 차례 색 = `routeColor(index)`. */ +export function planColors(): { + line: string; + active: string; + warn: string; + measure: string; + casing: string; + halo: string; +} { return { - line: routeLineColor(), - active: themeColor("--draw-primary", "#6d28d9"), - warn: themeColor("--draw-danger", "#dc2626"), + line: routeColor(0), + active: themeColor("--draw-map-sketch", "#ffe94d"), + warn: themeColor("--draw-map-warn", "#ff5a4d"), + measure: themeColor("--draw-map-measure", "#ffffff"), + casing: "rgba(0, 0, 0, 0.85)", halo: "rgba(0, 0, 0, 0.65)", }; } diff --git a/D03_PlanAnalysis/D03_PlanAnalysis_UI_Measure.ts b/D03_PlanAnalysis/D03_PlanAnalysis_UI_Measure.ts index fb4dbe80a..0102c9d31 100644 --- a/D03_PlanAnalysis/D03_PlanAnalysis_UI_Measure.ts +++ b/D03_PlanAnalysis/D03_PlanAnalysis_UI_Measure.ts @@ -7,6 +7,7 @@ import { groundSlopePct, segmentLength } from "./logic/D03_PlanAnalysis_Draw"; import type { Vertex } from "./logic/D03_PlanAnalysis_Plan"; import { planColors, type PlanMapLayer, type ScreenMap } from "./D03_PlanAnalysis_UI_Map"; +import { strokeCased } from "./D03_PlanAnalysis_UI_DrawPaint"; export interface PlanMeasure { layer: PlanMapLayer; @@ -40,25 +41,23 @@ export function createPlanMeasure(heightAt: () => (x: number, y: number) => numb if (!from) return; const colors = planColors(); const [ax, ay] = map.toScreen(from); - context.lineWidth = 2; - context.strokeStyle = colors.active; - context.fillStyle = colors.active; - context.setLineDash([6, 4]); + const dot = (x: number, y: number): void => { + context.beginPath(); + context.arc(x, y, 4.5, 0, Math.PI * 2); + context.fillStyle = colors.measure; + context.fill(); + context.lineWidth = 1.5; + context.strokeStyle = colors.casing; + context.stroke(); + }; if (to) { const [bx, by] = map.toScreen(to); context.beginPath(); context.moveTo(ax, ay); context.lineTo(bx, by); - context.stroke(); - context.setLineDash([]); - for (const [x, y] of [ - [ax, ay], - [bx, by], - ]) { - context.beginPath(); - context.arc(x, y, 4, 0, Math.PI * 2); - context.fill(); - } + strokeCased(context, colors.measure, 2.5, [6, 4]); + dot(ax, ay); + dot(bx, by); const { lengthM, slopePct, riseM } = measure(from, to); const text = `${fmt(lengthM)} m · ` + @@ -75,9 +74,7 @@ export function createPlanMeasure(heightAt: () => (x: number, y: number) => numb context.fillText(text, mx, my); }); } else { - context.beginPath(); - context.arc(ax, ay, 4, 0, Math.PI * 2); - context.fill(); + dot(ax, ay); } }, press(px, py, map, button) { diff --git a/resources/tester/test_551_2_draw_tokens.py b/resources/tester/test_551_2_draw_tokens.py index 321e7467d..04accf07d 100644 --- a/resources/tester/test_551_2_draw_tokens.py +++ b/resources/tester/test_551_2_draw_tokens.py @@ -34,7 +34,7 @@ DRAW_READS = [ ("B05_Profile/B05_Profile_UI_RouteEdit_Recommend_Map.ts", '"--draw-text-secondary"'), ("B05_Profile/B05_Profile_UI_Viewer.ts", '"--draw-surface-raised"'), ("B04_PreProcess/B04_PreProcess_UI_Camera.ts", '"--draw-surface-raised"'), - ("D03_PlanAnalysis/D03_PlanAnalysis_UI_Map.ts", '"--draw-primary"'), + ("D03_PlanAnalysis/D03_PlanAnalysis_UI_Map.ts", '"--draw-map-sketch"'), ("B04_PreProcess/B04_PreProcess_UI_MapOverlays.ts", '"--draw-warning"'), ("B04_PreProcess/B04_PreProcess_UI_MapOverlays.ts", '"--draw-canvas"'), ("B07_DesignDetail/openwebcad/src/App.css", "--cad-canvas: var(--draw-canvas);"), @@ -161,3 +161,25 @@ def test_changing_screen_tokens_keeps_drawing_colors(): a = resolve(value, before[mode]) assert "var(" not in a, (mode, rel, value) assert a == resolve(value, after[mode]), (mode, rel, value) + + +def _lum(hex_color: str) -> float: + rgb = [int(hex_color[i : i + 2], 16) / 255 for i in (1, 3, 5)] + lin = [c / 12.92 if c <= 0.03928 else ((c + 0.055) / 1.055) ** 2.4 for c in rgb] + return 0.2126 * lin[0] + 0.7152 * lin[1] + 0.0722 * lin[2] + + +def test_map_drawing_colors_fixed_and_readable_on_dark_map(): + """600-1 지도 위 그림 색 — 테마 안 따름(어두움 블록에 없음) · 어두운 바탕 `#1f2937` · 검은 테 둘 다 ≥ 3 : 1.""" + blocks = _blocks(THEME.read_text(encoding="utf-8")) + names = [ + k for k in blocks["light"] if re.fullmatch(r"--draw-map-(sketch|measure|warn|route-\d)", k) + ] + assert len(names) == 8, names + ground = _lum("#1f2937") + for name in names: + for mode in ("dark", "auto"): + assert name not in blocks[mode], (mode, name) + lum = _lum(blocks["light"][name]) + assert (lum + 0.05) / (ground + 0.05) >= 3, name + assert (lum + 0.05) / 0.05 >= 3, name diff --git a/ui_template/ui_template_palette.ts b/ui_template/ui_template_palette.ts index 93420d4dd..034218b25 100644 --- a/ui_template/ui_template_palette.ts +++ b/ui_template/ui_template_palette.ts @@ -50,3 +50,16 @@ export function pointColor(index: number): string { const [name, fallback] = POINT_COLORS[index % POINT_COLORS.length]; return themeColor(name, fallback); } + +/** 600-1 예정노선 선마다 차례 색 — 다섯 차례 돌림 · 지도 전용 값(테마 안 따름 · 겹 색과 가름) · 지도 선 · 구역 목록 색 띠가 같은 번호 같은 색 */ +const ROUTE_COLORS = [ + ["--draw-map-route-0", "#3df5c4"], + ["--draw-map-route-1", "#5aa9ff"], + ["--draw-map-route-2", "#c58bff"], + ["--draw-map-route-3", "#ff6ea8"], + ["--draw-map-route-4", "#9dff4d"], +] as const; +export function routeColor(index: number): string { + const [name, fallback] = ROUTE_COLORS[((index % 5) + 5) % 5]; + return themeColor(name, fallback); +} diff --git a/ui_template/ui_template_theme.css b/ui_template/ui_template_theme.css index ebc6038fa..f5a61f805 100644 --- a/ui_template/ui_template_theme.css +++ b/ui_template/ui_template_theme.css @@ -585,6 +585,14 @@ html.is-bm-route .m01lab-src__body * { --draw-map-zero-order: #7dd3fc; /* 0차곡(지형 추정 골짜기 머리 · 점선) */ --draw-map-forest-road-file: #ea580c; /* 올린 임도망도(실선 · 짐작 = 주황 점선) */ --draw-map-landslide-zone: #e11d48; /* 산사태취약지역 점 · 필지 테두리 */ + --draw-map-sketch: #ffe94d; /* 지도 위 그림(테마 안 따름 · 검은 테와 함께) — 긋기 미리보기 · 그리는 선 · 고름 강조 · 마커 */ + --draw-map-measure: #ffffff; /* 거리재기 */ + --draw-map-warn: #ff5a4d; /* 긋기 막힘(경고) */ + --draw-map-route-0: #3df5c4; /* 예정노선 선마다 차례 색(개발제한 · 산사태 주황과 가름) */ + --draw-map-route-1: #5aa9ff; + --draw-map-route-2: #c58bff; + --draw-map-route-3: #ff6ea8; + --draw-map-route-4: #9dff4d; } :root[data-theme="dark"] {