comparison python/tests/storage.txt @ 918:3a06007a4bb7

modularized save trajectories, added slice to Trajectory, etc
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 05 Jul 2017 12:19:59 -0400
parents 000555430b28
children c030f735c594
comparison
equal deleted inserted replaced
917:89cc05867c4c 918:3a06007a4bb7
14 DB Error: no such table: velocities 14 DB Error: no such table: velocities
15 [] 15 []
16 >>> from os import remove 16 >>> from os import remove
17 >>> remove(nonexistentFilename) 17 >>> remove(nonexistentFilename)
18 18
19 >>> o1 = MovingObject.generate(Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) 19 >>> o1 = MovingObject.generate(2, Point(0.,0.), Point(1.,0.), TimeInterval(0,10))
20 >>> o1.num = 2 20 >>> o2 = MovingObject.generate(3, Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9))
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') 21 >>> saveTrajectoriesToSqlite('test.sqlite', [o1, o2], 'feature')
24 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature') 22 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'feature')
25 >>> objects[0].getNum() == o1.num 23 >>> objects[0].getNum() == o1.num
26 True 24 True
27 >>> objects[1].getNum() == o2.num 25 >>> objects[1].getNum() == o2.num
28 True 26 True
29 >>> o1.getTimeInterval() == objects[0].getTimeInterval() 27 >>> o1.getTimeInterval() == objects[0].getTimeInterval()
30 True 28 True
31 >>> o2.getTimeInterval() == objects[1].getTimeInterval() 29 >>> o2.getTimeInterval() == objects[1].getTimeInterval()
30 True
31 >>> o1.getVelocities().length() == objects[0].getVelocities().length()
32 True
33 >>> o2.getVelocities().length() == objects[1].getVelocities().length()
32 True 34 True
33 >>> o1.getVelocities() == objects[0].getVelocities() 35 >>> o1.getVelocities() == objects[0].getVelocities()
34 True 36 True
35 >>> o2.getVelocities() == objects[1].getVelocities() 37 >>> o2.getVelocities() == objects[1].getVelocities()
36 True 38 True
69 True 71 True
70 >>> [str(l) for l in o2.curvilinearPositions.getLanes()] == objects[1].curvilinearPositions.getLanes() 72 >>> [str(l) for l in o2.curvilinearPositions.getLanes()] == objects[1].curvilinearPositions.getLanes()
71 True 73 True
72 >>> remove('test.sqlite') 74 >>> remove('test.sqlite')
73 75
74 >>> f1 = MovingObject.generate(Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) 76 >>> f1 = MovingObject.generate(3, Point(0.,0.), Point(1.,0.), TimeInterval(0,10))
75 >>> f1.num = 3 77 >>> f2 = MovingObject.generate(4, Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9))
76 >>> f2 = MovingObject.generate(Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9))
77 >>> f2.num = 4
78 >>> o1 = MovingObject(num = 1, userType = 1) 78 >>> o1 = MovingObject(num = 1, userType = 1)
79 >>> o1.features = [f1, f2] 79 >>> o1.features = [f1, f2]
80 >>> saveTrajectoriesToSqlite('test.sqlite', [o1], 'object') 80 >>> saveTrajectoriesToSqlite('test.sqlite', [o1], 'object')
81 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'object', withFeatures = True) 81 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'object', withFeatures = True)
82 >>> len(objects) 82 >>> len(objects)