# HG changeset patch # User Nicolas Saunier # Date 1774899094 14400 # Node ID 4bc0651d91f9fe628cd46c4c75e00c499943c1b1 # Parent 9c1870244adf2212d53dbb829cdc5a52d5f299b5 bug corrected generating last velocity twice and saving it (not saved, duplicated at loading time diff -r 9c1870244adf -r 4bc0651d91f9 scripts/dltrack.py --- 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 diff -r 9c1870244adf -r 4bc0651d91f9 trafficintelligence/moving.py --- 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)'