Mercurial > hg > nsaunier > traffic-intelligence
comparison trafficintelligence/tests/moving_shapely.txt @ 1028:cc5cb04b04b0
major update using the trafficintelligence package name and install through pip
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 15 Jun 2018 11:19:10 -0400 |
| parents | python/tests/moving_shapely.txt@7c38250ddfc7 |
| children |
comparison
equal
deleted
inserted
replaced
| 1027:6129296848d3 | 1028:cc5cb04b04b0 |
|---|---|
| 1 >>> from moving import * | |
| 2 >>> from shapely.geometry import Polygon | |
| 3 >>> from shapely.prepared import prep | |
| 4 | |
| 5 >>> t1 = Trajectory([[0.5,1.5,2.5],[0.5,3.5,6.5]]) | |
| 6 >>> poly = Polygon([[0,0],[4,0],[4,3],[0,3]]) | |
| 7 >>> sub1, sub2 = t1.getTrajectoryInPolygon(poly) | |
| 8 >>> sub1 | |
| 9 (0.500000,0.500000) | |
| 10 >>> sub1, sub2 = t1.getTrajectoryInPolygon(Polygon([[10,10],[14,10],[14,13],[10,13]])) | |
| 11 >>> sub1.length() | |
| 12 0 | |
| 13 >>> sub1, sub2 = t1.getTrajectoryInPolygon(prep(poly)) | |
| 14 >>> sub1 | |
| 15 (0.500000,0.500000) | |
| 16 >>> t2 = t1.differentiate(True) | |
| 17 >>> sub1, sub2 = t1.getTrajectoryInPolygon(prep(poly), t2) | |
| 18 >>> sub1.length() == sub2.length() | |
| 19 True | |
| 20 >>> sub1 | |
| 21 (0.500000,0.500000) | |
| 22 >>> sub2 | |
| 23 (1.000000,3.000000) | |
| 24 | |
| 25 >>> t1.proportionInPolygon(poly, 0.5) | |
| 26 False | |
| 27 >>> t1.proportionInPolygon(poly, 0.3) | |
| 28 True |
