# HG changeset patch # User Nicolas Saunier # Date 1322264699 18000 # Node ID c06379f25ab844bd348d208246feed685df2eac3 # Parent d70e9b36889c607aeed2e2edb9e99ce5a24a35cb utilities for user types diff -r d70e9b36889c -r c06379f25ab8 python/moving.py --- 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) diff -r d70e9b36889c -r c06379f25ab8 python/utils.py --- 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