-
Notifications
You must be signed in to change notification settings - Fork 2
/
process.py
50 lines (43 loc) · 1.26 KB
/
process.py
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
40
41
42
43
44
45
46
47
48
49
50
from calc import pathFinder_Threaded
from calc import edgeBuilder
from parsers import osm
from parsers import BuildingList
from viewer import NodeCollection,Node
import json
"""
This script does all of the cache-prep work for the web-tier to speed up requests.
Run it, and look at docs/Data Import.md to see how to deploy.
"""
#113 496
# 18 468
#x=BuildingList()
#
#cdebldn={}
#
#for code,building in x.buildings.items():
# cdebldn[code]=building
#
nC=NodeCollection()
nC.load("out.nodecollection")
#OSM=osm("mapdata-whole.xml",nC) #Whole campus. Letsdothisthing.
#
#OSM.runAll(x.buildings)
#eB=edgeBuilder(nC)
#eB.build()
#nC.dedupe()
#nC.save("out.nodecollection")
nds=open("nodes.sql","w")
ndsR=open("nodes.redis","w")
bldR=open("buildings.redis","w")
for nodeID,node in nC.vertices.items():
node.name=node.name.replace("'","")
if nodeID.find("b-") != -1:
bldR.write("SET 'building:"+nodeID.split("-")[1]+"' '"+node.name+"'\n")
nds.write("INSERT INTO nodes (id,name,lat,long) VALUES ('"+nodeID+"','"+node.name+"',"+str(node.x)+","+str(node.y)+");\n")#
ndsR.write("SET 'nodes:"+nodeID+"' '"+str(node.x)+","+str(node.y)+","+node.name+"'\n")
bldR.close()
nds.close()
ndsR.close()
##Only run if absolutely needed... Takes a very long time
#pF=pathFinder_Threaded(nC)
#pF.build()