Skip to content

Commit c855adb

Browse files
committed
fix #17359
1 parent 403e716 commit c855adb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tools/generateRerouters.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def get_options(args=None):
3737
help="define the output rerouter filename", default="rerouters.xml")
3838
op.add_option("-x", "--closed-edges", category="input", dest="closedEdges", type=op.edge_list,
3939
help="provide a comma-separated list of edges to close")
40+
op.add_option("-f", "--closed-edges.input-file", category="input", dest="closedEdgesFile", type=op.file,
41+
help="provide a selection file with edges to close")
4042
op.add_option("-i", "--id-prefix", category="processing", dest="idPrefix", default="rr",
4143
help="id prefix for generated rerouters")
4244
op.add_option("--vclass", category="processing", default="passenger",
@@ -50,11 +52,19 @@ def get_options(args=None):
5052
op.add_option("-e", "--end", category="time", default=86400, type=float,
5153
help="end time for the closing (default 86400)")
5254
options = op.parse_args(args=args)
53-
if not options.netfile or not options.closedEdges:
55+
if not options.netfile or (not options.closedEdges and not options.closedEdgesFile):
5456
op.print_help()
5557
sys.exit(1)
5658

57-
options.closedEdges = options.closedEdges.split(',')
59+
options.closedEdges = options.closedEdges.split(',') if options.closedEdges else []
60+
if options.closedEdgesFile:
61+
with sumolib.miscutils.openz(options.closedEdgesFile, "r", encoding="utf-8") as f:
62+
for line in f:
63+
line = line.strip()
64+
if line.startswith("edge:"):
65+
edgeID = line[5:]
66+
options.closedEdges.append(edgeID)
67+
5868
return options
5969

6070

0 commit comments

Comments
 (0)