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
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)
def readRawFCD(rawFcdPath, sim=False): """Reads the Raw-FCD-File and creates a list of Id's with a belonging List of Data tuples.""" rawDict={} inputFile=open(rawFcdPath,'r') inputFile.seek(30) for line in inputFile: words= line.split("\t") if sim: #id's of simulation raw data must be converted words[0]=getSimTaxiId(words[0]) if words[0] in rawDict: # Veh_ID time lat lon speed rawDict[words[0]].append((getTimeInSecs(words[1]), words[3], words[2], words[5][:-1])) else: # Veh_ID time lat lon speed rawDict[words[0]]=[(getTimeInSecs(words[1]),words[3], words[2], words[5][:-1])] inputFile.close() return rawDict
def readRawFCD(rawFcdPath, sim=False): """Reads the Raw-FCD-File and creates a list of Id's with a belonging List of Data tuples.""" rawDict = {} inputFile = open(rawFcdPath, 'r') inputFile.seek(30) for line in inputFile: words = line.split("\t") if sim: #id's of simulation raw data must be converted words[0] = getSimTaxiId(words[0]) if words[0] in rawDict: # Veh_ID time lat lon speed rawDict[words[0]].append( (getTimeInSecs(words[1]), words[3], words[2], words[5][:-1])) else: # Veh_ID time lat lon speed rawDict[words[0]] = [(getTimeInSecs(words[1]), words[3], words[2], words[5][:-1])] inputFile.close() return rawDict
def readSimFCDComplete(fcdPath): """Reads the FCD-File and creates a list of Id's with a belonging List of Data tuples. Uses the given taxiIds.""" #reset all global taxis, routes, vlsEdges, taxiIdDict, fcdDict taxis=[] routes=[] vlsEdges=[] taxiIdDict={} fcdDict={} inputFile=open(fcdPath,'r') for line in inputFile: words= line.split("\t") #add route taxiId=getSimTaxiId(words[4]) if taxiId in taxis: fcdDict[taxiId].append((getTimeInSecs(getNiceTimeLabel(words[0])),words[1],words[2])) else: taxis.append(taxiId) fcdDict[taxiId]=[(getTimeInSecs(getNiceTimeLabel(words[0])),words[1],words[2])] inputFile.close() return fcdDict
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] if words[1] in vlsEdges and ( actTime - prevTime ) < 180: #check if time lies not to far away from each other #routes[taxis.index(taxiId)].append((actTime, words[1])) fcdDict[taxiId].append((actTime, words[1], words[2])) elif words[ 1] in vlsEdges: #if time diff >3min add a new taxiId and start a new route taxiIdDict[words[4]] += 1 #create new taxiId taxis.append(getTaxiId(words[4])) #append new created id fcdDict[getTaxiId(words[4])] = [ (actTime, words[1], words[2]) ] #append new list (list will be filled with edges) 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([(actTime,words[1])]) fcdDict[taxiId] = [(actTime, words[1], words[2])] inputFile.close() return fcdDict
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
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)