# HG changeset patch # User Nicolas Saunier # Date 1427203032 -3600 # Node ID 6ae68383071e6f2d21ddc2877d8e75c49185f502 # Parent b61b309cb9dae9756b17dda7ac38e75e5025ab21 corrected issue with tests requiring shapely, adding a separate test file diff -r b61b309cb9da -r 6ae68383071e python/moving.py --- a/python/moving.py Tue Mar 24 14:02:14 2015 +0100 +++ b/python/moving.py Tue Mar 24 14:17:12 2015 +0100 @@ -1180,7 +1180,9 @@ @staticmethod def computePET(obj1, obj2, collisionDistanceThreshold): - '''Post-encroachment time based on distance threshold''' + '''Post-encroachment time based on distance threshold + + Returns the smallest time difference when the object positions are within collisionDistanceThreshold''' #for i in xrange(int(obj1.length())-1): # for j in xrange(int(obj2.length())-1): # inter = segmentIntersection(obj1.getPositionAt(i), obj1.getPositionAt(i+1), obj2.getPositionAt(i), obj2.getPositionAt(i+1)) @@ -1554,3 +1556,6 @@ unittest.TextTestRunner().run(suite) #doctest.testmod() #doctest.testfile("example.txt") + if shapelyAvailable: + suite = doctest.DocFileSuite('tests/moving_shapely.txt') + unittest.TextTestRunner().run(suite) diff -r b61b309cb9da -r 6ae68383071e python/tests/moving_shapely.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/tests/moving_shapely.txt Tue Mar 24 14:17:12 2015 +0100 @@ -0,0 +1,9 @@ +>>> from moving import * +>>> from shapely.geometry import Polygon + +>>> t1 = Trajectory([[0.5,1.5,2.5],[0.5,3.5,6.5]]) +>>> t1.getTrajectoryInPolygon(Polygon([[0,0],[4,0],[4,3],[0,3]])) +(0.500000,0.500000) +>>> t1.getTrajectoryInPolygon(Polygon([[10,10],[14,10],[14,13],[10,13]])).length() +0 +