Mercurial > hg > nsaunier > traffic-intelligence
diff trafficintelligence/moving.py @ 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 | f3574e43c238 |
| children |
line wrap: on
line diff
--- 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)'
