def generateThreePaths(self) : self.hasAnotherPath = True self.hasTwoPaths = True self.hasThreePaths = True self.pathFind.setMap(self.startBuilding, self.startLevel) conList1 = self.comMap[self.mapNumber].getNodeID() # append 2nd map self.comMap.append(mapParser()) self.comMap[self.mapNumber + 1].setMap(self.midBuilding, self.midLevel) conList2 = self.comMap[self.mapNumber + 1].getNodeID() # append 3rd map self.comMap.append(mapParser()) self.comMap[self.mapNumber + 2].setMap(self.endBuilding, self.endLevel) conList3 = self.comMap[self.mapNumber + 2].getNodeID() midEnd1, midStart1, self.hasStairs1 = self.getBuildingConnection(conList1, conList2) midEnd2, midStart2, self.hasStairs2 = self.getBuildingConnection(conList2, conList3) if (midEnd1 != 9999 and midStart1 != 9999) : self.pathList = self.pathFind.getPath(self.startLocation, midEnd1) self.pathFind.setMap(self.midBuilding, self.midLevel) self.pathList2 = self.pathFind.getPath(midStart1, midEnd2) self.pathFind.setMap(self.endBuilding, self.endLevel) self.pathList3 = self.pathFind.getPath(midStart2, self.endLocation)
def generateFullPath(self, startBuilding, startLevel, start, endBuilding, endLevel, end) : self.mapNumber = 0 self.pathListIndex = 0 self.comMap.append(mapParser()) self.comMap[self.mapNumber].setMap(startBuilding, startLevel) self.startBuilding = startBuilding self.startLevel = startLevel self.endBuilding = endBuilding self.endLevel = endLevel self.startLocation = start - 1 self.endLocation = end - 1 if((startBuilding == endBuilding) and (startLevel == endLevel)) : self.generateOnePath() elif ((startBuilding != endBuilding) and (startLevel != endLevel)) : self.midBuilding = "com2" self.midLevel = "2" self.generateThreePaths() else : self.generateTwoPaths() # print pathlists print "[", for i in self.pathList : print str(i+1) + ", ", print "]" print "[", for i in self.pathList2 : print str(i+1) + ", ", print "]" print "[", for i in self.pathList3 : print str(i+1) + ", ", print "]" self.northAt = 0 self.curMapNorth = self.comMap[self.mapNumber].getNorthAt() if (len(self.pathList) == 1) : self.alertNodeReached() return self.updatePrevNexCoord() self.provideNexNodeDirections()
def setMap(self, buildingName, levelNumber): self.currMap = mapParser() self.currMap.setMap(buildingName, levelNumber) self.NUM_NODES = self.currMap.numElements
import jsonParsing building = raw_input("Enter building name or number: ") level = raw_input("Enter level: ") maps = jsonParsing.mapParser() maps.setMap(building, level) print "distance is: " + str(maps.getDistance(0, 15)) maps.printMatrix() print "********************************************************************" maps.setMap(2, 3) maps.printMatrix() print "distance is: " + str(maps.getDistance(0, 15)) ##for i in range(maps.numElements): ## print maps.getLocationName(i) ##x = raw_input("Enter x: "); ##y = raw_input("Enter y: "); ## ##conList = maps.getNodeID() ## ##print conList