comparison python/storage.py @ 759:a05b70f307dd dev

added function to count vehicles per VISSIM link
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 04 Nov 2015 17:12:06 -0500
parents a73f43aac00e
children f8e0a8ea8402
comparison
equal deleted inserted replaced
757:61248f2cd459 759:a05b70f307dd
759 cursor.execute(queryStatement) 759 cursor.execute(queryStatement)
760 return [row[0] for row in cursor] 760 return [row[0] for row in cursor]
761 except sqlite3.OperationalError as error: 761 except sqlite3.OperationalError as error:
762 printDBError(error) 762 printDBError(error)
763 763
764 def getNObjectsInLinkFromVissimFile(filename, linkIds):
765 '''Returns the number of objects that traveled through the link ids'''
766 connection = sqlite3.connect(filename)
767 cursor = connection.cursor()
768 queryStatement = 'SELECT link_id, COUNT(DISTINCT trajectory_id) FROM curvilinear_positions where link_id IN ('+','.join([str(id) for id in linkIds])+') GROUP BY link_id'
769 try:
770 cursor.execute(queryStatement)
771 return {row[0]:row[1] for row in cursor}
772 except sqlite3.OperationalError as error:
773 printDBError(error)
764 774
765 def loadTrajectoriesFromVissimFile(filename, simulationStepsPerTimeUnit, objectNumbers = None, warmUpLastInstant = None, usePandas = False, nDecimals = 2, lowMemory = True): 775 def loadTrajectoriesFromVissimFile(filename, simulationStepsPerTimeUnit, objectNumbers = None, warmUpLastInstant = None, usePandas = False, nDecimals = 2, lowMemory = True):
766 '''Reads data from VISSIM .fzp trajectory file 776 '''Reads data from VISSIM .fzp trajectory file
767 simulationStepsPerTimeUnit is the number of simulation steps per unit of time used by VISSIM (second) 777 simulationStepsPerTimeUnit is the number of simulation steps per unit of time used by VISSIM (second)
768 for example, there seems to be 10 simulation steps per simulated second in VISSIM, 778 for example, there seems to be 10 simulation steps per simulated second in VISSIM,