Mercurial Hosting > traffic-intelligence
diff python/moving.py @ 619:dc2d0a0d7fe1
merged code from Mohamed Gomaa Mohamed for the use of points of interests in mation pattern learning and motion prediction (TRB 2015)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 10 Dec 2014 15:27:08 -0500 |
parents | 04a8304e13f0 0791b3b55b8f |
children | 582508610572 |
line wrap: on
line diff
--- a/python/moving.py Sun Dec 07 23:01:02 2014 -0500 +++ b/python/moving.py Wed Dec 10 15:27:08 2014 -0500 @@ -795,7 +795,7 @@ return False def wiggliness(self): - return self.cumulatedDisplacement()/float(Point.distanceNorm2(self.__getitem__(0),self.__getitem__(self.length()-1))) + return self.getCumulativeDistance(self.length()-1)/float(Point.distanceNorm2(self.__getitem__(0),self.__getitem__(self.length()-1))) def getIntersections(self, p1, p2): '''Returns a list of the indices at which the trajectory @@ -1068,7 +1068,7 @@ else: print('Load features to compute a maximum size') return None - + def setRoutes(self, startRouteID, endRouteID): self.startRouteID = startRouteID self.endRouteID = endRouteID @@ -1165,7 +1165,10 @@ def classifyUserTypeSpeedMotorized(self, threshold, aggregationFunc = median, ignoreNInstantsAtEnds = 0): '''Classifies slow and fast road users slow: non-motorized -> pedestrians - fast: motorized -> cars''' + fast: motorized -> cars + + aggregationFunc can be any function that can be applied to a vector of speeds, including percentile: + aggregationFunc = lambda x: percentile(x, percentileFactor) # where percentileFactor is 85 for 85th percentile''' if ignoreNInstantsAtEnds > 0: speeds = self.getSpeeds()[ignoreNInstantsAtEnds:-ignoreNInstantsAtEnds] else: