Mercurial Hosting > traffic-intelligence
diff python/moving.py @ 661:dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 18 May 2015 13:53:25 +0200 |
parents | 994dd644f6ab |
children | 72174e66aba5 |
line wrap: on
line diff
--- a/python/moving.py Fri May 15 23:09:49 2015 +0200 +++ b/python/moving.py Mon May 18 13:53:25 2015 +0200 @@ -986,7 +986,7 @@ self.velocities = velocities self.geometry = geometry self.userType = userType - self.features = [] + self.features = None # compute bounding polygon from trajectory @staticmethod @@ -1105,6 +1105,18 @@ def setFeatures(self, features): self.features = [features[i] for i in self.featureNumbers] + def getFeatures(self): + return self.features + + def hasFeatures(self): + return (self.features is not None) + + def getFeature(self, i): + if self.hasFeatures() and i<len(self.features): + return self.features[i] + else: + return None + def getSpeeds(self): return self.getVelocities().norm() @@ -1131,8 +1143,8 @@ return self.positions.getYCoordinates() def plot(self, options = '', withOrigin = False, timeStep = 1, withFeatures = False, **kwargs): - if withFeatures: - for f in self.features: + if withFeatures and self.hasFeatures(): + for f in self.getFeatures(): f.positions.plot('r', True, timeStep, **kwargs) self.positions.plot('bx-', True, timeStep, **kwargs) else: