changeset 1306:4bc0651d91f9 default tip

bug corrected generating last velocity twice and saving it (not saved, duplicated at loading time
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 30 Mar 2026 15:31:34 -0400
parents 9c1870244adf
children
files scripts/dltrack.py trafficintelligence/moving.py
diffstat 2 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/dltrack.py	Mon Jan 26 16:33:26 2026 -0500
+++ b/scripts/dltrack.py	Mon Mar 30 15:31:34 2026 -0400
@@ -258,7 +258,7 @@
     feature = moving.MovingObject(featureNum, obj.getTimeInterval(), moving.Trajectory(projected.tolist()))
     if smoothingHalfWidth is not None: # smoothing
         feature.smoothPositions(smoothingHalfWidth, replace = True)#f.positions = f.getPositions().filterMovingWindow(smoothingHalfWidth)
-    feature.computeVelocities()
+    feature.computeVelocities(duplicateLastVelocity = False)
     obj.features=[feature]
     obj.featureNumbers = [featureNum]
 #saving
--- a/trafficintelligence/moving.py	Mon Jan 26 16:33:26 2026 -0500
+++ b/trafficintelligence/moving.py	Mon Mar 30 15:31:34 2026 -0400
@@ -1748,13 +1748,14 @@
         else:
             return speeds
 
-    def computeVelocities(self, halfWidth = None):
+    def computeVelocities(self, halfWidth = None, duplicateLastVelocity = True):
         '''compute velocities, smoothed if halfwidth is not None '''        
         if halfWidth is None:
             self.velocities = self.getPositions().differentiate(True)
         else:
             self.velocities = self.getPositions().differentiate().filterMovingWindow(halfWidth)
-        self.velocities.addPosition(self.velocities[-1])
+        if duplicateLastVelocity:
+            self.velocities.addPosition(self.velocities[-1])
         
     def smoothPositions(self, halfWidth, replace = False):
         'Returns the smoothed positions (or replaces them)'