forked from gongzhenmu/GISDatabase-Simulation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataClean.py
More file actions
39 lines (29 loc) · 1022 Bytes
/
Copy pathDataClean.py
File metadata and controls
39 lines (29 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import osmium
import sys
class NamesHandler(osmium.SimpleHandler):
def __init__(self):
super(NamesHandler, self).__init__()
self.nodes = {}
self.ways = {}
self.relations = {}
def node(self, n):
location = str(n.location).split("/")
self.nodes[n.id] = {'lat':float(location[0]),'lon':float(location[1]),'tags':str(n.tags)}
def way(self,w):
mylist = [int(str(i).split("@")[0]) for i in w.nodes]
self.ways[w.id] = {'nodes':mylist,'tags':str(w.tags)}
def relation(self,r):
mylist = []
for i in r.members:
id = str(i).split("@")[0]
myTuple = (id[0],int(id[1:]))
mylist.append(myTuple)
self.relations[r.id] = {'members':mylist, 'tags':str(r.tags)}
x = NamesHandler()
x.apply_file('/content/drive/MyDrive/CS541Project/map.xml', locations=True)
for key,item in x.nodes.items():
print(key,item)
for key,item in x.ways.items():
print(key,item)
for key,item in x.relations.items():
print(key,item)