Mercurial Hosting > traffic-intelligence
comparison python/storage.py @ 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 |
comparison
equal
deleted
inserted
replaced
753:3d48e34db846 | 754:782e8fd3672c |
---|---|
746 from subprocess import check_call | 746 from subprocess import check_call |
747 out = openCheck("err.log", "w") | 747 out = openCheck("err.log", "w") |
748 check_call("sqlite3 "+utils.removeExtension(filename)+".sqlite < "+sqlScriptFilename, stderr = out, shell = True) | 748 check_call("sqlite3 "+utils.removeExtension(filename)+".sqlite < "+sqlScriptFilename, stderr = out, shell = True) |
749 out.close() | 749 out.close() |
750 shutil.os.remove(sqlScriptFilename) | 750 shutil.os.remove(sqlScriptFilename) |
751 | |
752 def loadObjectNumbersInLinkFromVissimFile(filename, linkIds): | |
753 '''Finds the ids of the objects that go through any of the link in the list linkIds''' | |
754 connection = sqlite3.connect(filename) | |
755 cursor = connection.cursor() | |
756 queryStatement = 'SELECT DISTINCT trajectory_id FROM curvilinear_positions where link_id IN ('+','.join([str(id) for id in linkIds])+')' | |
757 try: | |
758 cursor.execute(queryStatement) | |
759 return [row[0] for row in cursor] | |
760 except sqlite3.OperationalError as error: | |
761 printDBError(error) | |
762 | |
751 | 763 |
752 def loadTrajectoriesFromVissimFile(filename, simulationStepsPerTimeUnit, objectNumbers = None, warmUpLastInstant = None, usePandas = False, nDecimals = 2, lowMemory = True): | 764 def loadTrajectoriesFromVissimFile(filename, simulationStepsPerTimeUnit, objectNumbers = None, warmUpLastInstant = None, usePandas = False, nDecimals = 2, lowMemory = True): |
753 '''Reads data from VISSIM .fzp trajectory file | 765 '''Reads data from VISSIM .fzp trajectory file |
754 simulationStepsPerTimeUnit is the number of simulation steps per unit of time used by VISSIM | 766 simulationStepsPerTimeUnit is the number of simulation steps per unit of time used by VISSIM |
755 for example, there seems to be 5 simulation steps per simulated second in VISSIM, | 767 for example, there seems to be 5 simulation steps per simulated second in VISSIM, |