Mercurial Hosting > traffic-intelligence
changeset 635:6ae68383071e
corrected issue with tests requiring shapely, adding a separate test file
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 24 Mar 2015 14:17:12 +0100 |
parents | b61b309cb9da |
children | 3058e00887bc |
files | python/moving.py python/tests/moving_shapely.txt |
diffstat | 2 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- /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 +