comparison python/moving.py @ 329:a70c205ebdd9

added sqlite code, in particular to load and save road user type
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 13 Jun 2013 00:42:40 -0400
parents 42f2b46ec210
children 40790d93200e
comparison
equal deleted inserted replaced
328:5e43b7389c25 329:a70c205ebdd9
126 self.boundingPolygon = boundingPolygon 126 self.boundingPolygon = boundingPolygon
127 127
128 def empty(self): 128 def empty(self):
129 return self.timeInterval.empty() or not self.boudingPolygon 129 return self.timeInterval.empty() or not self.boudingPolygon
130 130
131 def getId(self): 131 def getNum(self):
132 return self.num 132 return self.num
133 133
134 def getFirstInstant(self): 134 def getFirstInstant(self):
135 return self.timeInterval.first 135 return self.timeInterval.first
136 136
553 553
554 ################## 554 ##################
555 # Moving Objects 555 # Moving Objects
556 ################## 556 ##################
557 557
558 userTypeNames = ['car', 558 userTypeNames = ['unknown',
559 'car',
559 'pedestrian', 560 'pedestrian',
560 'twowheels', 561 'motorcycle',
562 'bicycle',
561 'bus', 563 'bus',
562 'truck'] 564 'truck']
563 565
564 userType2Num = utils.inverseEnumeration(userTypeNames) 566 userType2Num = utils.inverseEnumeration(userTypeNames)
565 567
566 class MovingObject(STObject): 568 class MovingObject(STObject):
567 '''Class for moving objects: a spatio-temporal object 569 '''Class for moving objects: a spatio-temporal object
568 with a trajectory and a geometry (constant volume over time) and a usertype (e.g. road user) 570 with a trajectory and a geometry (constant volume over time) and a usertype (e.g. road user) coded as a number (see
569 ''' 571 '''
570 572
571 def __init__(self, num = None, timeInterval = None, positions = None, geometry = None, userType = None): 573 def __init__(self, num = None, timeInterval = None, positions = None, geometry = None, userType = None):
572 super(MovingObject, self).__init__(num, timeInterval) 574 super(MovingObject, self).__init__(num, timeInterval)
573 self.positions = positions 575 self.positions = positions
597 return self.positions 599 return self.positions
598 600
599 def getVelocities(self): 601 def getVelocities(self):
600 return self.velocities 602 return self.velocities
601 603
604 def getUserType(self):
605 return self.userType
606
607 def setUserType(self, userType):
608 self.userType = userType
609
602 def setFeatures(self, features): 610 def setFeatures(self, features):
603 self.features = [features[i] for i in self.featureNumbers] 611 self.features = [features[i] for i in self.featureNumbers]
604 612
605 def getSpeeds(self): 613 def getSpeeds(self):
606 return self.getVelocities().norm() 614 return self.getVelocities().norm()