diff 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
line wrap: on
line diff
--- a/trafficintelligence/events.py	Thu May 28 01:03:45 2020 -0400
+++ b/trafficintelligence/events.py	Wed Jul 01 11:02:52 2020 -0400
@@ -295,7 +295,7 @@
     def getCrossingZones(self):
         return self.crossingZones
 
-def createInteractions(objects, _others = None):
+def createInteractions(objects, _others = None, maxDurationApart = 0):
     '''Create all interactions of two co-existing road users'''
     if _others is not None:
         others = _others
@@ -307,7 +307,7 @@
             others = objects[:i]
         for j in range(len(others)):
             commonTimeInterval = objects[i].commonTimeInterval(others[j])
-            if not commonTimeInterval.empty():
+            if not commonTimeInterval.empty() or (maxDurationApart > 0 and objects[i].getTimeInterval().distance(objects[j].getTimeInterval()) < maxDurationApart):
                 interactions.append(Interaction(num, commonTimeInterval, objects[i].num, others[j].num, objects[i], others[j]))
                 num += 1
     return interactions