feat(공용 지도): 도구줄 표 · 지형 칩 — D03 평면 도구줄을 표로 · 끝에 지형 칩(수치지형도 고름 · 라이다 막힘) (PLAN 624-2 · 요구 530 · 결정 A④ · A⑤ · A⑩)

- map_toolbar = 단추 열쇠 · 할 일 · 보일 페이지(d03 · b05) 표 · mapToolGroups(page, parts) — D03 단추 차례 · 묶음 그대로
- map_terrain_chip = 분할 고르기(수치지형도 · 라이다) · 이름 D03 「분석 지형」 · B05 「설계 지형」 · 없는 원천 막힘 — 바꾸는 일은 onChange(624-1 · 624-4 · 626-1)
- 시험 test_624_2_map_parts 새로 · 553-4 돌리기 자리 확인 = 표

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-31 20:28:50 +09:00
co-authored by Claude Opus 5.5
parent 8eb4dbee13
commit 6c25b864ac
5 changed files with 237 additions and 10 deletions
+62
View File
@@ -0,0 +1,62 @@
/* =============================================================================
* map_terrain_chip.ts
* 공용 지도 지형 칩(PLAN 624-2 · 요구 530 · 결정 A④ · A⑤ · D2) — 도구줄 끝 분할 고르기 하나: 수치지형도 · 라이다.
* 이름 = 예정노선 「분석 지형」 · B05 「설계 지형」(바꾸면 뒤 단계 모두 다시 셈 · 확인창은 B05 몫).
* 없는 원천 = 막힘 + 까닭 글(D03 라이다 = D 프로젝트에 LAS 올린 뒤 · 624-4).
* 화면 칩만 — 바꾸는 일(서버 원천 인자 624-1 · B05 설계 지형 바꿈 626-1)은 `onChange` 로 페이지가 붙임.
* 쓰는 법 = `createTerrainChip({ page: "d03", value: "sheet", have: ["sheet"] })` → `{ root, set, setHave }` · root 를 도구줄 `terrain` 칸에.
* ========================================================================== */
import { createSegment } from "@ui/ui_template_segment";
import type { MapPage } from "./map_layer_list";
export type TerrainSource = "sheet" | "las";
export const TERRAIN_NAMES: Record<TerrainSource, string> = { sheet: "수치지형도", las: "라이다" };
const CAPTION: Record<MapPage, string> = {
d03: "분석 지형 — 급경사 · 음영 · 0차곡 · 긋기 높이에 쓰는 지형",
b05: "설계 지형 — 바꾸면 종단 · 횡단 · 배수 · 토공을 모두 다시 셈",
};
const MISSING: Record<TerrainSource, string> = {
sheet: "수치지형도 — 이 프로젝트 범위에 도엽 지형 없음",
las: "라이다 — 올린 LAS 없음",
};
export interface TerrainChip {
root: HTMLElement;
/** 고름을 바꿈(onChange 는 안 부름). */
set: (value: TerrainSource) => void;
/** 고를 수 있는 원천 — 없는 것은 막힘. */
setHave: (have: readonly TerrainSource[]) => void;
}
export function createTerrainChip(opts: {
page: MapPage;
value: TerrainSource;
have: readonly TerrainSource[];
onChange?: (value: TerrainSource) => void;
}): TerrainChip {
const sources = Object.keys(TERRAIN_NAMES) as TerrainSource[];
const segment = createSegment({
options: sources.map((value) => ({ value, label: TERRAIN_NAMES[value] })),
value: opts.value,
size: 32,
ariaLabel: CAPTION[opts.page],
onChange: (value) => opts.onChange?.(value as TerrainSource),
});
const root = segment.root;
root.dataset.act = "terrain";
root.title = CAPTION[opts.page];
const setHave = (have: readonly TerrainSource[]): void => {
for (const value of sources) {
const item = root.querySelector<HTMLButtonElement>(`[data-value="${value}"]`)!;
item.disabled = !have.includes(value);
item.title = item.disabled
? MISSING[value]
: `${CAPTION[opts.page]} · ${TERRAIN_NAMES[value]}`;
}
};
setHave(opts.have);
return { root, set: (value) => segment.set(value), setHave };
}
+66
View File
@@ -0,0 +1,66 @@
/* =============================================================================
* map_toolbar.ts
* 공용 지도 도구줄 표(PLAN 624-2 · 요구 530 「상단 아이콘 셋 같게 · 필요 없는 것 숨김」) — 예정노선(D03) · B05 평면이 같이 씀.
* 한 줄 = 열쇠(`ui_template_map_tools` 단추 이름 · 아이콘 · 마우스 글은 거기) · 할 일 · 보일 페이지.
* 묶음 = 나눔선 · 차례 = 도구줄 차례 · 단추 아닌 칸(간격 고르기 · 지형 칩)은 이름을 여기 둠.
* 누름 동작 · 페이지 문구는 페이지 몫 — 만든 요소를 `parts` 로 넘기면 그 자리에 · 안 넘긴 단추는 기본 단추(돌리기 둘 = 공용 돌림이 `data-act` 로 찾음).
* 거리 재기 = 단추 자리만 같고 동작은 페이지 몫(결정 A⑩) · 지형 칩 = `map_terrain_chip`.
* 쓰는 법 = `createMapTools({ label, hint, groups: mapToolGroups("d03", { undo: undoButton, terrain: chip.root }) })`.
* ========================================================================== */
import type { MapToolAct } from "@ui/ui_template_map_tools";
import type { MapPage } from "./map_layer_list";
export type MapToolKey = MapToolAct | "snap-step" | "terrain";
export interface MapToolRow {
key: MapToolKey;
/** 단추 아닌 칸 이름(단추는 `MAP_TOOLS` 이름). */
name?: string;
does: string;
pages: readonly MapPage[];
}
const BOTH: readonly MapPage[] = ["d03", "b05"];
const B05: readonly MapPage[] = ["b05"];
export const MAP_TOOLBAR: readonly (readonly MapToolRow[])[] = [
[
{ key: "undo", does: "편집 한 걸음 되돌림", pages: BOTH },
{ key: "redo", does: "되돌린 걸음 다시", pages: BOTH },
],
[
{ key: "view3d", does: "3D 큰 창(동작 = 페이지 몫)", pages: BOTH },
{ key: "rotate-ccw", does: "지도 반시계로 돌림(Ctrl+휠도)", pages: BOTH },
{ key: "rotate-cw", does: "지도 시계로 돌림", pages: BOTH },
],
[
{ key: "contour-minor", does: "라이다 1 m 등고선 켬끔(라이다일 때만 열림)", pages: B05 },
{ key: "stations", does: "측점 눈금 · 번호 켬끔", pages: BOTH },
{ key: "slopes", does: "구간 기울기 글 켬끔", pages: BOTH },
{ key: "footprint", does: "도로 끝 · 비탈 끝(절/성토선) 켬끔", pages: B05 },
{ key: "measure", does: "거리 재기(동작 = 페이지 몫 · A⑩)", pages: BOTH },
],
[
{ key: "station-snap", does: "곡선 가운데(MC)를 간격 배수에 맞춤", pages: B05 },
{ key: "snap-step", name: "측점 스냅 간격", does: "스냅 간격 고르기", pages: B05 },
],
[{ key: "terrain", name: "지형 칩", does: "지형 원천 보기 · 고르기", pages: BOTH }],
];
const isAct = (key: MapToolKey): key is MapToolAct => key !== "snap-step" && key !== "terrain";
/** 그 페이지 도구줄 묶음 — 넘긴 요소 · 기본 단추(단추 열쇠만) · 빈 묶음 뺌. */
export function mapToolGroups(
page: MapPage,
parts: Partial<Record<MapToolKey, HTMLElement>> = {},
): (MapToolAct | HTMLElement)[][] {
return MAP_TOOLBAR.map((group) =>
group
.filter((row) => row.pages.includes(page))
.flatMap((row): (MapToolAct | HTMLElement)[] => {
const made = parts[row.key];
return made ? [made] : isAct(row.key) ? [row.key] : [];
}),
).filter((group) => group.length);
}
+15 -7
View File
@@ -1,7 +1,8 @@
/* =============================================================================
* D03_PlanAnalysis_UI_Map.ts
* D03 메인 평면(PLAN 530-3 · 562-3) — 위성 바탕 · 위에 겹(바탕 겹 569-2 · 그리기 · 거리재기) · 도구줄 아홉
* (공용 `createMapTools` 568-3 — [?] · 되돌리기 · 다시하기 · 3D · 좌회전 · 우회전 · 측점 · 기울기 · 거리재기).
* D03 메인 평면(PLAN 530-3 · 562-3) — 위성 바탕 · 위에 겹(바탕 겹 569-2 · 그리기 · 거리재기) · 도구줄 아홉 + 지형 칩
* (공용 `createMapTools` 568-3 — [?] · 되돌리기 · 다시하기 · 3D · 좌회전 · 우회전 · 측점 · 기울기 · 거리재기 ·
* 차례 · 보임 = 공용 도구줄 표 `A00_Common/map/map_toolbar` 624-2 · 지형 칩 `map_terrain_chip`).
*
* 셈 · 그리기는 B 부품 그대로(import 만) — 좌표 `createMetricProjector` · `screenToMetric` · 맞춤
* `computeRouteView` · 휠 확대 · 가운데 단추 옮기기 `bindRouteEditNavigation` ·
@@ -19,6 +20,8 @@
import { perfTime } from "@ui/ui_template_gl_map";
import { createMapTools, mapToolButton } from "@ui/ui_template_map_tools";
import { routeColor, themeColor } from "@ui/ui_template_palette";
import { createTerrainChip } from "../A00_Common/map/map_terrain_chip";
import { mapToolGroups } from "../A00_Common/map/map_toolbar";
import type { VWorldMeta } from "../B04_PreProcess/B04_PreProcess_Api_Fetch";
import {
computeMapRect,
@@ -226,11 +229,16 @@ export function createPlanMap(events: PlanMapEvents): PlanMap {
"Ctrl+휠 = 돌리기",
],
},
groups: [
[undoButton, redoButton],
[viewButton, "rotate-ccw", "rotate-cw"],
[markButton("stations", "측점"), markButton("slopes", "구간 길이 · 기울기"), measureButton],
],
// 624-2 — 단추 차례 · 보임 = 공용 도구줄 표(페이지 「d03」) · 지형 칩 = 수치지형도(라이다 = 624-4)
groups: mapToolGroups("d03", {
undo: undoButton,
redo: redoButton,
view3d: viewButton,
stations: markButton("stations", "측점"),
slopes: markButton("slopes", "구간 길이 · 기울기"),
measure: measureButton,
terrain: createTerrainChip({ page: "d03", value: "sheet", have: ["sheet"] }).root,
}),
});
const toolbar = tools.root;
toolbar.classList.add("d03-plan__tools");
+10 -3
View File
@@ -35,7 +35,9 @@ def test_d03_parts():
tools = _src("D03_PlanAnalysis/D03_PlanAnalysis_UI_Map.ts")
layers = _src("D03_PlanAnalysis/D03_PlanAnalysis_UI_Layers.ts")
assert 'createElement("progress")' not in ts and "createProgressBar(" not in ts
assert "createProgressCircle({ size: 16, inline: true })" in ts # 604-3 받기 = 위치 칸 제목 서클
assert (
"createProgressCircle({ size: 16, inline: true })" in ts
) # 604-3 받기 = 위치 칸 제목 서클
site = _src(
"D03_PlanAnalysis/D03_PlanAnalysis_UI_Site.ts"
) # 596-2 위치 칸 · 596-5 등록 찾기 = 같은 부품
@@ -52,7 +54,8 @@ def test_d03_parts():
assert "createToolbar(" not in tools and "createIconButton(" not in tools
for act in ("undo", "redo", "view3d", "measure", "stations", "slopes"):
assert f'mapToolButton("{act}"' in tools or f'markButton("{act}"' in tools, act
assert '"rotate-ccw", "rotate-cw"' in tools
table = _src("A00_Common/map/map_toolbar.ts") # 624-2 — 차례 · 보임 = 공용 도구줄 표
assert 'mapToolGroups("d03"' in tools and re.search(r'key: "rotate-ccw".*pages: BOTH', table)
for b05_only in ("footprint", "station-snap", "contour-minor"):
assert f'"{b05_only}"' not in tools, b05_only
paint = _src("D03_PlanAnalysis/D03_PlanAnalysis_UI_DrawPaint.ts") # 580 — 그림 나눔
@@ -60,7 +63,11 @@ def test_d03_parts():
# 569-2 · 581-1 · 581-2 — 바탕 겹 단추(공용 지도 도구줄 한 줄 · 묶음 셋) · 처음 켬 셋 · 취향 기억
defs = _src("A00_Common/map/map_layer_list.ts") # 624-2 공용 겹 목록
bar = _src("A00_Common/map/map_layer_bar.ts")
assert "createMapTools({" in bar and "createIconButton({" in bar and "createMapLayerBar({" in layers
assert (
"createMapTools({" in bar
and "createIconButton({" in bar
and "createMapLayerBar({" in layers
)
assert "createToolbar(" not in layers and "createToolbar(" not in bar
assert '"aislo:pref:d03.layers"' in defs and "writeByKey(MAP_LAYER_PAGES[page].pref" in bar
keys = re.findall(r'key: "(\w+)",\s+icon: "\w+",\s+title:\s+"[^"]+",\s+on: (true|false)', defs)
+84
View File
@@ -0,0 +1,84 @@
"""PLAN 624-2 — 공용 지도 부품(A00_Common/map) 지킴: 도구줄 표 · 겹 목록 페이지 표 · 범례 · 지형 칩 · D03 은 부르기만.
./venv/Scripts/python.exe -m pytest resources/tester/test_624_2_map_parts.py -q
"""
import re
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
MAP = ROOT / "A00_Common" / "map"
D03 = ROOT / "D03_PlanAnalysis"
def _read(path: Path) -> str:
return path.read_text(encoding="utf-8")
def _toolbar_rows() -> list[list[tuple[str, set[str]]]]:
"""표 → 묶음마다 (열쇠, 보일 페이지)."""
src = _read(MAP / "map_toolbar.ts")
pages = {"BOTH": {"d03", "b05"}, "B05": {"b05"}}
body = src[src.index("MAP_TOOLBAR") : src.index("const isAct")]
groups = re.findall(r"\[\s*(\{.*?\})\s*,?\s*\]", body, re.S)
return [
[(k, pages[p]) for k, p in re.findall(r'key: "([\w-]+)".*?pages: (\w+)', g, re.S)]
for g in groups
]
def test_toolbar_table_d03_same_as_before_plus_terrain() -> None:
d03 = [[k for k, p in g if "d03" in p] for g in _toolbar_rows()]
d03 = [g for g in d03 if g]
# 옛 D03 도구줄 세 묶음 그대로 + 끝에 지형 칩
assert d03 == [
["undo", "redo"],
["view3d", "rotate-ccw", "rotate-cw"],
["stations", "slopes", "measure"],
["terrain"],
], d03
b05 = {k for g in _toolbar_rows() for k, p in g if "b05" in p}
assert {"contour-minor", "footprint", "station-snap", "snap-step", "terrain"} <= b05
tools = _read(ROOT / "ui_template" / "ui_template_map_tools.ts")
for key in {k for g in _toolbar_rows() for k, _ in g} - {"snap-step", "terrain"}:
assert f'"{key}": {{' in tools or f"{key}: {{" in tools, key # 아이콘 · 이름 = MAP_TOOLS
def test_layer_pages() -> None:
src = _read(MAP / "map_layer_list.ts")
assert 'd03: { hide: [], pref: "aislo:pref:d03.layers" }' in src
b05 = re.search(r"b05: \{(.*?)\},", src, re.S).group(1)
assert 'hide: ["bands", "forestRoadFile"]' in b05 # A⑨
assert 'on: ["contour", "stream"]' in b05 # A② 지금 그대로
assert "for (const key of hide) on[key] = false;" in src
def test_common_parts_use_kit_and_no_page_imports() -> None:
for path in MAP.glob("*.ts"):
src = _read(path)
assert len(src.splitlines()) <= 700, path.name
for page in ("D03_PlanAnalysis", "B05_Profile", "B04_PreProcess"):
assert f"../../{page}" not in src and f"../{page}" not in src, (path.name, page)
for raw in ('createElement("button")', 'createElement("input")', 'createElement("select")'):
assert raw not in src, (path.name, raw)
chip = _read(MAP / "map_terrain_chip.ts")
assert "createSegment({" in chip and 'root.dataset.act = "terrain"' in chip
assert "createLegend(row)" in _read(MAP / "map_legend.ts")
assert "createMapTools({" in _read(MAP / "map_layer_bar.ts")
def test_d03_calls_common_only() -> None:
layers = _read(D03 / "D03_PlanAnalysis_UI_Layers.ts")
assert (
'createMapLayerBar({\n page: "d03"' in layers
and 'createMapLegend("d03-plan__legend")' in layers
)
assert len(layers.splitlines()) < 683 # 줄이기만
gl = _read(D03 / "D03_PlanAnalysis_UI_MapGl.ts")
assert "mapLayerSpecs(light, pick)" in gl and "function haloLine" not in gl
defs = _read(D03 / "D03_PlanAnalysis_UI_LayerDefs.ts")
assert "export const GROUPS" not in defs and "readPref" not in defs
ui_map = _read(D03 / "D03_PlanAnalysis_UI_Map.ts")
assert 'mapToolGroups("d03", {' in ui_map
assert 'createTerrainChip({ page: "d03", value: "sheet", have: ["sheet"] })' in ui_map
assert not (D03 / "D03_PlanAnalysis_UI_ForestLayers.ts").exists()