summaryrefslogtreecommitdiffstats
path: root/store.py
diff options
context:
space:
mode:
authorGustav Sörnäs <gusso230@student.liu.se>2020-12-01 10:55:33 +0100
committerGustav Sörnäs <gusso230@student.liu.se>2020-12-01 10:55:33 +0100
commit3e4015d2c06935b9c2c3da92f586df02c1b903d2 (patch)
tree74a1c04828bc3e362236ce4e3c89c89756ead91f /store.py
parent7cbe2400eb7022273b382fb50b09c93d7060fa1e (diff)
downloadtdde25-3e4015d2c06935b9c2c3da92f586df02c1b903d2.tar.gz
no global parser
Diffstat (limited to 'store.py')
-rw-r--r--store.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/store.py b/store.py
index 9e6d4f7..1cee81a 100644
--- a/store.py
+++ b/store.py
@@ -13,10 +13,8 @@ class Node:
return self.lat, self.lng
-parser = None # Have a global reusable parser object
-
-
-def add_neighbours(nodes):
+def add_neighbours(nodes, parser):
+ print("adding neighbours")
for way in parser.iter_ways():
if 'highway' not in way['tags']:
continue
@@ -34,14 +32,13 @@ def add_neighbours(nodes):
def extract_osm_nodes(f_name):
- global parser
parser = get_default_parser(f_name)
nodes = dict()
for node in parser.iter_nodes():
nodes[node['id']] = Node(node['id'], node['lat'], node['lon'])
- add_neighbours(nodes)
+ add_neighbours(nodes, parser)
# remove nodes without neighbours
for node_id, node in nodes.copy().items():