コード例 #1
0
ファイル: gtfs2pt.py プロジェクト: YanyueMa/sumo
def traceMap(options, typedNets):
    routes = defaultdict(list)
    for railType in typedNets.keys():
        net = sumolib.net.readNet(os.path.join(options.network_split, railType + ".net.xml"))
        traces = tracemapper.readFCD(os.path.join(options.fcd, railType + ".fcd.xml"), net, True)
        for tid, trace in traces:
            routes[tid] = [e.getID() for e in sumolib.route.mapTrace(trace, net, 100)]
    return routes
コード例 #2
0
def traceMap(options, typedNets, radius=100):
    routes = defaultdict(list)
    for railType in typedNets.keys():
        if options.verbose:
            print("mapping", railType)
        net = sumolib.net.readNet(os.path.join(options.network_split, railType + ".net.xml"))
        netBox = net.getBBoxXY()
        traces = tracemapper.readFCD(os.path.join(options.fcd, railType + ".fcd.xml"), net, True)
        for tid, trace in traces:
            minX, minY, maxX, maxY = sumolib.geomhelper.addToBoundingBox(trace)
            if (minX < netBox[1][0] + radius and minY < netBox[1][1] + radius and
                maxX > netBox[0][0] - radius and maxY > netBox[0][1] - radius):
                mappedRoute = sumolib.route.mapTrace(trace, net, radius)
                if mappedRoute:
                    routes[tid] = [e.getID() for e in mappedRoute]
    return routes