Skip to content

Commit

Permalink
write turn direction into intersection output
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Sep 30, 2024
1 parent 1ecc7a5 commit 9e8a753
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions matsim/scenariogen/network/run_intersections.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def writeDetectorFile(f_name, output, lanes):
f.write(text)


def read_result(folder, junctionId, fromEdgeId, toEdgeId):
def read_result(folder, junctionId, fromEdgeId, toEdgeId, direction):

res = []
lane = 0
Expand Down Expand Up @@ -100,6 +100,7 @@ def read_result(folder, junctionId, fromEdgeId, toEdgeId):
"junctionId": junctionId,
"fromEdgeId": fromEdgeId,
"toEdgeId": toEdgeId,
"direction": direction,
"lane": lane,
"flow": flow
})
Expand Down Expand Up @@ -168,6 +169,12 @@ def run(args, nodes):
if r not in extra_routes:
extra_routes.append(r)

# Store all directions
directions = set()
for c in node.getConnections():
if c.getFrom() == fromEdge and c.getTo() == toEdge:
directions.add(c._direction)

lanes = [fromEdge._id + "_" + str(i) for i in range(len(fromEdge._lanes))]

writeRouteFile(p_routes, routes, extra_routes, args.scenario)
Expand All @@ -183,7 +190,8 @@ def run(args, nodes):
res.extend(read_result(folder,
junctionId=node._id,
fromEdgeId=fromEdge._id,
toEdgeId=toEdge._id))
toEdgeId=toEdge._id,
direction="".join(directions)))

df = pd.DataFrame(res)
df.to_csv(join(args.output, "%s.csv" % node._id), index=False)
Expand Down

0 comments on commit 9e8a753

Please sign in to comment.