当前位置: 首页>>代码示例>>Python>>正文


Python Reader.readVLS_Edges方法代码示例

本文整理汇总了Python中util.Reader.readVLS_Edges方法的典型用法代码示例。如果您正苦于以下问题:Python Reader.readVLS_Edges方法的具体用法?Python Reader.readVLS_Edges怎么用?Python Reader.readVLS_Edges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在util.Reader的用法示例。


在下文中一共展示了Reader.readVLS_Edges方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: readFCD

# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readVLS_Edges [as 别名]
def readFCD():
    """Reads the FCD and creates a list of Taxis and for each a list of routes"""
    vlsEdges = reader.readVLS_Edges()

    inputFile = open(path.fcd, 'r')
    for line in inputFile:
        words = line.split("\t")
        # add route
        taxiId = getTaxiId(words[4])
        actTime = getTimeInSecs(words[0])
        if taxiId in taxis:
            prevTime = routes[taxis.index(taxiId)][-1][0]
            # check if time lies not to far away from each other
            if words[1] in vlsEdges and (actTime - prevTime) < 180:
                routes[taxis.index(taxiId)].append((actTime, words[1]))
            # if time diff >3min add a new taxiId and start a new route
            elif words[1] in vlsEdges:
                taxiIdDict[words[4]] += 1  # create new taxiId
                taxis.append(getTaxiId(words[4]))  # append new created id
                # append new list (list will be filled with edges)
                routes.append([(actTime, words[1])])
            else:
                taxiIdDict[words[4]] += 1
        # if the edge is in the VLS-Area a new route is created
        elif words[1] in vlsEdges:
            taxis.append(taxiId)
            #                 departTime
            routes.append([(actTime, words[1])])

    inputFile.close()
    print len(taxis)
开发者ID:RamonHPSilveira,项目名称:urbansim,代码行数:33,代码来源:GenerateTaxiRoutes.py

示例2: readFCDCompleteOLD

# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readVLS_Edges [as 别名]
def readFCDCompleteOLD(fcdPath):
    """Reads the FCD-File and creates a list of Id's with a belonging List of Data tuples."""
    # reset all
    global taxis, routes, vlsEdges, taxiIdDict, fcdDict
    taxis = []
    routes = []
    vlsEdges = []
    taxiIdDict = {}
    fcdDict = {}

    vlsEdges = reader.readVLS_Edges()

    inputFile = open(fcdPath, 'r')
    for line in inputFile:
        words = line.split("\t")
        # add route
        taxiId = getTaxiId(words[4])
        if taxiId in taxis:
            if words[1] in vlsEdges:
                # routes[taxis.index(taxiId)].append(words[1])
                fcdDict[taxiId].append(
                    (getTimeInSecs(words[0]), words[1], words[2]))
            else:
                taxiIdDict[words[4]] += 1
        # if the edge is in the VLS-Area a new route is created
        elif words[1] in vlsEdges:
            taxis.append(taxiId)
            #                 departTime
            # routes.append([(int)(mktime(strptime(words[0],format))-simDate),words[1]])
            fcdDict[taxiId] = [(getTimeInSecs(words[0]), words[1], words[2])]

    inputFile.close()
    return fcdDict
开发者ID:RamonHPSilveira,项目名称:urbansim,代码行数:35,代码来源:GenerateTaxiRoutes.py

示例3: generateVLS_FCD_File

# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readVLS_Edges [as 别名]
def generateVLS_FCD_File():
    """Creates a new FCD-file which contains only the rows which edges belongs to the VLS-Area"""
    outputVLSFile = open(path.vls, 'w')
    inputFile = open(path.fcd, 'r')

    vlsEdgeList = reader.readVLS_Edges()

    for line in inputFile:
        words = line.split("\t")
        # check if edge belongs to the VLS-Area
        if words[1] in vlsEdgeList:
            outputVLSFile.write(line)
    inputFile.close()
    outputVLSFile.close()
开发者ID:fieryzig,项目名称:sumo,代码行数:16,代码来源:SeparateVLSArea.py

示例4: readFCDComplete

# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readVLS_Edges [as 别名]
def readFCDComplete(fcdPath):
    """Reads the FCD and creates a list of Taxis and for each a list of routes"""
    # reset all
    global taxis, routes, vlsEdges, taxiIdDict, fcdDict
    taxis = []
    routes = []
    vlsEdges = []
    taxiIdDict = {}
    fcdDict = {}

    vlsEdges = reader.readVLS_Edges()

    inputFile = open(path.fcd, 'r')
    for line in inputFile:
        words = line.split("\t")
        # add route
        taxiId = getTaxiId(words[4])
        actTime = getTimeInSecs(words[0])

        if taxiId in taxis:
            # prevTime=routes[taxis.index(taxiId)][-1][0]
            prevTime = fcdDict[taxiId][-1][0]
            # check if time lies not to far away from each other
            if words[1] in vlsEdges and (actTime - prevTime) < 180:
                #routes[taxis.index(taxiId)].append((actTime, words[1]))
                fcdDict[taxiId].append((actTime, words[1], words[2]))
            # if time diff >3min add a new taxiId and start a new route
            elif words[1] in vlsEdges:
                taxiIdDict[words[4]] += 1  # create new taxiId
                taxis.append(getTaxiId(words[4]))  # append new created id
                # append new list (list will be filled with edges)
                fcdDict[getTaxiId(words[4])] = [(actTime, words[1], words[2])]
            else:
                taxiIdDict[words[4]] += 1
        # if the edge is in the VLS-Area a new route is created
        elif words[1] in vlsEdges:
            taxis.append(taxiId)
            #                 departTime
            # routes.append([(actTime,words[1])])
            fcdDict[taxiId] = [(actTime, words[1], words[2])]
    inputFile.close()
    return fcdDict
开发者ID:RamonHPSilveira,项目名称:urbansim,代码行数:44,代码来源:GenerateTaxiRoutes.py

示例5: readFCDOLD

# 需要导入模块: from util import Reader [as 别名]
# 或者: from util.Reader import readVLS_Edges [as 别名]
def readFCDOLD(): 
    """Reads the FCD and creates a list of Taxis and for each a list of routes"""
    vlsEdges=reader.readVLS_Edges()
       
    inputFile=open(path.fcd,'r')
    for line in inputFile:
        words= line.split("\t")
        #add route
        taxiId=getTaxiId(words[4])              
        if taxiId in taxis:           
            if words[1] in vlsEdges:
                routes[taxis.index(taxiId)].append(words[1])
            else:
                taxiIdDict[words[4]]+=1                
        elif words[1] in vlsEdges: #if the edge is in the VLS-Area a new route is created 
            taxis.append(taxiId)
            #                 departTime               
            routes.append([getTimeInSecs(words[0]),words[1]])
           
    inputFile.close() 
    print len(taxis) 
开发者ID:harora,项目名称:ITS,代码行数:23,代码来源:GenerateTaxiRoutes.py


注:本文中的util.Reader.readVLS_Edges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。