Mercurial Hosting > traffic-intelligence
view python/event.py @ 65:75cf537b8d88
moved and generalized map making functions to the library
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sun, 07 Nov 2010 01:09:50 -0500 |
parents | f955e83da499 |
children | ded58c424783 |
line wrap: on
line source
#! /usr/bin/env python '''Libraries for events Interactions, pedestrian crossing...''' #import utils; import moving __metaclass__ = type class Interaction(moving.STObject): '''Class for an interaction between two road users or a road user and an obstacle link to the moving objects ''' categories = {'headon': 0, 'rearend': 1, 'side': 2, 'parallel': 3} def __init__(self, num = None, timeInterval = None, roaduserNum1 = None, roaduserNum2 = None, movingObject1 = None, movingObject2 = None, categoryNum = None): moving.STObject.__init__(self, num, timeInterval) self.roaduserNum1 = roaduserNum1 self.roaduserNum2 = roaduserNum2 self.movingObject1 = movingObject1 self.movingObject2 = movingObject2 self.categoryNum = categoryNum def getIndicator(self, indicatorName): if hasattr(self, 'indicators'): for i in self.indicators: if i.name == indicatorName: return i else: return None class Crossing(moving.STObject): '''Class for the event of a street crossing TODO: detecter passage sur la chaussee identifier origines et destination (ou uniquement chaussee dans FOV) carac traversee detecter proximite veh (retirer si trop similaire simultanement carac interaction''' def __init__(self, roaduserNum = None, num = None, timeInterval = None): moving.STObject.__init__(self, num, timeInterval) self.roaduserNum = roaduserNum if __name__ == "__main__": import doctest import unittest #suite = doctest.DocFileSuite('tests/moving.txt') suite = doctest.DocTestSuite() unittest.TextTestRunner().run(suite)