Mercurial > hg > nsaunier > traffic-intelligence
comparison trafficintelligence/tests/storage.txt @ 1077:3939ae415be0
Merging
| author | Wendlasida |
|---|---|
| date | Fri, 20 Jul 2018 14:03:34 -0400 |
| parents | a7ada64b8214 |
| children | 8734742c08c0 |
comparison
equal
deleted
inserted
replaced
| 1076:108c5dc4e34a | 1077:3939ae415be0 |
|---|---|
| 1 >>> from io import StringIO | 1 >>> from io import StringIO |
| 2 >>> from os import remove | |
| 2 >>> from trafficintelligence.storage import * | 3 >>> from trafficintelligence.storage import * |
| 3 >>> from trafficintelligence.utils import openCheck, readline | 4 >>> from trafficintelligence.utils import openCheck, readline |
| 4 >>> from trafficintelligence.moving import MovingObject, Point, TimeInterval, Trajectory, prepareSplines | 5 >>> from trafficintelligence.moving import MovingObject, Point, TimeInterval, Trajectory, prepareSplines |
| 5 | 6 |
| 6 >>> f = openCheck('non_existant_file.txt') | 7 >>> f = openCheck('non_existant_file.txt') |
| 7 File non_existant_file.txt could not be opened. | 8 File non_existant_file.txt could not be opened. |
| 8 | 9 |
| 9 >>> nonexistentFilename = "nonexistent" | 10 >>> nonexistentFilename = "nonexistent" |
| 10 >>> loadTrajectoriesFromSqlite(nonexistentFilename, 'feature') | 11 >>> loadTrajectoriesFromSqlite(nonexistentFilename, 'feature') |
| 11 DB Error: no such table: positions | |
| 12 DB Error: no such table: velocities | |
| 13 [] | 12 [] |
| 14 >>> from os import remove | |
| 15 >>> remove(nonexistentFilename) | |
| 16 | 13 |
| 17 >>> o1 = MovingObject.generate(2, Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) | 14 >>> o1 = MovingObject.generate(2, Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) |
| 18 >>> o2 = MovingObject.generate(3, Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9)) | 15 >>> o2 = MovingObject.generate(3, Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9)) |
| 19 >>> saveTrajectoriesToSqlite('test.sqlite', [o1, o2], 'feature') | 16 >>> saveTrajectoriesToSqlite('test.sqlite', [o1, o2], 'feature') |
| 20 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature') | 17 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature') |
| 46 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature', timeStep = 3) | 43 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature', timeStep = 3) |
| 47 >>> objects[0].positions.length() | 44 >>> objects[0].positions.length() |
| 48 4 | 45 4 |
| 49 >>> objects[1].positions.length() | 46 >>> objects[1].positions.length() |
| 50 4 | 47 4 |
| 48 >>> remove('test.sqlite') | |
| 49 | |
| 51 >>> align1 = Trajectory.fromPointList([Point(-1, 0), Point(20, 0)]) | 50 >>> align1 = Trajectory.fromPointList([Point(-1, 0), Point(20, 0)]) |
| 52 >>> align2 = Trajectory.fromPointList([Point(-9, -3), Point(6, 3)]) | 51 >>> align2 = Trajectory.fromPointList([Point(-9, -3), Point(6, 3)]) |
| 53 >>> align1.computeCumulativeDistances() | 52 >>> align1.computeCumulativeDistances() |
| 54 >>> align2.computeCumulativeDistances() | 53 >>> align2.computeCumulativeDistances() |
| 55 >>> prepareSplines([align1, align2]) | 54 >>> prepareSplines([align1, align2]) |
