Mercurial > hg > nsaunier > traffic-intelligence
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 879:f9ea5083588e | 880:000555430b28 |
|---|---|
| 69 True | 69 True |
| 70 >>> [str(l) for l in o2.curvilinearPositions.getLanes()] == objects[1].curvilinearPositions.getLanes() | 70 >>> [str(l) for l in o2.curvilinearPositions.getLanes()] == objects[1].curvilinearPositions.getLanes() |
| 71 True | 71 True |
| 72 >>> remove('test.sqlite') | 72 >>> remove('test.sqlite') |
| 73 | 73 |
| 74 >>> f1 = MovingObject.generate(Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) | |
| 75 >>> f1.num = 3 | |
| 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) | |
| 79 >>> o1.features = [f1, f2] | |
| 80 >>> saveTrajectoriesToSqlite('test.sqlite', [o1], 'object') | |
| 81 >>> objects = loadTrajectoriesFromSqlite('test.sqlite', 'object', withFeatures = True) | |
| 82 >>> len(objects) | |
| 83 1 | |
| 84 >>> reloaded1 = objects[0] | |
| 85 >>> reloaded1.getNum() == o1.getNum() | |
| 86 True | |
| 87 >>> reloaded1.getUserType() == o1.getUserType() | |
| 88 True | |
| 89 >>> len(reloaded1.featureNumbers) | |
| 90 2 | |
| 91 >>> len(reloaded1.features) | |
| 92 2 | |
| 93 >>> reloaded1.getPositionAt(0) == Point.midPoint(f1.getPositionAt(0), f2.getPositionAt(0)) | |
| 94 True | |
| 95 >>> reloaded1.getPositionAt(5) == Point.midPoint(f1.getPositionAt(5), f2.getPositionAt(5)) | |
| 96 True | |
| 97 >>> reloaded1.getPositionAt(10) == f1.getPositionAt(10) | |
| 98 True | |
| 99 >>> set(reloaded1.featureNumbers) == set([f1.num, f2.num]) | |
| 100 True | |
| 101 >>> remove('test.sqlite') | |
| 102 | |
| 74 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') | 103 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') |
| 75 >>> readline(strio) | 104 >>> readline(strio) |
| 76 'sadlkfjsdlakjf' | 105 'sadlkfjsdlakjf' |
| 77 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') | 106 >>> strio = StringIO('# asdlfjasdlkj0\nsadlkfjsdlakjf') |
| 78 >>> readline(strio, ['#']) | 107 >>> readline(strio, ['#']) |
