Mercurial Hosting > traffic-intelligence
annotate python/tests/moving_shapely.txt @ 830:2a5856961933
first working version of feature merging (works with feature grouping)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 29 Jun 2016 17:56:19 -0400 |
parents | 7c38250ddfc7 |
children |
rev | line source |
---|---|
635
6ae68383071e
corrected issue with tests requiring shapely, adding a separate test file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
1 >>> from moving import * |
6ae68383071e
corrected issue with tests requiring shapely, adding a separate test file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
2 >>> from shapely.geometry import Polygon |
781
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
3 >>> from shapely.prepared import prep |
635
6ae68383071e
corrected issue with tests requiring shapely, adding a separate test file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
4 |
6ae68383071e
corrected issue with tests requiring shapely, adding a separate test file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
5 >>> t1 = Trajectory([[0.5,1.5,2.5],[0.5,3.5,6.5]]) |
781
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
6 >>> poly = Polygon([[0,0],[4,0],[4,3],[0,3]]) |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
7 >>> sub1, sub2 = t1.getTrajectoryInPolygon(poly) |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
8 >>> sub1 |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
9 (0.500000,0.500000) |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
10 >>> sub1, sub2 = t1.getTrajectoryInPolygon(Polygon([[10,10],[14,10],[14,13],[10,13]])) |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
11 >>> sub1.length() |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
12 0 |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
13 >>> sub1, sub2 = t1.getTrajectoryInPolygon(prep(poly)) |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
14 >>> sub1 |
635
6ae68383071e
corrected issue with tests requiring shapely, adding a separate test file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
15 (0.500000,0.500000) |
781
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
16 >>> t2 = t1.differentiate(True) |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
17 >>> sub1, sub2 = t1.getTrajectoryInPolygon(prep(poly), t2) |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
18 >>> sub1.length() == sub2.length() |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
19 True |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
20 >>> sub1 |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
21 (0.500000,0.500000) |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
22 >>> sub2 |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
23 (1.000000,3.000000) |
635
6ae68383071e
corrected issue with tests requiring shapely, adding a separate test file
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
24 |
781
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
25 >>> t1.proportionInPolygon(poly, 0.5) |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
26 False |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
27 >>> t1.proportionInPolygon(poly, 0.3) |
7c38250ddfc7
updated to deal with prepared polygons from shapely, and to extract the same positions from a second trajectory in a polygon (for velocities for example)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
635
diff
changeset
|
28 True |