feat(측점열쇠): 346-2 덧 2 열쇠 한 벌 — 구간형 :start · :end · 묶음 측점 종류(grid · end) · 같은 열쇠 둘째 규칙 공용
- common_util_station_key(ts · py 짝): role 덧붙임(구간형 시작 · 끝 = structure:<id>:start · :end · 기준은 structure:<id> 그대로) · grid(원래 격자 번호) · end(BP/EP) 종류 · dedupeStationKeys(같은 열쇠 둘째부터 at:<누가거리>) - B06 stationKeysOf 가 같은 규칙(측점 계획 · 구조물 목록의 시작 · 끝 자리 · 공용 dedupe) - 거울 시험에 새 갈래(구간형 · grid · end · dedupe) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QfHKQs7J3hQELKMWQMUJEy
This commit is contained in:
@@ -16,6 +16,7 @@ if str(PROJECT_ROOT) not in sys.path:
|
||||
|
||||
from common_util.common_util_station_key import ( # noqa: E402
|
||||
chainage_key,
|
||||
dedupe_station_keys,
|
||||
loose_chainage,
|
||||
station_key,
|
||||
)
|
||||
@@ -24,7 +25,17 @@ TS = PROJECT_ROOT / "common_util" / "common_util_station_key.ts"
|
||||
TYPESCRIPT = PROJECT_ROOT / "config" / "node_modules" / "typescript"
|
||||
|
||||
CASES = [
|
||||
("bp", 0.0, 20.0, None, "structure"),
|
||||
("bp", 0.0, 20.0, None, "structure", "anchor"),
|
||||
# 5파 — 묶음 측점 종류(grid · end) · 구간형 시작 · 끝(:start · :end)
|
||||
("grid", 41.3, 20.0, "2", "structure", "anchor"),
|
||||
("grid", 41.3, 20.0, None, "structure", "anchor"),
|
||||
("end", 0.0, 20.0, None, "structure", "anchor"),
|
||||
("end", 99.0, 20.0, None, "structure", "anchor"),
|
||||
("end", 99.0, 20.0, "EP", "structure", "anchor"),
|
||||
("structure", 30.0, 20.0, "st-9", "structure", "start"),
|
||||
("structure", 36.0, 20.0, "st-9", "structure", "end"),
|
||||
("irregular", 30.0, 20.0, "st-9", "structure", "start"),
|
||||
("pipe", 30.0, 20.0, None, "structure", "end"),
|
||||
("ep", 812.345, 20.0, None, "structure"),
|
||||
("regular", 40.0, 20.0, None, "structure"),
|
||||
("regular", 50.0, 20.0, None, "structure"), # 2.5 → 3(위로)
|
||||
@@ -37,6 +48,7 @@ CASES = [
|
||||
("pipe", 12.344, 20.0, "pipe-s1", "structure"),
|
||||
("structure", 12.345, 20.0, None, "structure"),
|
||||
]
|
||||
DEDUPE = (["grid:1", "structure:st-1", "grid:1", "structure:st-1"], [20.0, 25.0, 20.004, 25.006])
|
||||
LOOSE = ["85.05", "at:85.05", "grid:4", "pipe:pipe-s3", "-1.5", "end:BP"]
|
||||
|
||||
SCRIPT = r"""
|
||||
@@ -50,7 +62,8 @@ new Function("exports", "module", js)(box.exports, box);
|
||||
const m = box.exports;
|
||||
const input = JSON.parse(process.argv[3]);
|
||||
process.stdout.write(JSON.stringify({
|
||||
keys: input.cases.map((c) => m.stationKey(c[0], c[1], c[2], c[3], c[4])),
|
||||
keys: input.cases.map((c) => m.stationKey(c[0], c[1], c[2], c[3], c[4], c[5] ?? "anchor")),
|
||||
dedupe: m.dedupeStationKeys(input.dedupe[0], input.dedupe[1]),
|
||||
chainage: input.cases.map((c) => m.chainageKey(c[1])),
|
||||
loose: input.loose.map((k) => m.looseChainage(k)),
|
||||
}));
|
||||
@@ -65,7 +78,7 @@ def test_파이썬과_TS_열쇠_같음():
|
||||
SCRIPT,
|
||||
str(TYPESCRIPT),
|
||||
str(TS),
|
||||
json.dumps({"cases": CASES, "loose": LOOSE}),
|
||||
json.dumps({"cases": CASES, "loose": LOOSE, "dedupe": DEDUPE}),
|
||||
],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
@@ -77,6 +90,7 @@ def test_파이썬과_TS_열쇠_같음():
|
||||
assert out["keys"] == [station_key(*case) for case in CASES]
|
||||
assert out["chainage"] == [chainage_key(case[1]) for case in CASES]
|
||||
assert out["loose"] == [loose_chainage(key) for key in LOOSE]
|
||||
assert out["dedupe"] == dedupe_station_keys(*DEDUPE)
|
||||
|
||||
|
||||
def test_열쇠_규칙():
|
||||
@@ -86,3 +100,9 @@ def test_열쇠_규칙():
|
||||
assert station_key("irregular", 85.054, 20.0, "pipe-s3", "pipe") == "pipe:pipe-s3"
|
||||
assert station_key("irregular", 85.054, 20.0) == "at:85.05"
|
||||
assert loose_chainage("85.05") == 85.05 and loose_chainage("grid:4") is None
|
||||
# 5파 — 구간형 시작 · 끝 · 기준은 그대로 · 원래 격자 번호 · 같은 열쇠 둘째는 at:
|
||||
assert station_key("structure", 30.0, 20.0, "st-9", role="start") == "structure:st-9:start"
|
||||
assert station_key("structure", 33.0, 20.0, "st-9") == "structure:st-9"
|
||||
assert station_key("grid", 41.3, 20.0, "2") == "grid:2"
|
||||
assert station_key("end", 99.0, 20.0) == "end:EP"
|
||||
assert dedupe_station_keys(*DEDUPE) == ["grid:1", "structure:st-1", "at:20.00", "at:25.01"]
|
||||
|
||||
Reference in New Issue
Block a user