changeset 527:37830a831818

loading from VISSIM trajectory data works
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sat, 21 Jun 2014 14:46:20 -0400
parents 21bdeb29f855
children 5585ebd8ad61
files python/moving.py python/storage.py
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/python/moving.py	Fri Jun 20 17:45:32 2014 -0400
+++ b/python/moving.py	Sat Jun 21 14:46:20 2014 -0400
@@ -673,7 +673,7 @@
         for i in xrange(self.length()-1):
             q1=self.__getitem__(i)
             q2=self.__getitem__(i+1)
-            if q1[0] <= S1 <= q2[0] and lane == None or (self.lanes[i] == lane and self.lanes[i+1] == lane):
+            if q1[0] <= S1 < q2[0] and (lane == None or (self.lanes[i] == lane and self.lanes[i+1] == lane)):
                 indices.append(i+(S1-q1[0])/(q2[0]-q1[0]))
         return indices
 
--- a/python/storage.py	Fri Jun 20 17:45:32 2014 -0400
+++ b/python/storage.py	Sat Jun 21 14:46:20 2014 -0400
@@ -419,8 +419,12 @@
             finally: self.sechead = None
         else: return self.fp.readline()
 
-def loadTrajectoriesFromVissimFile(filename, simulationStepsPerTimeUnit, nObjects = -1, sequenceNum = -1):
+def loadTrajectoriesFromVissimFile(filename, simulationStepsPerTimeUnit, nObjects = -1):
     '''Reads data from VISSIM .fzp trajectory file
+    simulationStepsPerTimeUnit is the number of simulation steps per unit of time used by VISSIM
+    for example, there seems to be 5 simulation steps per simulated second in VISSIM, 
+    so simulationStepsPerTimeUnit should be 5, 
+    so that all times correspond to the number of the simulation step (and can be stored as integers)
 
     Assumed to be sorted over time'''
     objects = {} # dictionary of objects index by their id
@@ -438,7 +442,7 @@
         instant = int(float(data[0])*simulationStepsPerTimeUnit)
         s = float(data[4])
         y = float(data[5])
-        lane = int(data[3])
+        lane = data[2]+'_'+data[3]
         if objNum not in objects:
             objects[objNum] = moving.MovingObject(num = objNum, timeInterval = moving.TimeInterval(instant, instant))
             objects[objNum].curvilinearPositions = moving.CurvilinearTrajectory()