Mercurial Hosting > traffic-intelligence
comparison python/moving.py @ 543:cb213269d330
defensive code for curvilinear trajectory initialization
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 07 Jul 2014 16:59:20 -0400 |
parents | a3add9f751ef |
children | b5525249eda1 |
comparison
equal
deleted
inserted
replaced
542:a3add9f751ef | 543:cb213269d330 |
---|---|
632 '''Sub class of trajectory for trajectories with curvilinear coordinates and lane assignements | 632 '''Sub class of trajectory for trajectories with curvilinear coordinates and lane assignements |
633 longitudinal coordinate is stored as first coordinate (exterior name S) | 633 longitudinal coordinate is stored as first coordinate (exterior name S) |
634 lateral coordiante is stored as second coordinate''' | 634 lateral coordiante is stored as second coordinate''' |
635 | 635 |
636 def __init__(self, S = None, Y = None, lanes = None): | 636 def __init__(self, S = None, Y = None, lanes = None): |
637 if S == None or Y == None: | 637 if S == None or Y == None or len(S) != len(Y): |
638 self.positions = [[],[]] | 638 self.positions = [[],[]] |
639 if len(S) != len(Y): | |
640 print("S and Y coordinates of different lengths\nInitializing to empty lists") | |
639 else: | 641 else: |
640 self.positions = [S,Y] | 642 self.positions = [S,Y] |
641 if lanes == None: | 643 if lanes == None or len(lanes) != self.length(): |
642 self.lanes = [] | 644 self.lanes = [] |
643 else: | 645 else: |
644 self.lanes = lanes | 646 self.lanes = lanes |
645 | 647 |
646 def __getitem__(self,i): | 648 def __getitem__(self,i): |