omniflo SumZeile jetzt nur über Python erzeugt.
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
# ============================================================
|
||||||
|
# export.cfg - Konfiguration fuer Lisp/export.lsp
|
||||||
|
#
|
||||||
|
# Format: INI-Style
|
||||||
|
# [ABSCHNITT]
|
||||||
|
# Key = Wert (einzelner Wert)
|
||||||
|
# Key = Wert1, Wert2, Wert3 (Musterliste fuer wcmatch, kommagetrennt)
|
||||||
|
#
|
||||||
|
# Zeilen mit # sind Kommentare. Leerzeilen werden ignoriert.
|
||||||
|
# ============================================================
|
||||||
|
|
||||||
|
[blockpattern]
|
||||||
|
pattern_kreisel= KR_*, KREISEL_*, ECKRAD_*
|
||||||
|
pattern_gerade= AP110*, AP_110*
|
||||||
|
pattern_strecke= Vario*, Staustrecke*, AUS_Element*, EIN_Element*, VF_*, GF_*
|
||||||
|
pattern_numerisch= #*
|
||||||
|
pattern_ks_subblocks= KS_EIN, KS_AUS, K1, K2, K3, K4
|
||||||
|
|
||||||
|
|
||||||
|
[filenames]
|
||||||
|
raw_json_datei= export_raw.json
|
||||||
|
python_exe= python
|
||||||
|
sivas_script= export_sivas.py
|
||||||
|
sivas_csv= export_sivas.csv
|
||||||
|
csv_script= export_csv.py
|
||||||
|
csv_csv= export.csv
|
||||||
+96
-5
@@ -1,7 +1,11 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
export_csv.py - Erzeugt eine einfache Item-Liste als CSV (ohne Summierung).
|
export_csv.py - Erzeugt eine einfache Item-Liste als CSV.
|
||||||
|
|
||||||
|
Fuer Omniflo-Elemente (Bogen/Weiche/Gerade) wird am Ende zusaetzlich eine
|
||||||
|
"Omniflo Sum"-Zeile mit Anzahl Boegen/Weichentypen und Gesamtlaenge AP110/AP60
|
||||||
|
angehaengt (siehe build_omni_sum_merkmale).
|
||||||
|
|
||||||
Aufruf:
|
Aufruf:
|
||||||
python export_csv.py <export_raw.json> <data_dir> <output.csv>
|
python export_csv.py <export_raw.json> <data_dir> <output.csv>
|
||||||
@@ -98,19 +102,74 @@ def build_variofoerderer_merkmale(block):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def get_laenge_mm(block):
|
||||||
|
"""Liest LAENGE (oder A) aus Block-Attributen. Fallback: 2000mm."""
|
||||||
|
attribs = block.get("attribs", {})
|
||||||
|
laenge = attribs.get("LAENGE") or attribs.get("A")
|
||||||
|
try:
|
||||||
|
return float(laenge)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return 2000.0
|
||||||
|
|
||||||
|
|
||||||
def build_gerade_merkmale(block):
|
def build_gerade_merkmale(block):
|
||||||
|
laenge_mm = get_laenge_mm(block)
|
||||||
|
hoehe = get_hoehe(block)
|
||||||
return {
|
return {
|
||||||
"Anzahl der Separatoren": "0",
|
"Anzahl der Separatoren": "0",
|
||||||
"Länge in Meter": "2",
|
"Länge in Meter": f"{laenge_mm / 1000.0:.2f}",
|
||||||
"Winkel": "0",
|
"Winkel": "0",
|
||||||
"Anzahl der Scanner": 0,
|
"Anzahl der Scanner": 0,
|
||||||
"Höhe oben": "2000",
|
"Höhe oben": hoehe,
|
||||||
"Höhe unten": "2000",
|
"Höhe unten": hoehe,
|
||||||
"Drehung": block.get("rotation", 0.0),
|
"Drehung": get_drehung(block),
|
||||||
"SivasNummer": ""
|
"SivasNummer": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Omniflo Sum-Zeile (Anzahl Boegen/Weichentypen, Gesamtlaenge AP110/AP60)
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
WEICHE_SUBTYP_MAP = {
|
||||||
|
"Einzelweiche": "einzelweiche",
|
||||||
|
"Doppelweiche": "doppelweiche",
|
||||||
|
"Dreiwegeweiche": "doppelweiche",
|
||||||
|
"Deltaweiche": "deltaweiche",
|
||||||
|
"Dreifachweiche": "deltaweiche",
|
||||||
|
"Sternweiche": "sternweiche",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def weichensubtyp(block, eintrag):
|
||||||
|
"""Bestimmt den Weichen-Subtyp fuer die Omniflo-Sum-Zaehlung."""
|
||||||
|
beschr = (block.get("attribs", {}).get("BESCHR") or "").upper()
|
||||||
|
if "WEICHENK" in beschr:
|
||||||
|
return "weichenkoerper"
|
||||||
|
subtyp = WEICHE_SUBTYP_MAP.get(eintrag.get("WeichenTyp", ""))
|
||||||
|
if subtyp:
|
||||||
|
return subtyp
|
||||||
|
if "DELTA" in beschr:
|
||||||
|
return "deltaweiche"
|
||||||
|
if "STAR" in beschr:
|
||||||
|
return "sternweiche"
|
||||||
|
return "einzelweiche"
|
||||||
|
|
||||||
|
|
||||||
|
def build_omni_sum_merkmale(cnt_boegen, cnt_wk, cnt_einzel, cnt_delta, cnt_doppel, cnt_stern,
|
||||||
|
len_ap110_mm, len_ap60_mm):
|
||||||
|
return {
|
||||||
|
"Anzahl Bögen": cnt_boegen,
|
||||||
|
"Anzahl Weichengrundkörper": cnt_wk,
|
||||||
|
"Anzahl Einwegweichen": cnt_einzel,
|
||||||
|
"Anzahl Deltaweichen": cnt_delta,
|
||||||
|
"Anzahl Doppelweichen und Dreiwegeweichen": cnt_doppel,
|
||||||
|
"Anzahl Sternweichen": cnt_stern,
|
||||||
|
"Gesamtlänge AP110": round(len_ap110_mm, 1),
|
||||||
|
"Gesamtlänge AP60": round(len_ap60_mm, 1),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def build_kreisel_merkmale(block):
|
def build_kreisel_merkmale(block):
|
||||||
attribs = block.get("attribs", {})
|
attribs = block.get("attribs", {})
|
||||||
abstand_mm = attribs.get("ABSTAND", "2300")
|
abstand_mm = attribs.get("ABSTAND", "2300")
|
||||||
@@ -156,6 +215,12 @@ def process_blocks(blocks, lookup):
|
|||||||
kreisel_count = 0
|
kreisel_count = 0
|
||||||
vf_count = 0
|
vf_count = 0
|
||||||
|
|
||||||
|
# Zaehlung fuer die Omniflo-Sum-Zeile (nur Bogen/Weiche/Gerade)
|
||||||
|
cnt_wk = cnt_einzel = cnt_delta = cnt_doppel = cnt_stern = 0
|
||||||
|
len_ap110_mm = 0.0
|
||||||
|
len_ap60_mm = 0.0
|
||||||
|
has_omniflo = False
|
||||||
|
|
||||||
for block in blocks:
|
for block in blocks:
|
||||||
bname = block.get("block_name", "")
|
bname = block.get("block_name", "")
|
||||||
|
|
||||||
@@ -167,6 +232,7 @@ def process_blocks(blocks, lookup):
|
|||||||
typ, eintrag = lookup[bname]
|
typ, eintrag = lookup[bname]
|
||||||
elem_nr += 1
|
elem_nr += 1
|
||||||
shape_id = block.get("attribs", {}).get("ID", "0000")
|
shape_id = block.get("attribs", {}).get("ID", "0000")
|
||||||
|
has_omniflo = True
|
||||||
|
|
||||||
if typ == "bogen":
|
if typ == "bogen":
|
||||||
bogen_count += 1
|
bogen_count += 1
|
||||||
@@ -188,12 +254,24 @@ def process_blocks(blocks, lookup):
|
|||||||
"bezeichnung": f"OFWeiche :{weiche_count[wt]}",
|
"bezeichnung": f"OFWeiche :{weiche_count[wt]}",
|
||||||
"merkmale": build_weiche_merkmale(block, eintrag),
|
"merkmale": build_weiche_merkmale(block, eintrag),
|
||||||
})
|
})
|
||||||
|
subtyp = weichensubtyp(block, eintrag)
|
||||||
|
if subtyp == "weichenkoerper":
|
||||||
|
cnt_wk += 1
|
||||||
|
elif subtyp == "deltaweiche":
|
||||||
|
cnt_delta += 1
|
||||||
|
elif subtyp == "sternweiche":
|
||||||
|
cnt_stern += 1
|
||||||
|
elif subtyp == "doppelweiche":
|
||||||
|
cnt_doppel += 1
|
||||||
|
else:
|
||||||
|
cnt_einzel += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Omniflo Gerade (AP110)
|
# Omniflo Gerade (AP110)
|
||||||
if "AP110" in bname.upper() or "AP_110" in bname.upper():
|
if "AP110" in bname.upper() or "AP_110" in bname.upper():
|
||||||
elem_nr += 1
|
elem_nr += 1
|
||||||
gerade_count += 1
|
gerade_count += 1
|
||||||
|
has_omniflo = True
|
||||||
items.append({
|
items.append({
|
||||||
"nr": elem_nr,
|
"nr": elem_nr,
|
||||||
"teileart": "Omniflo Gerade",
|
"teileart": "Omniflo Gerade",
|
||||||
@@ -201,6 +279,7 @@ def process_blocks(blocks, lookup):
|
|||||||
"bezeichnung": f"OFGerade :{gerade_count}",
|
"bezeichnung": f"OFGerade :{gerade_count}",
|
||||||
"merkmale": build_gerade_merkmale(block),
|
"merkmale": build_gerade_merkmale(block),
|
||||||
})
|
})
|
||||||
|
len_ap110_mm += get_laenge_mm(block)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# VarioFoerderer Compound-Block (VF_N)
|
# VarioFoerderer Compound-Block (VF_N)
|
||||||
@@ -229,6 +308,18 @@ def process_blocks(blocks, lookup):
|
|||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if has_omniflo:
|
||||||
|
elem_nr += 1
|
||||||
|
items.append({
|
||||||
|
"nr": elem_nr,
|
||||||
|
"teileart": "Omniflo Sum",
|
||||||
|
"teileid": "autogenerated_of_json",
|
||||||
|
"bezeichnung": "Omniflo sum",
|
||||||
|
"merkmale": build_omni_sum_merkmale(
|
||||||
|
bogen_count, cnt_wk, cnt_einzel, cnt_delta, cnt_doppel, cnt_stern,
|
||||||
|
len_ap110_mm, len_ap60_mm),
|
||||||
|
})
|
||||||
|
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user