# HG changeset patch # User Nicolas Saunier # Date 1446150683 14400 # Node ID 782e8fd3672cf4af6146b67cefc61680578017c8 # Parent 3d48e34db846a2082bea18de2eaa51cc9fc4b3b9 added function to find object ids going through some vissim links diff -r 3d48e34db846 -r 782e8fd3672c python/storage.py --- a/python/storage.py Thu Oct 29 14:29:31 2015 -0400 +++ b/python/storage.py Thu Oct 29 16:31:23 2015 -0400 @@ -749,6 +749,18 @@ out.close() shutil.os.remove(sqlScriptFilename) +def loadObjectNumbersInLinkFromVissimFile(filename, linkIds): + '''Finds the ids of the objects that go through any of the link in the list linkIds''' + connection = sqlite3.connect(filename) + cursor = connection.cursor() + queryStatement = 'SELECT DISTINCT trajectory_id FROM curvilinear_positions where link_id IN ('+','.join([str(id) for id in linkIds])+')' + try: + cursor.execute(queryStatement) + return [row[0] for row in cursor] + except sqlite3.OperationalError as error: + printDBError(error) + + def loadTrajectoriesFromVissimFile(filename, simulationStepsPerTimeUnit, objectNumbers = None, warmUpLastInstant = None, usePandas = False, nDecimals = 2, lowMemory = True): '''Reads data from VISSIM .fzp trajectory file simulationStepsPerTimeUnit is the number of simulation steps per unit of time used by VISSIM