changeset 1163:fa9c358789ac

bug correction
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 19 Mar 2021 15:54:19 -0400
parents efd52c55a72b
children f1a33f458d7e
files trafficintelligence/iframework.py
diffstat 1 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/trafficintelligence/iframework.py	Sun Mar 07 23:26:51 2021 -0500
+++ b/trafficintelligence/iframework.py	Fri Mar 19 15:54:19 2021 -0400
@@ -137,10 +137,13 @@
 class Line(Base):
     __tablename__ = 'lines'
     idx = Column(Integer, primary_key=True)
+    name = Column(String)
+    # todo define lines for access counting: add type? - AccessLine?
 
     points = relationship('Point', secondary=pointLineAssociation)
 
-    def __init__(self, x1, y1, x2, y2):
+    def __init__(self, name, x1, y1, x2, y2):
+        self.name = name
         self.points = [Point(x1, y1), Point(x2, y2)]
 
 pointZoneAssociation = Table('pointzones', Base.metadata,
@@ -150,11 +153,13 @@
 class Zone(Base):
     __tablename__ = 'zones'
     idx = Column(Integer, primary_key=True)
+    name = Column(String)
 
     points = relationship('Point', secondary=pointZoneAssociation)
 
-    def __init__(self, xs = None, ys = None):
+    def __init__(self, name, xs = None, ys = None):
         'xs and ys are the list of x and y coordinates'
+        self.name = name
         if xs is not None and ys is not None:
             for x,y in zip(xs, ys):
                 self.addPoint(x,y)
@@ -164,6 +169,10 @@
 
 class AbstractPassing:
     def initPersonGroupPassing(self, group, person, transport, vehicle):
+        ''' initiates with the passing the group or person
+
+        design question: what should be done about simple line counting, 
+        without information about persons'''
         if person is None and group is not None: # create group
             self.group = group
             if transport is not None:
@@ -272,9 +281,9 @@
     veh1 = Vehicle('car')
     modes = [Mode('cardriver', p, veh1), Mode('walking', p, startTime = datetime(2020,7,7,11,20))]
     
-    line = Line(0.,0.,0.,10.)
-    zone = Zone([0., 0., 1., 1.], [0., 1., 1., 0.])
-    destination = Zone([10., 10., 11., 11.], [10., 11., 11., 10.])
+    line = Line('line1', 0.,0.,0.,10.)
+    zone = Zone('zone1', [0., 0., 1., 1.], [0., 1., 1., 0.])
+    destination = Zone('destination1', [10., 10., 11., 11.], [10., 11., 11., 10.])
     counts = [LinePassing(line, datetime(2020,7,2,23,20+i), person = Person(20+i, 'female', disability = True), transport = 'walking') for i in range(5)]
     group1 = Group([Person(13+i,'female', False, False, True, False) for i in range(3)])
     groupMode1 = Mode.initGroup('walking', group1)
@@ -285,7 +294,7 @@
     counts.append(LinePassing(line, datetime(2020,7,2,23,7), person = Person(23, 'unknown'), transport = 'cardriver', vehicle = Vehicle('car')))
     counts.append(LinePassing(line, datetime(2020,7,2,23,9), person = Person('teen', 'unknown'), transport = 'scooter', vehicle = Vehicle('scooter')))
     counts.append(LinePassing(line, datetime(2020,7,2,23,11), person = Person(12, 'female'), transport = 'bike'))
-    counts.append(LinePassing(line, datetime(2020,7,2,23,13), person = Person(), transport = 'car')) # example of counting cars without knowing the driver and passenger's attributes
+    counts.append(LinePassing(line, datetime(2020,7,2,23,13), person = Person(), transport = 'cardriver')) # example of counting cars without knowing the driver and passenger's attributes
     counts.append(LinePassing(line, datetime(2020,7,2,23,15), group = Group([Person(34+i) for i in range(3)]), transport = 'carpassenger'))