comparison 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
comparison
equal deleted inserted replaced
660:994dd644f6ab 661:dc70d9e711f5
984 super(MovingObject, self).__init__(num, timeInterval) 984 super(MovingObject, self).__init__(num, timeInterval)
985 self.positions = positions 985 self.positions = positions
986 self.velocities = velocities 986 self.velocities = velocities
987 self.geometry = geometry 987 self.geometry = geometry
988 self.userType = userType 988 self.userType = userType
989 self.features = [] 989 self.features = None
990 # compute bounding polygon from trajectory 990 # compute bounding polygon from trajectory
991 991
992 @staticmethod 992 @staticmethod
993 def generate(p, v, timeInterval): 993 def generate(p, v, timeInterval):
994 positions, velocities = Trajectory.generate(p, v, int(timeInterval.length())) 994 positions, velocities = Trajectory.generate(p, v, int(timeInterval.length()))
1103 self.userType = userType 1103 self.userType = userType
1104 1104
1105 def setFeatures(self, features): 1105 def setFeatures(self, features):
1106 self.features = [features[i] for i in self.featureNumbers] 1106 self.features = [features[i] for i in self.featureNumbers]
1107 1107
1108 def getFeatures(self):
1109 return self.features
1110
1111 def hasFeatures(self):
1112 return (self.features is not None)
1113
1114 def getFeature(self, i):
1115 if self.hasFeatures() and i<len(self.features):
1116 return self.features[i]
1117 else:
1118 return None
1119
1108 def getSpeeds(self): 1120 def getSpeeds(self):
1109 return self.getVelocities().norm() 1121 return self.getVelocities().norm()
1110 1122
1111 def getSpeedIndicator(self): 1123 def getSpeedIndicator(self):
1112 from indicators import SeverityIndicator 1124 from indicators import SeverityIndicator
1129 1141
1130 def getYCoordinates(self): 1142 def getYCoordinates(self):
1131 return self.positions.getYCoordinates() 1143 return self.positions.getYCoordinates()
1132 1144
1133 def plot(self, options = '', withOrigin = False, timeStep = 1, withFeatures = False, **kwargs): 1145 def plot(self, options = '', withOrigin = False, timeStep = 1, withFeatures = False, **kwargs):
1134 if withFeatures: 1146 if withFeatures and self.hasFeatures():
1135 for f in self.features: 1147 for f in self.getFeatures():
1136 f.positions.plot('r', True, timeStep, **kwargs) 1148 f.positions.plot('r', True, timeStep, **kwargs)
1137 self.positions.plot('bx-', True, timeStep, **kwargs) 1149 self.positions.plot('bx-', True, timeStep, **kwargs)
1138 else: 1150 else:
1139 self.positions.plot(options, withOrigin, timeStep, **kwargs) 1151 self.positions.plot(options, withOrigin, timeStep, **kwargs)
1140 1152