diff python/tests/storage.txt @ 880:000555430b28

adapted code from Paul St-Aubin and udpated MovingObject.setFeatures to truly find the right features in a list that may not start at 0
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 14 Mar 2017 17:10:35 -0400
parents c70adaeeddf5
children 3a06007a4bb7
line wrap: on
line diff
--- a/python/tests/storage.txt	Tue Mar 14 14:22:14 2017 -0400
+++ b/python/tests/storage.txt	Tue Mar 14 17:10:35 2017 -0400
@@ -71,6 +71,35 @@
 True
 >>> remove('test.sqlite')
 
+>>> f1 = MovingObject.generate(Point(0.,0.), Point(1.,0.), TimeInterval(0,10))
+>>> f1.num = 3
+>>> f2 = MovingObject.generate(Point(1.,1.), Point(-0.5,-0.2), TimeInterval(0,9))
+>>> f2.num = 4
+>>> o1 = MovingObject(num = 1, userType = 1)
+>>> o1.features = [f1, f2]
+>>> saveTrajectoriesToSqlite('test.sqlite', [o1], 'object')
+>>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'object', withFeatures = True)
+>>> len(objects)
+1
+>>> reloaded1 = objects[0]
+>>> reloaded1.getNum() == o1.getNum()
+True
+>>> reloaded1.getUserType() == o1.getUserType()
+True
+>>> len(reloaded1.featureNumbers)
+2
+>>> len(reloaded1.features)
+2
+>>> reloaded1.getPositionAt(0) == Point.midPoint(f1.getPositionAt(0), f2.getPositionAt(0))
+True
+>>> reloaded1.getPositionAt(5) == Point.midPoint(f1.getPositionAt(5), f2.getPositionAt(5))
+True
+>>> reloaded1.getPositionAt(10) == f1.getPositionAt(10)
+True
+>>> set(reloaded1.featureNumbers) == set([f1.num, f2.num])
+True
+>>> remove('test.sqlite')
+
 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf')
 >>> readline(strio)
 'sadlkfjsdlakjf'