Mercurial > hg > nsaunier > traffic-intelligence
comparison python/tests/storage.txt @ 795:a34ec862371f
merged with dev branch
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Mon, 09 May 2016 15:33:11 -0400 |
| parents | 1b22d81ef5ff |
| children | 180b6b0231c0 |
comparison
equal
deleted
inserted
replaced
| 758:0a05883216cf | 795:a34ec862371f |
|---|---|
| 1 >>> from storage import * | 1 >>> from storage import * |
| 2 >>> from StringIO import StringIO | 2 >>> from StringIO import StringIO |
| 3 >>> from moving import MovingObject, Point, TimeInterval, Trajectory, prepareSplines | |
| 3 | 4 |
| 4 >>> f = openCheck('non_existant_file.txt') | 5 >>> f = openCheck('non_existant_file.txt') |
| 5 File non_existant_file.txt could not be opened. | 6 File non_existant_file.txt could not be opened. |
| 6 | 7 |
| 7 >>> nonexistentFilename = "nonexistent" | 8 >>> nonexistentFilename = "nonexistent" |
| 13 DB Error: no such table: velocities | 14 DB Error: no such table: velocities |
| 14 [] | 15 [] |
| 15 >>> from os import remove | 16 >>> from os import remove |
| 16 >>> remove(nonexistentFilename) | 17 >>> remove(nonexistentFilename) |
| 17 | 18 |
| 19 >>> o1 = MovingObject.generate(Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) | |
| 20 >>> o1.num = 2 | |
| 21 >>> o2 = MovingObject.generate(Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9)) | |
| 22 >>> o2.num = 3 | |
| 23 >>> saveTrajectoriesToSqlite('test.sqlite', [o1, o2], 'feature') | |
| 24 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature') | |
| 25 >>> objects[0].getNum() == o1.num | |
| 26 True | |
| 27 >>> objects[1].getNum() == o2.num | |
| 28 True | |
| 29 >>> o1.getTimeInterval() == objects[0].getTimeInterval() | |
| 30 True | |
| 31 >>> o2.getTimeInterval() == objects[1].getTimeInterval() | |
| 32 True | |
| 33 >>> o1.getVelocities() == objects[0].getVelocities() | |
| 34 True | |
| 35 >>> o2.getVelocities() == objects[1].getVelocities() | |
| 36 True | |
| 37 >>> o1.getPositions() == objects[0].getPositions() | |
| 38 True | |
| 39 >>> o2.getPositions() == objects[1].getPositions() | |
| 40 True | |
| 41 >>> align1 = Trajectory.fromPointList([Point(-1, 0), Point(20, 0)]) | |
| 42 >>> align2 = Trajectory.fromPointList([Point(-9, -3), Point(6, 3)]) | |
| 43 >>> align1.computeCumulativeDistances() | |
| 44 >>> align2.computeCumulativeDistances() | |
| 45 >>> prepareSplines([align1, align2]) | |
| 46 >>> o1.projectCurvilinear([align1, align2]) | |
| 47 >>> o2.projectCurvilinear([align1, align2]) | |
| 48 >>> saveTrajectoriesToSqlite('test.sqlite', [o1, o2], 'curvilinear') | |
| 49 >>> addCurvilinearTrajectoriesFromSqlite('test.sqlite', {o.num: o for o in objects}) | |
| 50 >>> o1.curvilinearPositions[3][:2] == objects[0].curvilinearPositions[3][:2] | |
| 51 True | |
| 52 >>> o1.curvilinearPositions[7][:2] == objects[0].curvilinearPositions[7][:2] | |
| 53 True | |
| 54 >>> [str(l) for l in o1.curvilinearPositions.getLanes()] == objects[0].curvilinearPositions.getLanes() | |
| 55 True | |
| 56 >>> o2.curvilinearPositions[2][:2] == objects[1].curvilinearPositions[2][:2] | |
| 57 True | |
| 58 >>> o2.curvilinearPositions[6][:2] == objects[1].curvilinearPositions[6][:2] | |
| 59 True | |
| 60 >>> [str(l) for l in o2.curvilinearPositions.getLanes()] == objects[1].curvilinearPositions.getLanes() | |
| 61 True | |
| 62 >>> remove('test.sqlite') | |
| 63 | |
| 18 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') | 64 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') |
| 19 >>> readline(strio) | 65 >>> readline(strio) |
| 20 'sadlkfjsdlakjf' | 66 'sadlkfjsdlakjf' |
| 21 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') | 67 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') |
| 22 >>> readline(strio, ['#']) | 68 >>> readline(strio, ['#']) |
