Skip to content

Commit

Permalink
fix OSM name duplication issue
Browse files Browse the repository at this point in the history
  • Loading branch information
toruseo committed Mar 21, 2024
1 parent e3ce9c9 commit f5b4485
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Install pytest other dependencies
run: pip install pytest setuptools gymnasium torch osmnx
- name: Run examples with pytest
run: pytest tests/test_examples.py --durations=0
run: pytest tests/test_examples.py --durations=0 -v
12 changes: 9 additions & 3 deletions uxsim/uxsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -2622,10 +2622,16 @@ def osm_network_to_World(W, nodes, links, default_jam_density=0.2, coef_degree_t
coef_degree_to_meter: float
The coefficient to convert lon/lat degree to meter. Default is 111000.
"""
for node in nodes:
for i, node in enumerate(nodes):
nname = str(node[0])
if nname in [n.name for n in W.NODES.values()]:
nname + f"_osm{i}"
W.addNode(str(node[0]), x=node[1], y=node[2])
for link in links:
W.addLink(link[0], str(link[1]), str(link[2]), length=link[5]*coef_degree_to_meter, free_flow_speed=link[4], jam_density=default_jam_density)
for i, link in enumerate(links):
lname = str(link[0])
if lname in [l.name for l in W.LINKS.values()]:
lname + f"_osm{i}"
W.addLink(lname, str(link[1]), str(link[2]), length=link[5]*coef_degree_to_meter, free_flow_speed=link[4], jam_density=default_jam_density)


class World:
Expand Down

0 comments on commit f5b4485

Please sign in to comment.