示例#1
0
    
    #mm.saveGraph("/Users/bsnizek/Projects/Mapmatching/pymapmatching/testdata/Network.yaml")
    #print "Graph saved"
    
    mm.readGPS(BASE_PATH + "GPS_Points.shp")
    
    # max_distance = mm.maxGPSDistance()

    if NETWORK_ELIMINATION:    
        max_distance = 300

        print "The maximum distance between 2 adjacent GPS points is %d" % max_distance
        mm.eliminiateEmptyEdges(distance = max_distance + 0.5)
    
        gts = GraphToShape(mm.G)
        gts.dump(BASE_PATH + "Sparse_bigger0.shp",
                 original_coverage = BASE_PATH + "Network.shp")    
    
    mm.nearPoints()
    print "Near points executed"

    ##selected_label = mm.findRoute(returnNonSelection=False)

    selected_route = mm.findRoutes2()

    print selected_route

    if selected_route:

        if (type(selected_route) == tuple):
            selected_route[0].saveAsShapeFile(BASE_PATH + "SelectedRoute.shp")
            non_selected_counter = 0
    
    #mm.saveGraph("/Users/bsnizek/Projects/Mapmatching/pymapmatching/testdata/Network.yaml")
    #print "Graph saved"
    
    mm.readGPS("/Users/bsnizek/Projects/Mapmatching/pymapmatching/testdata/GPS_Points.shp")
    
    # max_distance = mm.maxGPSDistance()

    if NETWORK_ELIMINATION:    
        max_distance = 300

        print "The maximum distance between 2 adjacent GPS points is %d" % max_distance
        mm.eliminiateEmptyEdges(distance = max_distance + 0.5)
    
        gts = GraphToShape(mm.G)
        gts.dump("/Users/bsnizek/Projects/Mapmatching/pymapmatching/testdata/SparseNetwork.shp",
                 original_coverage = "/Users/bsnizek/Projects/Mapmatching/pymapmatching/testdata/Network.shp")    
    
    mm.nearPoints()
    print "Near points executed"

    selected_label = mm.findRoute(returnNonSelection=False)

    print selected_label

    if selected_label:

        if (type(selected_label) == tuple):
            selected_label[0].saveAsShapeFile("/Users/bsnizek/Projects/Mapmatching/pymapmatching/testdata/SelectedRoute.shp")
            non_selected_counter = 0
            for non_selected in selected_label[1]:
                non_selected.saveAsShapeFile("/Users/bsnizek/Projects/Mapmatching/pymapmatching/testdata/Nonselected-" + non_selected_counter + ".shp")