Mercurial > hg > nsaunier > traffic-intelligence
comparison python/ubc_utils.py @ 44:be3ae926e4e8
added simple intersection description, function to load collision points
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Sat, 31 Jul 2010 23:39:17 -0400 |
| parents | 6d11d9e7ad4e |
| children | e27598865af3 |
comparison
equal
deleted
inserted
replaced
| 43:6d11d9e7ad4e | 44:be3ae926e4e8 |
|---|---|
| 57 lines = getLines(file) | 57 lines = getLines(file) |
| 58 | 58 |
| 59 file.close() | 59 file.close() |
| 60 return objects | 60 return objects |
| 61 | 61 |
| 62 def loadCollisionPoints(filename, nPoints = -1): | |
| 63 '''Loads collision points and returns a dict | |
| 64 with keys as a pair of the numbers of the two interacting objects''' | |
| 65 file = utils.openCheck(filename) | |
| 66 if (not file): | |
| 67 return [] | |
| 68 | |
| 69 points = {} | |
| 70 num = 0 | |
| 71 lines = getLines(file) | |
| 72 while (lines != []) and ((nPoints<0) or (num<nPoints)): | |
| 73 parsedLine = [int(n) for n in lines[0].split(' ')] | |
| 74 protagonistNums = (parsedLine[0], parsedLine[1]) | |
| 75 points[protagonistNums] = [[float(n) for n in lines[1].split(' ')], | |
| 76 [float(n) for n in lines[2].split(' ')]] | |
| 77 | |
| 78 num+=1 | |
| 79 lines = getLines(file) | |
| 80 | |
| 81 file.close() | |
| 82 return points |
