comparison python/moving.py @ 54:c354d41ef7cd

corrected code for usertype in movingobject
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 13 Oct 2010 19:08:12 -0400
parents 1fb5606506ae
children 88d5ee5ac164
comparison
equal deleted inserted replaced
53:0a5bdbf0d1b4 54:c354d41ef7cd
247 # use shapely polygon contains 247 # use shapely polygon contains
248 pass 248 pass
249 249
250 class MovingObject(STObject): 250 class MovingObject(STObject):
251 '''Class for moving objects 251 '''Class for moving objects
252 i.e. with a trajectory and a geometry (volume) 252 i.e. with a trajectory and a geometry (volume) (constant)
253 and a type (e.g. road user) 253 and a usertype (e.g. road user)
254 ''' 254 '''
255 255
256 def __init__(self, num = None, timeInterval = None, positions = None, geometry = None, type = None): 256 def __init__(self, num = None, timeInterval = None, positions = None, geometry = None, userType = None):
257 STObject.__init__(self, num, timeInterval) 257 STObject.__init__(self, num, timeInterval)
258 self.positions = positions 258 self.positions = positions
259 self.geometry = geometry 259 self.geometry = geometry
260 self.type = type 260 self.userType = userType
261 # compute bounding polygon from trajectory 261 # compute bounding polygon from trajectory
262 262
263 def getObjectInTimeInterval(self, inter): 263 def getObjectInTimeInterval(self, inter):
264 '''Returns a new object extracted from self, existing at time interval inter''' 264 '''Returns a new object extracted from self,
265 restricted to time interval inter'''
265 if inter.inside(self.timeInterval): 266 if inter.inside(self.timeInterval):
266 inter = TimeInterval(inter.first-self.getFirstInstant(), inter.last-self.getFirstInstant()) 267 inter = TimeInterval(inter.first-self.getFirstInstant(), inter.last-self.getFirstInstant())
267 obj = MovingObject(self.num, inter, self.positions.getTrajectoryInInterval(inter), self.geometry, self.type) 268 obj = MovingObject(self.num, inter, self.positions.getTrajectoryInInterval(inter), self.geometry, self.userType)
268 if self.velocities: 269 if self.velocities:
269 obj.velocities = self.velocities.getTrajectoryInInterval(inter) 270 obj.velocities = self.velocities.getTrajectoryInInterval(inter)
270 return obj 271 return obj
271 else: 272 else:
272 print 'The object does not exist at '+str(inter) 273 print 'The object does not exist at '+str(inter)