new seplist added

This commit is contained in:
2026-09-11 11:57:39 +02:00
parent bb9d77fde9
commit f4edb7339d
2 changed files with 324981 additions and 0 deletions
+324840
View File
File diff suppressed because it is too large Load Diff
+141
View File
@@ -0,0 +1,141 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
test_export_separatorliste.py - Merkmal "Separatorlist" einer Strecke.
Laeuft komplett ohne BricsCAD (reine Python-Logik, siehe lib/export_csv.py).
Eine Strecke (VF_n/GF_n) traegt in ihrer "sepliste"-XDATA nur x/y je AS-/SEP-/
ES-Eintrag (Rohkoordinaten aus der Zeichnung, kein TeileId). write_separator-
liste_merkmale() soll daraus, ueber die bereits von map_separator_kette_items
per x/y-Abgleich aufgeloesten sep_kette_by_key-Eintraege, das Merkmal
"Separatorlist" der Strecke fuellen: die TeileIds ihrer SEP-Eintraege (NICHT
AS/ES) in Baureihenfolge, kommagetrennt (z.B. "0052, 0053, 0054").
"""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
from export_neighbors import compute_sep_kette, compute_kreisel_umlauf # noqa: E402
from export_csv import ( # noqa: E402
build_strecke_schleus_items,
map_separator_kette_items,
write_separatorliste_merkmale,
)
DURCHMESSER_MM = 800.0
def _kreisel(teileid, x0, y0, rotation, abstand=1000.0):
return {
"teileart": "ILS 2.0 Kreisel",
"teileid": teileid,
"x": x0, "y": y0, "z": 0.0,
"rotation": rotation,
"attribs": {"ABSTAND": str(abstand), "DREHRICHTUNG": "UZS"},
"_bbox": {"cx": x0, "cy": y0, "cz": 0.0,
"dx": abstand + DURCHMESSER_MM, "dy": DURCHMESSER_MM},
}
def _strecke_mit_zwei_separatoren():
"""Ein Kreisel + eine Gefaellestrecke mit sepliste AS(1) -> SEP(2) ->
SEP(3) -> ES(4), PLUS die zwei bereits vorhandenen Proxy-Separator-Items
(wie sie der freie-Separator-Pfad in process_blocks erzeugt: TeileId,
Merkmal "Zuordnung" = Wrapper-ID, INSERT-Punkt _x/_y an der jeweiligen
sepliste-SEP-Koordinate) - siehe TestSeplisteNachbarnAufgeloest in
test_export_kreisel_umlauf.py fuer dasselbe Fixture-Muster."""
k = _kreisel("0001", 0.0, 0.0, 0.0, abstand=1000.0)
strecke = {
"teileart": "ILS 2.0 Gefaellestrecke",
"teileid": "0010",
"x": 5000.0, "y": 0.0, "z": 0.0,
"nachbarn": "0001",
"_bbox": {"cx": 5000.0, "cy": 0.0, "cz": 0.0, "dx": 8000.0, "dy": 300.0},
"k1": "", "k2": "",
"merkmale": {"Anzahl_Separator": "2", "Anzahl_Scanner": "0"},
"sepliste": [
{"typ": "AS", "lfdnr": 1, "x": 1500.0, "y": 0.0},
{"typ": "SEP", "lfdnr": 2, "x": 4000.0, "y": 0.0},
{"typ": "SEP", "lfdnr": 3, "x": 6000.0, "y": 0.0},
{"typ": "ES", "lfdnr": 4, "x": 8500.0, "y": 0.0},
],
}
proxy_sep_1 = {
"teileart": "ILS 2.0 Separator",
"teileid": "0052",
"merkmale": {"Zuordnung": "0010"},
"_x": 4000.0, "_y": 0.0,
"_bbox": {"cx": 4000.0, "cy": 0.0, "cz": 0.0, "dx": 150.0, "dy": 210.0},
"nachbarn": "",
}
proxy_sep_2 = {
"teileart": "ILS 2.0 Separator",
"teileid": "0053",
"merkmale": {"Zuordnung": "0010"},
"_x": 6000.0, "_y": 0.0,
"_bbox": {"cx": 6000.0, "cy": 0.0, "cz": 0.0, "dx": 150.0, "dy": 210.0},
"nachbarn": "",
}
return [k, strecke, proxy_sep_1, proxy_sep_2]
class TestSeparatorlisteMerkmal:
def test_separatorlist_in_baureihenfolge(self):
items = _strecke_mit_zwei_separatoren()
sep_kette = compute_sep_kette(items)
compute_kreisel_umlauf( # AS/ES muessen als Punkte existieren, sonst
items, sep_kette, tolerance_mm=50.0, # unveraendert fuer diesen Test
durchmesser_mm=DURCHMESSER_MM, touch_switches=[])
sep_kette_by_key = {}
build_strecke_schleus_items(
items, None, 100, sep_kette=sep_kette,
sep_kette_by_key=sep_kette_by_key)
map_separator_kette_items(
items, sep_kette, sep_kette_by_key=sep_kette_by_key)
write_separatorliste_merkmale(items, sep_kette_by_key)
strecke = next(it for it in items if it.get("teileid") == "0010")
assert strecke["merkmale"]["Separatorlist"] == "0052, 0053", (
f'Separatorlist = {strecke["merkmale"].get("Separatorlist")!r}, '
f'erwartet "0052, 0053" (Baureihenfolge, AS/ES ausgeschlossen)')
def test_vertauschte_proxy_reihenfolge_in_items_aendert_nichts(self):
"""Die Reihenfolge in "items" (bzw. in welcher Reihenfolge die Proxy-
Separatoren im Export auftauchen) darf die Separatorlist-Reihenfolge
nicht beeinflussen - massgeblich ist allein die lfdnr aus der
sepliste, nicht die Item-Liste."""
items = _strecke_mit_zwei_separatoren()
k, strecke, proxy_1, proxy_2 = items
items = [k, strecke, proxy_2, proxy_1] # vertauscht
sep_kette = compute_sep_kette(items)
compute_kreisel_umlauf(
items, sep_kette, tolerance_mm=50.0,
durchmesser_mm=DURCHMESSER_MM, touch_switches=[])
sep_kette_by_key = {}
build_strecke_schleus_items(
items, None, 100, sep_kette=sep_kette,
sep_kette_by_key=sep_kette_by_key)
map_separator_kette_items(
items, sep_kette, sep_kette_by_key=sep_kette_by_key)
write_separatorliste_merkmale(items, sep_kette_by_key)
strecke = next(it for it in items if it.get("teileid") == "0010")
assert strecke["merkmale"]["Separatorlist"] == "0052, 0053"
def test_strecke_ohne_sepliste_bleibt_unveraendert(self):
"""Altbestand ohne "sepliste"-XDATA darf kein leeres/kaputtes
Separatorlist-Merkmal bekommen - das Merkmal fehlt einfach."""
strecke = {
"teileart": "ILS 2.0 Strecke",
"teileid": "0020",
"merkmale": {"Anzahl_Separator": "0", "Anzahl_Scanner": "0"},
}
write_separatorliste_merkmale([strecke], {})
assert "Separatorlist" not in strecke["merkmale"]