Die CPID von Connectionspoint wurde korrigiert.
This commit is contained in:
+21
-11
@@ -20,14 +20,13 @@ def process_json_file(input_file, output_file):
|
||||
"CPR1": 180,
|
||||
"CPL1": 180,
|
||||
"CP2": lambda kw: round(360 - kw, 1),
|
||||
"CPR2": lambda kw: round(360 - kw, 1),
|
||||
"CPR2": lambda kw: round(kw, 1),
|
||||
"CPL2": lambda kw: round(360 - kw, 1),
|
||||
"CP3": lambda kw: round(kw, 1),
|
||||
"CPR3": lambda kw: round(kw, 1),
|
||||
"CPL3": lambda kw: round(kw, 1),
|
||||
"CP4": 0
|
||||
}
|
||||
|
||||
|
||||
# Process each item in the JSON data
|
||||
for item in data:
|
||||
if item.get("SivasnrTEF") is not None:
|
||||
@@ -57,10 +56,16 @@ def process_json_file(input_file, output_file):
|
||||
item["scale_factor_RD_Width"] = round(scale_RD_W, 6)
|
||||
item["scale_factor_RD_Height"] = round(scale_RD_H, 6)
|
||||
|
||||
# Process connection points -
|
||||
# Process connection points
|
||||
connection_points = []
|
||||
kurven_winkel = item["KurvenWinkel"]
|
||||
|
||||
# 检查特殊条件
|
||||
profiltyp = item.get("ProfilTyp", "")
|
||||
weichentyp = item.get("WeichenTyp", "")
|
||||
|
||||
# 特殊规则:如果包含 -R- 且是 Einzelweiche,则 CP2 使用 CP3 的规则
|
||||
is_special_case = "-R-" in profiltyp and weichentyp == "Einzelweiche"
|
||||
|
||||
cp_fields = {}
|
||||
for key in item.keys():
|
||||
@@ -70,10 +75,8 @@ def process_json_file(input_file, output_file):
|
||||
if y_key in item:
|
||||
cp_fields[base_key] = (key, y_key)
|
||||
|
||||
|
||||
for base_key, (x_key, y_key) in cp_fields.items():
|
||||
try:
|
||||
|
||||
if base_key.startswith('OFWeiche_'):
|
||||
cp_type = base_key.replace('OFWeiche_', '')
|
||||
link_class = "Omniflo"
|
||||
@@ -83,11 +86,16 @@ def process_json_file(input_file, output_file):
|
||||
else:
|
||||
continue
|
||||
|
||||
|
||||
cp_id = cp_type.lower()
|
||||
|
||||
|
||||
direction_rule = DIRECTION_RULES.get(cp_type)
|
||||
# 应用特殊规则
|
||||
if is_special_case and cp_type in ["CP2"]:
|
||||
# 对于特殊情况的CP2,使用CP3的规则
|
||||
direction_rule = DIRECTION_RULES.get("CP3")
|
||||
print(f"特殊规则应用: {cp_type} 使用 CP3 的方向规则")
|
||||
else:
|
||||
direction_rule = DIRECTION_RULES.get(cp_type)
|
||||
|
||||
if direction_rule is None:
|
||||
print(f"警告: 未找到连接点 {cp_type} 的方向规则,使用默认值0")
|
||||
direction = 0
|
||||
@@ -96,7 +104,6 @@ def process_json_file(input_file, output_file):
|
||||
else:
|
||||
direction = direction_rule
|
||||
|
||||
|
||||
x_px = round(item[x_key] * scale * scale_RD_W, 3)
|
||||
y_px = round(item[y_key] * scale * scale_RD_H, 3)
|
||||
|
||||
@@ -114,10 +121,13 @@ def process_json_file(input_file, output_file):
|
||||
print(f"cp: {base_key} error: {e}")
|
||||
continue
|
||||
|
||||
|
||||
connection_points.sort(key=lambda x: x["id"])
|
||||
item["connectionPoints"] = connection_points
|
||||
|
||||
# 输出特殊规则应用信息
|
||||
if is_special_case:
|
||||
print(f"特殊规则已应用: {item['Sivasnr']} - {profiltyp}")
|
||||
|
||||
print(f"Processed {item['Sivasnr']}: find: {len(connection_points)} CPs")
|
||||
|
||||
# Save the processed data
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
"TEFWeiche_center_line_height_mm": 722.5864,
|
||||
"OFWeiche_CP1_x_mm": 53.5437,
|
||||
"OFWeiche_CP1_y_mm": 715.0010,
|
||||
"OFWeiche_CP3_x_mm": 403.6727,
|
||||
"OFWeiche_CP3_y_mm": 14.8776,
|
||||
"OFWeiche_CP2_x_mm": 403.6727,
|
||||
"OFWeiche_CP2_y_mm": 14.8776,
|
||||
"OFWeiche_CP4_x_mm": 53.5437,
|
||||
"OFWeiche_CP4_y_mm": 355.0010,
|
||||
"TEFWeiche_CPR1_x_mm": 153.5537,
|
||||
@@ -88,8 +88,8 @@
|
||||
"TEFWeiche_center_line_height_mm": 764.5864,
|
||||
"OFWeiche_CP1_x_mm": 53.5437,
|
||||
"OFWeiche_CP1_y_mm": 764.8776,
|
||||
"OFWeiche_CP3_x_mm": 453.5437,
|
||||
"OFWeiche_CP3_y_mm": 14.8776,
|
||||
"OFWeiche_CP2_x_mm": 453.5437,
|
||||
"OFWeiche_CP2_y_mm": 14.8776,
|
||||
"OFWeiche_CP4_x_mm": 53.5437,
|
||||
"OFWeiche_CP4_y_mm": 404.8776,
|
||||
"TEFWeiche_CPR1_x_mm": 153.5537,
|
||||
@@ -138,8 +138,8 @@
|
||||
"TEFWeiche_center_line_height_mm": 738.62,
|
||||
"OFWeiche_CP1_x_mm": 53.544,
|
||||
"OFWeiche_CP1_y_mm": 721.225,
|
||||
"OFWeiche_CP3_x_mm": 753.9172,
|
||||
"OFWeiche_CP3_y_mm": 21.0400,
|
||||
"OFWeiche_CP2_x_mm": 753.9172,
|
||||
"OFWeiche_CP2_y_mm": 21.0400,
|
||||
"OFWeiche_CP4_x_mm": 53.544,
|
||||
"OFWeiche_CP4_y_mm": 361.25,
|
||||
"TEFWeiche_CPR1_x_mm": 153.554,
|
||||
|
||||
@@ -82,8 +82,8 @@
|
||||
"TEFWeiche_center_line_height_mm": 722.5864,
|
||||
"OFWeiche_CP1_x_mm": 53.5437,
|
||||
"OFWeiche_CP1_y_mm": 715.001,
|
||||
"OFWeiche_CP3_x_mm": 403.6727,
|
||||
"OFWeiche_CP3_y_mm": 14.8776,
|
||||
"OFWeiche_CP2_x_mm": 403.6727,
|
||||
"OFWeiche_CP2_y_mm": 14.8776,
|
||||
"OFWeiche_CP4_x_mm": 53.5437,
|
||||
"OFWeiche_CP4_y_mm": 355.001,
|
||||
"TEFWeiche_CPR1_x_mm": 153.5537,
|
||||
@@ -108,7 +108,7 @@
|
||||
"linkClass": "Omniflo"
|
||||
},
|
||||
{
|
||||
"id": "cp3",
|
||||
"id": "cp2",
|
||||
"x": 813.207,
|
||||
"y": 17.334,
|
||||
"direction": 45,
|
||||
@@ -132,7 +132,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 955.415,
|
||||
"y": 99.873,
|
||||
"direction": 315,
|
||||
"direction": 45,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -220,8 +220,8 @@
|
||||
"TEFWeiche_center_line_height_mm": 764.5864,
|
||||
"OFWeiche_CP1_x_mm": 53.5437,
|
||||
"OFWeiche_CP1_y_mm": 764.8776,
|
||||
"OFWeiche_CP3_x_mm": 453.5437,
|
||||
"OFWeiche_CP3_y_mm": 14.8776,
|
||||
"OFWeiche_CP2_x_mm": 453.5437,
|
||||
"OFWeiche_CP2_y_mm": 14.8776,
|
||||
"OFWeiche_CP4_x_mm": 53.5437,
|
||||
"OFWeiche_CP4_y_mm": 404.8776,
|
||||
"TEFWeiche_CPR1_x_mm": 153.5537,
|
||||
@@ -246,7 +246,7 @@
|
||||
"linkClass": "Omniflo"
|
||||
},
|
||||
{
|
||||
"id": "cp3",
|
||||
"id": "cp2",
|
||||
"x": 920.665,
|
||||
"y": 16.458,
|
||||
"direction": 45,
|
||||
@@ -270,7 +270,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 955.073,
|
||||
"y": 154.171,
|
||||
"direction": 315,
|
||||
"direction": 45,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -358,8 +358,8 @@
|
||||
"TEFWeiche_center_line_height_mm": 738.62,
|
||||
"OFWeiche_CP1_x_mm": 53.544,
|
||||
"OFWeiche_CP1_y_mm": 721.225,
|
||||
"OFWeiche_CP3_x_mm": 753.9172,
|
||||
"OFWeiche_CP3_y_mm": 21.04,
|
||||
"OFWeiche_CP2_x_mm": 753.9172,
|
||||
"OFWeiche_CP2_y_mm": 21.04,
|
||||
"OFWeiche_CP4_x_mm": 53.544,
|
||||
"OFWeiche_CP4_y_mm": 361.25,
|
||||
"TEFWeiche_CPR1_x_mm": 153.554,
|
||||
@@ -384,7 +384,7 @@
|
||||
"linkClass": "Omniflo"
|
||||
},
|
||||
{
|
||||
"id": "cp3",
|
||||
"id": "cp2",
|
||||
"x": 1000.0,
|
||||
"y": 24.475,
|
||||
"direction": 90,
|
||||
@@ -408,7 +408,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 920.928,
|
||||
"y": 140.81,
|
||||
"direction": 270,
|
||||
"direction": 90,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -546,7 +546,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 972.604,
|
||||
"y": 99.873,
|
||||
"direction": 315,
|
||||
"direction": 45,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -633,7 +633,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 975.012,
|
||||
"y": 99.873,
|
||||
"direction": 315,
|
||||
"direction": 45,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -771,7 +771,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 974.083,
|
||||
"y": 154.171,
|
||||
"direction": 315,
|
||||
"direction": 45,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -858,7 +858,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 974.797,
|
||||
"y": 154.171,
|
||||
"direction": 315,
|
||||
"direction": 45,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -996,7 +996,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 957.445,
|
||||
"y": 140.81,
|
||||
"direction": 270,
|
||||
"direction": 90,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -1083,7 +1083,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 957.445,
|
||||
"y": 140.81,
|
||||
"direction": 270,
|
||||
"direction": 90,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -1239,7 +1239,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 972.604,
|
||||
"y": 99.873,
|
||||
"direction": 315,
|
||||
"direction": 45,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -1335,7 +1335,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 975.012,
|
||||
"y": 99.873,
|
||||
"direction": 315,
|
||||
"direction": 45,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -1491,7 +1491,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 974.083,
|
||||
"y": 154.171,
|
||||
"direction": 315,
|
||||
"direction": 45,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -1587,7 +1587,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 974.797,
|
||||
"y": 154.171,
|
||||
"direction": 315,
|
||||
"direction": 45,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -1743,7 +1743,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 957.445,
|
||||
"y": 140.81,
|
||||
"direction": 270,
|
||||
"direction": 90,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -1839,7 +1839,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 957.445,
|
||||
"y": 140.81,
|
||||
"direction": 270,
|
||||
"direction": 90,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -1926,7 +1926,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 1000.0,
|
||||
"y": 154.474,
|
||||
"direction": 270,
|
||||
"direction": 90,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
@@ -2064,7 +2064,7 @@
|
||||
"id": "cpr2",
|
||||
"x": 1000.0,
|
||||
"y": 154.735,
|
||||
"direction": 270,
|
||||
"direction": 90,
|
||||
"linkClass": "TEFOmniflo"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user