Mercurial Hosting > traffic-intelligence
diff 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 |
line wrap: on
line diff
--- a/trafficintelligence/tests/moving.txt Thu Feb 17 10:55:11 2022 -0500 +++ b/trafficintelligence/tests/moving.txt Thu Mar 24 16:07:51 2022 -0400 @@ -137,6 +137,9 @@ >>> t3 = Trajectory.fromPointList([(92.2, 102.9), (56.7, 69.6), (56.7, 69.6)]) >>> t1 == t3 False +>>> t1.append(t2) +>>> t1.length() +4 >>> left = Trajectory.fromPointList([(92.291666666666686, 102.99239033124439), (56.774193548387103, 69.688898836168306)]) >>> middle = Trajectory.fromPointList([(87.211021505376351, 93.390778871978512), (59.032258064516128, 67.540286481647257)]) @@ -151,8 +154,8 @@ >>> Trajectory().length() 0 >>> t1 = Trajectory([[0.5,1.5,2.5],[0.5,3.5,6.5]]) ->>> t1.length() == 3. -True +>>> t1.length() +3 >>> t1[1] (1.500000,3.500000) @@ -298,9 +301,15 @@ >>> o2.features = [o2] >>> o3 = MovingObject.generate(3, Point(2., 2.), Point(1., 1.), TimeInterval(2,12)) >>> o3.features = [o3] ->>> o13 = MovingObject.concatenate(o1, o3, 4) ->>> o13.getNum() -4 +>>> o4 = MovingObject.generate(4, Point(4., 4.), Point(1., 1.), TimeInterval(11,20)) +>>> o4.features = [o4] +>>> o5 = MovingObject.generate(5, Point(5., 5.), Point(1., 1.), TimeInterval(12,22)) +>>> o5.features = [o5] + +>>> objNum = 14 +>>> o13, f13 = MovingObject.concatenate(o1, o3, objNum) +>>> o13.getNum() == objNum +True >>> o13.getTimeInterval() == TimeInterval(0,12) True >>> t=5 @@ -309,7 +318,7 @@ >>> len(o13.getFeatures()) 2 ->>> o12 = MovingObject.concatenate(o1, o2, 5, minFeatureLength = 6) +>>> o12, f12 = MovingObject.concatenate(o1, o2, 15, 15) >>> o12.getTimeInterval() == TimeInterval(o1.getFirstInstant(), o2.getLastInstant()) True >>> v = o12.getVelocityAtInstant(12) @@ -319,9 +328,41 @@ True >>> len(o12.getFeatures()) 3 ->>> f = o12.getFeatures()[-1] ->>> f.length() -6.0 +>>> f12.length() +5.0 +>>> f12.getPositions().length() +5 +>>> f12.getVelocities().length() +5 + +>>> o14, f14 = MovingObject.concatenate(o1, o4, 16) +>>> len(o14.getFeatures()) +2 +>>> o14.getPositionAtInstant(10) == o1.getPositionAtInstant(10) +True +>>> o14.getPositionAtInstant(11) == o4.getPositionAtInstant(11) +True + +>>> o15, f15 = MovingObject.concatenate(o1, o5, 17, 17) +>>> len(o15.getFeatures()) +3 +>>> f15.length() +3.0 +>>> o15.getFeatures()[-1] == f15 +True +>>> o1.getPositionAtInstant(10) == o15.getPositionAtInstant(10) +True +>>> f15.getPositionAtInstant(11) == o15.getPositionAtInstant(11) +True +>>> o5.getPositionAtInstant(12) == o15.getPositionAtInstant(12) +True +>>> o15.updatePositions() +>>> o1.getPositionAtInstant(10) == o15.getPositionAtInstant(10) +True +>>> f15.getPositionAtInstant(11) == o15.getPositionAtInstant(11) +True +>>> o5.getPositionAtInstant(12) == o15.getPositionAtInstant(12) +True >>> o1 = MovingObject.generate(1, Point(0., 2.), Point(0., 1.), TimeInterval(0,2)) >>> o1.classifyUserTypeSpeedMotorized(0.5, np.median)