Beispiel #1
0
def PathTestMashUp(startPt, endPt, runDis, ):

    startCor = GeoCode(startPt);
    endCor = GeoCode(endPt)
    
    miniGraph = Graph()
    bounds = createMiniWorld(miniGraph, startCor, endCor)
    
    startNode = [0, 0]
    dist = miniGraph.findNearestNode(startCor, startNode)
    print 'the closest node found to startPt is '+ str(startNode) +', with dist '+str(dist)
    endNode = [0, 0]
    dist = miniGraph.findNearestNode(endCor, endNode)
    print 'the closest node found to endPt is '+str(endNode) +', with dist '+str(dist)
    
    startNode = cor2ID(startNode)
    endNode = cor2ID(endNode)
    K=5
    pathDict = miniGraph.findPath(startNode, endNode, runDis, K)
    for k in range(0, K):
        print 'The actual path dis is '+ str(pathDict[k]['cost'])
        #print pathDict[k]['path']
    return {'miniGraph': miniGraph, 
            'startPt':startCor, 
            'endPt':endCor, 
            'startNode':startNode,
            'endNode':endNode,
            'pathDict':pathDict}
Beispiel #2
0
def PathTestMashUp(startPt, endPt, targetDis):

    startCor = GeoCode(startPt);
    endCor = GeoCode(endPt)
    
    miniGraph = Graph()
    bounds = createMiniWorld(miniGraph, startCor, endCor)
    
    startNode = [0, 0]
    dist = miniGraph.findNearestNode(startCor, startNode)
    print 'the closest node found to startPt is '+ str(startNode) +', with dist '+str(dist)
    endNode = [0, 0]
    dist = miniGraph.findNearestNode(endCor, endNode)
    print 'the closest node found to endPt is '+str(endNode) +', with dist '+str(dist)
    
    startNode = cor2ID(startNode)
    endNode = cor2ID(endNode)
   
    myPath = miniGraph.MonteCarloBestPath(startNode, endNode, targetDis)
    
    print 'The actual path dis is '+ str(myPath['dist'])
    return {'miniGraph': miniGraph, 
            'startPt':startCor, 
            'endPt':endCor, 
            'startNode':startNode,
            'endNode':endNode,
            'dist': myPath['dist'],
            'path': myPath['path']}