Mercurial > hg > nsaunier > traffic-intelligence
comparison python/tests/moving_shapely.txt @ 795:a34ec862371f
merged with dev branch
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Mon, 09 May 2016 15:33:11 -0400 |
| parents | 7c38250ddfc7 |
| children |
comparison
equal
deleted
inserted
replaced
| 758:0a05883216cf | 795:a34ec862371f |
|---|---|
| 1 >>> from moving import * | 1 >>> from moving import * |
| 2 >>> from shapely.geometry import Polygon | 2 >>> from shapely.geometry import Polygon |
| 3 >>> from shapely.prepared import prep | |
| 3 | 4 |
| 4 >>> t1 = Trajectory([[0.5,1.5,2.5],[0.5,3.5,6.5]]) | 5 >>> t1 = Trajectory([[0.5,1.5,2.5],[0.5,3.5,6.5]]) |
| 5 >>> t1.getTrajectoryInPolygon(Polygon([[0,0],[4,0],[4,3],[0,3]])) | 6 >>> poly = Polygon([[0,0],[4,0],[4,3],[0,3]]) |
| 7 >>> sub1, sub2 = t1.getTrajectoryInPolygon(poly) | |
| 8 >>> sub1 | |
| 6 (0.500000,0.500000) | 9 (0.500000,0.500000) |
| 7 >>> t1.getTrajectoryInPolygon(Polygon([[10,10],[14,10],[14,13],[10,13]])).length() | 10 >>> sub1, sub2 = t1.getTrajectoryInPolygon(Polygon([[10,10],[14,10],[14,13],[10,13]])) |
| 11 >>> sub1.length() | |
| 8 0 | 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) | |
| 9 | 24 |
| 25 >>> t1.proportionInPolygon(poly, 0.5) | |
| 26 False | |
| 27 >>> t1.proportionInPolygon(poly, 0.3) | |
| 28 True |
