Mercurial Hosting > traffic-intelligence
changeset 185:c06379f25ab8
utilities for user types
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 25 Nov 2011 18:44:59 -0500 |
parents | d70e9b36889c |
children | 6c48283a78ca |
files | python/moving.py python/utils.py |
diffstat | 2 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/python/moving.py Fri Nov 25 18:38:54 2011 -0500 +++ b/python/moving.py Fri Nov 25 18:44:59 2011 -0500 @@ -413,9 +413,11 @@ userTypeNames = ['car', 'pedestrian', 'twowheels', - 'bus' + 'bus', 'truck'] +userType2Num = utils.inverseEnumeration(userTypeNames) + class MovingObject(STObject): '''Class for moving objects i.e. with a trajectory and a geometry (volume) (constant)
--- a/python/utils.py Fri Nov 25 18:38:54 2011 -0500 +++ b/python/utils.py Fri Nov 25 18:44:59 2011 -0500 @@ -10,6 +10,16 @@ delimiterChar = '%'; +######################### +# Enumerations +######################### + +def inverseEnumeration(l): + 'Returns the dictionary that provides for each element in the input list its index in the input list' + result = {} + for i,x in enumerate(l): + result[x] = i + return result ######################### # CLI utils