From 05a7000d3333dae60b80ff52da74963bbbbe1bec Mon Sep 17 00:00:00 2001 From: Michael Stangl Date: Thu, 2 Jul 2026 13:19:30 +0200 Subject: [PATCH] =?UTF-8?q?Gef=C3=A4llestrecke=20in=20Sivas=20und=20csv=20?= =?UTF-8?q?Exports=20eingebaut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/export_csv.py | 33 ++++++++++++++++++ lib/export_sivas.py | 82 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 103 insertions(+), 12 deletions(-) diff --git a/lib/export_csv.py b/lib/export_csv.py index 76e5a61..c67cc1c 100644 --- a/lib/export_csv.py +++ b/lib/export_csv.py @@ -79,6 +79,25 @@ def build_weiche_merkmale(block, eintrag): } +def build_variofoerderer_merkmale(block): + attribs = block.get("attribs", {}) + return { + "Typ": attribs.get("TYP", ""), + "Seite": attribs.get("SEITE", ""), + "Winkel": attribs.get("WINKEL", ""), + "DeltaH_mm": attribs.get("DELTA_H", ""), + "DeltaL_mm": attribs.get("DELTA_L", ""), + "L_VF_m": attribs.get("L_VF_m", ""), + "L_GF_m": attribs.get("L_GF_m", ""), + "Montagehoehe_m": attribs.get("MONTAGEHOEHE_m", ""), + "Hoehe_Von_mm": attribs.get("HOEHE_VON", ""), + "Hoehe_Bis_mm": attribs.get("HOEHE_BIS", ""), + "Antriebfahrtrichtung": attribs.get("ANTRIEBFAHRTRICHTUNG", ""), + "Anzahl_Separator": attribs.get("ANZAHL_SEPARATOR", ""), + "Anzahl_Scanner": attribs.get("ANZAHL_SCANNER", ""), + } + + def build_gerade_merkmale(block): return { "Anzahl der Separatoren": "0", @@ -135,6 +154,7 @@ def process_blocks(blocks, lookup): weiche_count = {} gerade_count = 0 kreisel_count = 0 + vf_count = 0 for block in blocks: bname = block.get("block_name", "") @@ -183,6 +203,19 @@ def process_blocks(blocks, lookup): }) continue + # VarioFoerderer Compound-Block (VF_N) + if bname.startswith("VF_"): + elem_nr += 1 + vf_count += 1 + items.append({ + "nr": elem_nr, + "teileart": "VarioFoerderer", + "teileid": block.get("attribs", {}).get("ID", "0000"), + "bezeichnung": f"VarioFoerderer :{vf_count}", + "merkmale": build_variofoerderer_merkmale(block), + }) + continue + # ILS Kreisel (Compound-Bloecke mit Praefix KR_) if bname.startswith("KR_"): elem_nr += 1 diff --git a/lib/export_sivas.py b/lib/export_sivas.py index f5b34a9..c85b0c3 100644 --- a/lib/export_sivas.py +++ b/lib/export_sivas.py @@ -64,6 +64,11 @@ def get_hoehe_mm(block): return v +def get_id(block): + """Liest das eindeutige ID-Attribut eines Blocks (von ssg-id-check-all vergeben).""" + return block.get("attribs", {}).get("ID", "") + + def format_hoehe_m(hoehe_mm_str): """Konvertiert mm-String nach m mit deutschem Dezimaltrennzeichen.""" try: @@ -129,12 +134,14 @@ def process_blocks(blocks, lookup): items - Liste der CSV-Zeilen als Dicts counters - Zaehler fuer ILS-Automation-Summierungszeile """ - # Gruppen: sivasnr_str -> {anzahl, hoehe_mm} + # Gruppen: sivasnr_str -> {anzahl, hoehe_mm, ids} bogen_groups = {} # sivasnr -> dict weiche_groups = {} # sivasnr -> dict - # Gerade: artinr_str -> {anzahl, laenge_mm_total, hoehe_mm} + # Gerade: artinr_str -> {anzahl, laenge_mm_total, hoehe_mm, ids} gerade_groups = {} kreisel_list = [] # Liste von blocks + eckrad_ids = [] # IDs aller Eckrad-Bloecke + strecke_ids = [] # IDs aller Strecke-Module (VF_*, GF_*, Vario/Staustrecke) counters = { "anzahl_boegen": 0, @@ -181,14 +188,16 @@ def process_blocks(blocks, lookup): if typ == "bogen": if sivasnr not in bogen_groups: - bogen_groups[sivasnr] = {"anzahl": 0, "hoehe_mm": hoehe} + bogen_groups[sivasnr] = {"anzahl": 0, "hoehe_mm": hoehe, "ids": []} bogen_groups[sivasnr]["anzahl"] += 1 + bogen_groups[sivasnr]["ids"].append(get_id(block)) counters["anzahl_boegen"] += 1 elif typ == "weiche": if sivasnr not in weiche_groups: - weiche_groups[sivasnr] = {"anzahl": 0, "hoehe_mm": hoehe} + weiche_groups[sivasnr] = {"anzahl": 0, "hoehe_mm": hoehe, "ids": []} weiche_groups[sivasnr]["anzahl"] += 1 + weiche_groups[sivasnr]["ids"].append(get_id(block)) subtyp = classify_weiche(eintrag) if subtyp == "einzelweiche": counters["anzahl_einzelweichen"] += 1 @@ -217,10 +226,12 @@ def process_blocks(blocks, lookup): pass if key not in gerade_groups: gerade_groups[key] = { - "anzahl": 0, "laenge_mm": 0.0, "hoehe_mm": hoehe, "artinr": artinr + "anzahl": 0, "laenge_mm": 0.0, "hoehe_mm": hoehe, + "artinr": artinr, "ids": [], } gerade_groups[key]["anzahl"] += 1 gerade_groups[key]["laenge_mm"] += laenge + gerade_groups[key]["ids"].append(get_id(block)) counters["gesamtlaenge_ap110"] += laenge continue @@ -247,12 +258,57 @@ def process_blocks(blocks, lookup): # --- ILS Eckrad --- if bname.startswith("ECKRAD_"): counters["anzahl_eckraeder"] += 1 + eckrad_ids.append(get_id(block)) continue - # --- ILS Strecke-Module (Vario/Staustrecke) --- + # --- VarioFoerderer Compound-Block (VF_N) --- + if bname.startswith("VF_"): + attribs = block.get("attribs", {}) + counters["anzahl_variofoerderer"] += 1 + strecke_ids.append(get_id(block)) + try: + counters["laengen_variofoerderer"] += float(attribs.get("L_VF_m", "0") or "0") + except (ValueError, TypeError): + pass + try: + counters["anzahl_separatoren"] += int(attribs.get("ANZAHL_SEPARATOR", "0") or "0") + except (ValueError, TypeError): + pass + try: + counters["anzahl_scanner"] += int(attribs.get("ANZAHL_SCANNER", "0") or "0") + except (ValueError, TypeError): + pass + if counters["anzahl_streckengruppen"] == 0: + counters["anzahl_streckengruppen"] = 1 + continue + + # --- Gefaellestrecke Compound-Block (GF_N) --- + if bname.startswith("GF_"): + attribs = block.get("attribs", {}) + counters["anzahl_variofoerderer"] += 1 + counters["anzahl_gefaellestrecken"] += 1 + strecke_ids.append(get_id(block)) + try: + counters["laengen_gefaellestrecken"] += float(attribs.get("L_GF_m", "0") or "0") + except (ValueError, TypeError): + pass + try: + counters["anzahl_separatoren"] += int(attribs.get("ANZAHL_SEPARATOR", "0") or "0") + except (ValueError, TypeError): + pass + try: + counters["anzahl_scanner"] += int(attribs.get("ANZAHL_SCANNER", "0") or "0") + except (ValueError, TypeError): + pass + if counters["anzahl_streckengruppen"] == 0: + counters["anzahl_streckengruppen"] = 1 + continue + + # --- ILS Strecke-Module (Vario/Staustrecke, einzelne Komponenten in Modelspace) --- for sb in STRECKE_BLOCKS: if sb in bname: counters["anzahl_variofoerderer"] += 1 + strecke_ids.append(get_id(block)) break # --- Zeilen aufbauen --- @@ -269,7 +325,7 @@ def process_blocks(blocks, lookup): "anzahl": g["anzahl"], "laenge_mm": "", "hoehe_m": format_hoehe_m(g["hoehe_mm"]), - "details": {}, + "details": {"IDs": g["ids"]}, }) nr += 1 @@ -283,7 +339,7 @@ def process_blocks(blocks, lookup): "anzahl": g["anzahl"], "laenge_mm": "", "hoehe_m": format_hoehe_m(g["hoehe_mm"]), - "details": {}, + "details": {"IDs": g["ids"]}, }) nr += 1 @@ -297,12 +353,14 @@ def process_blocks(blocks, lookup): "anzahl": g["anzahl"], "laenge_mm": int(g["laenge_mm"]), "hoehe_m": format_hoehe_m(g["hoehe_mm"]), - "details": {}, + "details": {"IDs": g["ids"]}, }) nr += 1 for block in kreisel_list: sivasnr, teileart = ILS_SIVASNR["kreisel"] + details = build_kreisel_details(block) + details["ID"] = get_id(block) items.append({ "nr": nr, "teileart": teileart, @@ -312,7 +370,7 @@ def process_blocks(blocks, lookup): "anzahl": 1, "laenge_mm": "", "hoehe_m": "", - "details": build_kreisel_details(block), + "details": details, }) nr += 1 @@ -327,7 +385,7 @@ def process_blocks(blocks, lookup): "anzahl": counters["anzahl_eckraeder"], "laenge_mm": "", "hoehe_m": "", - "details": {}, + "details": {"IDs": eckrad_ids}, }) nr += 1 @@ -342,7 +400,7 @@ def process_blocks(blocks, lookup): "anzahl": counters["anzahl_variofoerderer"], "laenge_mm": "", "hoehe_m": "", - "details": {}, + "details": {"IDs": strecke_ids}, }) nr += 1