comparison trafficintelligence/events.py @ 1151:658f87232536

extended creation of interactions to non simultaneous objects for PET calculations
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 01 Jul 2020 11:02:52 -0400
parents 14140b55e580
children 173b7926734e
comparison
equal deleted inserted replaced
1150:14140b55e580 1151:658f87232536
293 return self.collisionPoints 293 return self.collisionPoints
294 294
295 def getCrossingZones(self): 295 def getCrossingZones(self):
296 return self.crossingZones 296 return self.crossingZones
297 297
298 def createInteractions(objects, _others = None): 298 def createInteractions(objects, _others = None, maxDurationApart = 0):
299 '''Create all interactions of two co-existing road users''' 299 '''Create all interactions of two co-existing road users'''
300 if _others is not None: 300 if _others is not None:
301 others = _others 301 others = _others
302 302
303 interactions = [] 303 interactions = []
305 for i in range(len(objects)): 305 for i in range(len(objects)):
306 if _others is None: 306 if _others is None:
307 others = objects[:i] 307 others = objects[:i]
308 for j in range(len(others)): 308 for j in range(len(others)):
309 commonTimeInterval = objects[i].commonTimeInterval(others[j]) 309 commonTimeInterval = objects[i].commonTimeInterval(others[j])
310 if not commonTimeInterval.empty(): 310 if not commonTimeInterval.empty() or (maxDurationApart > 0 and objects[i].getTimeInterval().distance(objects[j].getTimeInterval()) < maxDurationApart):
311 interactions.append(Interaction(num, commonTimeInterval, objects[i].num, others[j].num, objects[i], others[j])) 311 interactions.append(Interaction(num, commonTimeInterval, objects[i].num, others[j].num, objects[i], others[j]))
312 num += 1 312 num += 1
313 return interactions 313 return interactions
314 314
315 def findInteraction(interactions, roadUserNum1, roadUserNum2): 315 def findInteraction(interactions, roadUserNum1, roadUserNum2):