Skip to content

Commit 4fc0e29

Browse files
authored
Merge pull request #617 from HSLdevcom/feat/modes-in-links-txt
Feat/modes in links txt
2 parents 9bb0b46 + c9e4ae3 commit 4fc0e29

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Scripts/utils/print_links.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,30 @@
33

44
def print_links(network, resultdata):
55
"""Dump link attributes with wkt coordinates to file.
6-
6+
77
Includes noise calculation (works well only when morning peak hour
88
is assigned in the same EMME skenario). Noise calculation could be
99
removed from here if noise extra attribute would be added.
10-
10+
1111
Parameters
1212
----------
1313
network : inro.emme.network.Network
1414
Network where whole-day results are stored
1515
"""
1616
attr_names = network.attributes("LINK")
1717
resultdata.print_line(
18-
"Link\tnode_i\tnode_j" + "\t".join(attr_names) + "\tNoise_zone_width", "links")
18+
"Link\tnode_i\tnode_j\tmodes" + "\t".join(attr_names) + "\tNoise_zone_width", "links")
1919
noisemodel = NoiseModel(
2020
network, ("@car_work_vrk", "@car_leisure_vrk", "@van_vrk"),
2121
("@truck_vrk", "@trailer_truck_vrk"))
2222
for link in network.links():
23+
# link.modes is a frozenset of modes objects, we want a string of identifiers
24+
modes = "".join([mode.id for mode in link.modes])
2325
wkt = "LINESTRING ({} {}, {} {})".format(
2426
link.i_node.x, link.i_node.y, link.j_node.x, link.j_node.y)
2527
attrs = "\t".join([str(link[attr]) for attr in attr_names])
2628
noise_zone_width = noisemodel.calc_noise(link)
2729
resultdata.print_line(
28-
wkt + "\t" + str(link.i_node.id) + "\t" + str(link.j_node.id) + "\t" + attrs + "\t" + str(noise_zone_width), "links")
30+
wkt + "\t" + str(link.i_node.id) + "\t" + str(link.j_node.id)+ "\t" + modes + "\t" + attrs + "\t" + str(noise_zone_width), "links")
2931
resultdata.flush()
32+

0 commit comments

Comments
 (0)