Mercurial > hg > nsaunier > traffic-intelligence
comparison python/moving.py @ 997:4f3387a242a1
updated utils to python 3
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 25 May 2018 18:15:18 -0400 |
| parents | add667153087 |
| children | 933670761a57 |
comparison
equal
deleted
inserted
replaced
| 996:add667153087 | 997:4f3387a242a1 |
|---|---|
| 1143 return MovingObject(num = num, timeInterval = timeInterval, positions = positions, velocities = velocities) | 1143 return MovingObject(num = num, timeInterval = timeInterval, positions = positions, velocities = velocities) |
| 1144 | 1144 |
| 1145 @staticmethod | 1145 @staticmethod |
| 1146 def concatenate(obj1, obj2, num = None, computePositions = False): | 1146 def concatenate(obj1, obj2, num = None, computePositions = False): |
| 1147 '''Concatenates two objects supposed to overlap temporally ''' | 1147 '''Concatenates two objects supposed to overlap temporally ''' |
| 1148 if num is None: | 1148 if num is None: |
| 1149 newNum = obj1.getNum() | 1149 newNum = obj1.getNum() |
| 1150 else: | 1150 else: |
| 1151 newNum = num | 1151 newNum = num |
| 1152 commonTimeInterval = obj1.commonTimeInterval(obj2) | 1152 commonTimeInterval = obj1.commonTimeInterval(obj2) |
| 1153 if commonTimeInterval.empty(): | 1153 if commonTimeInterval.empty(): |
| 1154 print('The two objects\' time intervals do not overlap: obj1 {} and obj2 {}'.format(obj1.getTimeInterval(), obj2.getTimeInterval())) | 1154 print('The two objects\' time intervals do not overlap: obj1 {} and obj2 {}'.format(obj1.getTimeInterval(), obj2.getTimeInterval())) |
| 1155 emptyInterval = TimeInterval(min(obj1.getLastInstant(),obj2.getLastInstant()) , max(obj1.getFirstInstant(),obj2.getFirstInstant())) | 1155 emptyInterval = TimeInterval(min(obj1.getLastInstant(),obj2.getLastInstant()) , max(obj1.getFirstInstant(),obj2.getFirstInstant())) |
| 1156 positions = Trajectory() | 1156 positions = Trajectory() |
| 1168 positions.addPositionXY(px,py) | 1168 positions.addPositionXY(px,py) |
| 1169 velocities.addPositionXY(vitessex,vitessey) | 1169 velocities.addPositionXY(vitessex,vitessey) |
| 1170 px+=vitessex | 1170 px+=vitessex |
| 1171 py+=vitessey | 1171 py+=vitessey |
| 1172 | 1172 |
| 1173 newObject = MovingObject(newNum, emptyInterval, positions, velocities, userType = obj1.getUserType()) | 1173 newObject = MovingObject(newNum, emptyInterval, positions, velocities, userType = obj1.getUserType()) |
| 1174 return MovingObject.concatenate(MovingObject.concatenate(obj1, newObject),obj2) | 1174 return MovingObject.concatenate(MovingObject.concatenate(obj1, newObject),obj2) |
| 1175 | 1175 |
| 1176 | |
| 1177 else: | 1176 else: |
| 1178 newTimeInterval = TimeInterval.union(obj1.getTimeInterval(), obj2.getTimeInterval()) | 1177 newTimeInterval = TimeInterval.union(obj1.getTimeInterval(), obj2.getTimeInterval()) |
| 1179 # positions | 1178 # positions |
| 1180 if computePositions: # TODO it would probably be better to recompute from all features, if features are available, in other method | 1179 if computePositions: # TODO it would probably be better to recompute from all features, if features are available, in other method |
| 1181 positions = Trajectory() | 1180 positions = Trajectory() |
