Mercurial Hosting > traffic-intelligence
changeset 754:782e8fd3672c dev
added function to find object ids going through some vissim links
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 29 Oct 2015 16:31:23 -0400 |
parents | 3d48e34db846 |
children | f3aeb0b47eff |
files | python/storage.py |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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