comparison trafficintelligence/moving.py @ 1289:86122f5fe500

correction
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sun, 21 Jul 2024 23:00:06 -0400
parents 76f5693b530c
children 9012fb72d79a
comparison
equal deleted inserted replaced
1288:96c7cfbdd226 1289:86122f5fe500
1849 return self.positions.getYCoordinates() 1849 return self.positions.getYCoordinates()
1850 1850
1851 def isStationary(self, speedThreshold, distanceThreshold): 1851 def isStationary(self, speedThreshold, distanceThreshold):
1852 '''Indicates if object is not moving 1852 '''Indicates if object is not moving
1853 if speed on average below threshold and final-initial position close enough 1853 if speed on average below threshold and final-initial position close enough
1854 or the largest time interval during which the object is stationary (same condition)''' 1854 or the largest interval [t1, t2] during which the object is stationary (same condition)
1855
1856 Returns time instants'''
1855 speeds = self.getSpeeds() 1857 speeds = self.getSpeeds()
1856 if quantile(speeds, 0.5) <= speedThreshold and Point.distanceNorm2(self.getPositionAt(0),self.getPositionAt(-1)) <= distanceThreshold: 1858 if quantile(speeds, 0.5) <= speedThreshold and Point.distanceNorm2(self.getPositionAt(0),self.getPositionAt(-1)) <= distanceThreshold:
1857 return True, None 1859 return True, None
1858 else: 1860 else:
1859 indices = flatnonzero(speeds < speedThreshold).tolist() 1861 indices = flatnonzero(speeds < speedThreshold).tolist()
1866 i+=1 1868 i+=1
1867 #else: 1869 #else:
1868 j-=1 1870 j-=1
1869 #incrementI = not incrementI 1871 #incrementI = not incrementI
1870 if i<j: # we found a smaller subset 1872 if i<j: # we found a smaller subset
1871 return True, [indices[i], indices[j]] 1873 firstInstant = self.getFirstInstant()
1874 return True, [indices[i]+firstInstant, indices[j]+firstInstant]
1872 else: 1875 else:
1873 return False, None 1876 return False, None
1874 else: 1877 else:
1875 return False, None 1878 return False, None
1876 1879