comparison python/moving.py @ 62:290fceb125d2

moved road user types and added plotting for all road users
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 04 Nov 2010 17:40:07 -0400
parents 40e1508380ed
children c75bcdaed00f
comparison
equal deleted inserted replaced
61:a8c6d544f015 62:290fceb125d2
244 244
245 def getTrajectoryInPolygon(self, polygon): 245 def getTrajectoryInPolygon(self, polygon):
246 'Returns the set of points inside the polygon' 246 'Returns the set of points inside the polygon'
247 # use shapely polygon contains 247 # use shapely polygon contains
248 pass 248 pass
249
250 ##################
251 # Moving Objects
252 ##################
253
254 userTypeNames = ['car',
255 'pedestrian',
256 'twowheels',
257 'bus'
258 'truck']
249 259
250 class MovingObject(STObject): 260 class MovingObject(STObject):
251 '''Class for moving objects 261 '''Class for moving objects
252 i.e. with a trajectory and a geometry (volume) (constant) 262 i.e. with a trajectory and a geometry (volume) (constant)
253 and a usertype (e.g. road user) 263 and a usertype (e.g. road user)
318 instants.append(self.timeInterval[i]*(1-ratio)+ratio*self.timeInterval[i+1]) 328 instants.append(self.timeInterval[i]*(1-ratio)+ratio*self.timeInterval[i+1])
319 return instants 329 return instants
320 330
321 # def computeVelocities(self): 331 # def computeVelocities(self):
322 332
333 def plotRoadUsers(objects, colors):
334 '''Colors is a PlottingPropertyValues instance'''
335 from matplotlib.pyplot import figure, axis
336 figure()
337 for obj in objects:
338 obj.draw(colors.get(obj.userType))
339 axis('equal')
340
341
323 # need for a class representing the indicators, their units, how to print them in graphs... 342 # need for a class representing the indicators, their units, how to print them in graphs...
324 class TemporalIndicator: 343 class TemporalIndicator:
325 '''Class for temporal indicators 344 '''Class for temporal indicators
326 i.e. indicators that take a value at specific instants 345 i.e. indicators that take a value at specific instants
327 346