def main(): nodes=NodeCollection() nodes.load() viewer=Viewer(nodes) viewer.run()
class NodeCollectionTestMethods(unittest.TestCase): def setUp(self): self.source=NodeCollection() for i in range(50): self.source.addNode(i,random.randint(20,800-20),random.randint(20,600-20)) for i in range(3): self.source.addEdge(random.randint(0,49),random.randint(0,49),1) def tearDown(self): try: os.remove("tests/nodecollection_temp.txt") except: #file not found pass def testEdgeLengthSymmetry(self): """checks that if an edge exists from A->B, a path of equal length exists from B->A""" for ID,vertex in self.source.vertices.iteritems(): for otherVertex in vertex.adjacent: self.source[otherVertex].adjacent[ID] self.assertEqual(vertex.adjacent[otherVertex], self.source[otherVertex].adjacent[ID]) def testSavingPreservesN(self): """Checks """ self.source.save("tests/nodecollection_temp.txt") copy=NodeCollection() copy.load("tests/nodecollection_temp.txt") self.assertEqual(len(self.source.vertices),len(copy.vertices)) self.assertEqual(len(self.source.edges),len(copy.edges)) for node in copy.vertices: for otherNode in copy[node].adjacent.keys(): self.assertTrue(otherNode in self.source[node].adjacent) def testSavingPreservesStringForm(self): """Tests that the save file of a copy is identical to the save file that it was loaded from.""" self.source.save("tests/nodecollection_temp.txt") copy=NodeCollection() copy.load("tests/nodecollection_temp.txt") self.assertEqual(self.source.getSaveString(), copy.getSaveString()) def testSavingPreservesSingleNode(self): self.source=NodeCollection() self.source.addNode(1,2,3,name="asdfasdn") self.source.save("tests/nodecollection_temp.txt") self.source.load("tests/nodecollection_temp.txt") self.assertEqual(self.source.vertices["1"].id,"1") self.assertEqual(self.source.vertices["1"].x,2.) self.assertEqual(self.source.vertices["1"].y,3.) self.assertEqual(self.source.vertices["1"].adjacent,{})
def testSavingPreservesN(self): """Checks """ self.source.save("tests/nodecollection_temp.txt") copy=NodeCollection() copy.load("tests/nodecollection_temp.txt") self.assertEqual(len(self.source.vertices),len(copy.vertices)) self.assertEqual(len(self.source.edges),len(copy.edges)) for node in copy.vertices: for otherNode in copy[node].adjacent.keys(): self.assertTrue(otherNode in self.source[node].adjacent)
def main(): nodes = NodeCollection() nodes.load() viewer = Viewer(nodes) viewer.run()
""" #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")#
from jinja2 import Environment, PackageLoader from viewer import NodeCollection, Node from services import Paths import web """ beep,boop, please ignore. """ pt = Paths() env = Environment(loader=PackageLoader('html', '')) template = env.get_template('maptest.html') nC = NodeCollection() nC.load() xs = [] pth = [] for el in pt.getPath("2016012246", "b-Engineering 3"): pth.append([nC[el].x, nC[el].y]) xs.append(nC[el]) print template.render(vertices=xs, path=pth)
def testSavingPreservesStringForm(self): """Tests that the save file of a copy is identical to the save file that it was loaded from.""" self.source.save("tests/nodecollection_temp.txt") copy=NodeCollection() copy.load("tests/nodecollection_temp.txt") self.assertEqual(self.source.getSaveString(), copy.getSaveString())
from jinja2 import Environment, PackageLoader from viewer import NodeCollection, Node from services import Paths import web """ beep,boop, please ignore. """ pt = Paths() env = Environment(loader=PackageLoader("html", "")) template = env.get_template("maptest.html") nC = NodeCollection() nC.load() xs = [] pth = [] for el in pt.getPath("2016012246", "b-Engineering 3"): pth.append([nC[el].x, nC[el].y]) xs.append(nC[el]) print template.render(vertices=xs, path=pth)