comparison trafficintelligence/tests/moving.txt @ 1177:aa88acf06876

rewrote object concatenation method, cleaner
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 24 Mar 2022 16:07:51 -0400
parents b55adb13f262
children dc28364f34b9
comparison
equal deleted inserted replaced
1176:5874ece33637 1177:aa88acf06876
135 >>> t1 == t3 135 >>> t1 == t3
136 False 136 False
137 >>> t3 = Trajectory.fromPointList([(92.2, 102.9), (56.7, 69.6), (56.7, 69.6)]) 137 >>> t3 = Trajectory.fromPointList([(92.2, 102.9), (56.7, 69.6), (56.7, 69.6)])
138 >>> t1 == t3 138 >>> t1 == t3
139 False 139 False
140 >>> t1.append(t2)
141 >>> t1.length()
142 4
140 143
141 >>> left = Trajectory.fromPointList([(92.291666666666686, 102.99239033124439), (56.774193548387103, 69.688898836168306)]) 144 >>> left = Trajectory.fromPointList([(92.291666666666686, 102.99239033124439), (56.774193548387103, 69.688898836168306)])
142 >>> middle = Trajectory.fromPointList([(87.211021505376351, 93.390778871978512), (59.032258064516128, 67.540286481647257)]) 145 >>> middle = Trajectory.fromPointList([(87.211021505376351, 93.390778871978512), (59.032258064516128, 67.540286481647257)])
143 >>> right = Trajectory.fromPointList([(118.82392473118281, 115.68263205013426), (63.172043010752688, 66.600268576544309)]) 146 >>> right = Trajectory.fromPointList([(118.82392473118281, 115.68263205013426), (63.172043010752688, 66.600268576544309)])
144 >>> alignments = [left, middle, right] 147 >>> alignments = [left, middle, right]
149 [1, 0, (77.033188,84.053889), 13.811799123113715, 13.811799123113715, -1.4301775140225983] 152 [1, 0, (77.033188,84.053889), 13.811799123113715, 13.811799123113715, -1.4301775140225983]
150 153
151 >>> Trajectory().length() 154 >>> Trajectory().length()
152 0 155 0
153 >>> t1 = Trajectory([[0.5,1.5,2.5],[0.5,3.5,6.5]]) 156 >>> t1 = Trajectory([[0.5,1.5,2.5],[0.5,3.5,6.5]])
154 >>> t1.length() == 3. 157 >>> t1.length()
155 True 158 3
156 >>> t1[1] 159 >>> t1[1]
157 (1.500000,3.500000) 160 (1.500000,3.500000)
158 161
159 >>> t1.differentiate() 162 >>> t1.differentiate()
160 (1.000000,3.000000) (1.000000,3.000000) 163 (1.000000,3.000000) (1.000000,3.000000)
296 >>> o1.features = [o1] 299 >>> o1.features = [o1]
297 >>> o2 = MovingObject.generate(2, Point(14., 14.), Point(1., 0.), TimeInterval(14,20)) 300 >>> o2 = MovingObject.generate(2, Point(14., 14.), Point(1., 0.), TimeInterval(14,20))
298 >>> o2.features = [o2] 301 >>> o2.features = [o2]
299 >>> o3 = MovingObject.generate(3, Point(2., 2.), Point(1., 1.), TimeInterval(2,12)) 302 >>> o3 = MovingObject.generate(3, Point(2., 2.), Point(1., 1.), TimeInterval(2,12))
300 >>> o3.features = [o3] 303 >>> o3.features = [o3]
301 >>> o13 = MovingObject.concatenate(o1, o3, 4) 304 >>> o4 = MovingObject.generate(4, Point(4., 4.), Point(1., 1.), TimeInterval(11,20))
302 >>> o13.getNum() 305 >>> o4.features = [o4]
303 4 306 >>> o5 = MovingObject.generate(5, Point(5., 5.), Point(1., 1.), TimeInterval(12,22))
307 >>> o5.features = [o5]
308
309 >>> objNum = 14
310 >>> o13, f13 = MovingObject.concatenate(o1, o3, objNum)
311 >>> o13.getNum() == objNum
312 True
304 >>> o13.getTimeInterval() == TimeInterval(0,12) 313 >>> o13.getTimeInterval() == TimeInterval(0,12)
305 True 314 True
306 >>> t=5 315 >>> t=5
307 >>> o13.getPositionAtInstant(t) == (o1.getPositionAtInstant(t)+o3.getPositionAtInstant(t)).divide(2) 316 >>> o13.getPositionAtInstant(t) == (o1.getPositionAtInstant(t)+o3.getPositionAtInstant(t)).divide(2)
308 True 317 True
309 >>> len(o13.getFeatures()) 318 >>> len(o13.getFeatures())
310 2 319 2
311 320
312 >>> o12 = MovingObject.concatenate(o1, o2, 5, minFeatureLength = 6) 321 >>> o12, f12 = MovingObject.concatenate(o1, o2, 15, 15)
313 >>> o12.getTimeInterval() == TimeInterval(o1.getFirstInstant(), o2.getLastInstant()) 322 >>> o12.getTimeInterval() == TimeInterval(o1.getFirstInstant(), o2.getLastInstant())
314 True 323 True
315 >>> v = o12.getVelocityAtInstant(12) 324 >>> v = o12.getVelocityAtInstant(12)
316 >>> v == Point(3./4, 2./4) 325 >>> v == Point(3./4, 2./4)
317 True 326 True
318 >>> o12.getPositionAtInstant(11) == o1.getPositionAtInstant(10)+v 327 >>> o12.getPositionAtInstant(11) == o1.getPositionAtInstant(10)+v
319 True 328 True
320 >>> len(o12.getFeatures()) 329 >>> len(o12.getFeatures())
321 3 330 3
322 >>> f = o12.getFeatures()[-1] 331 >>> f12.length()
323 >>> f.length() 332 5.0
324 6.0 333 >>> f12.getPositions().length()
334 5
335 >>> f12.getVelocities().length()
336 5
337
338 >>> o14, f14 = MovingObject.concatenate(o1, o4, 16)
339 >>> len(o14.getFeatures())
340 2
341 >>> o14.getPositionAtInstant(10) == o1.getPositionAtInstant(10)
342 True
343 >>> o14.getPositionAtInstant(11) == o4.getPositionAtInstant(11)
344 True
345
346 >>> o15, f15 = MovingObject.concatenate(o1, o5, 17, 17)
347 >>> len(o15.getFeatures())
348 3
349 >>> f15.length()
350 3.0
351 >>> o15.getFeatures()[-1] == f15
352 True
353 >>> o1.getPositionAtInstant(10) == o15.getPositionAtInstant(10)
354 True
355 >>> f15.getPositionAtInstant(11) == o15.getPositionAtInstant(11)
356 True
357 >>> o5.getPositionAtInstant(12) == o15.getPositionAtInstant(12)
358 True
359 >>> o15.updatePositions()
360 >>> o1.getPositionAtInstant(10) == o15.getPositionAtInstant(10)
361 True
362 >>> f15.getPositionAtInstant(11) == o15.getPositionAtInstant(11)
363 True
364 >>> o5.getPositionAtInstant(12) == o15.getPositionAtInstant(12)
365 True
325 366
326 >>> o1 = MovingObject.generate(1, Point(0., 2.), Point(0., 1.), TimeInterval(0,2)) 367 >>> o1 = MovingObject.generate(1, Point(0., 2.), Point(0., 1.), TimeInterval(0,2))
327 >>> o1.classifyUserTypeSpeedMotorized(0.5, np.median) 368 >>> o1.classifyUserTypeSpeedMotorized(0.5, np.median)
328 >>> userTypeNames[o1.getUserType()] 369 >>> userTypeNames[o1.getUserType()]
329 'car' 370 'car'