|
10 | 10 | # our imports |
11 | 11 | import shapefile |
12 | 12 |
|
13 | | -# define valid shape tuples of (type, points, parts indexes, and expected geo interface output) |
14 | | -# test all sorts, incl no holes, hole in singlepoly, hole in multipoly, nested holes and polys |
| 13 | +# define various test shape tuples of (type, points, parts indexes, and expected geo interface output) |
15 | 14 | geo_interface_tests = [ (shapefile.POINT, # point |
16 | 15 | [(1,1)], |
17 | 16 | [], |
|
127 | 126 | ], |
128 | 127 | ]} |
129 | 128 | ), |
| 129 | + (shapefile.POLYGON, # multi polygon, holes incl orphaned holes (unordered), should raise warning |
| 130 | + [(1,1),(1,9),(9,9),(9,1),(1,1), # exterior 1 |
| 131 | + (11,11),(11,19),(19,19),(19,11),(11,11), # exterior 2 |
| 132 | + (12,12),(14,12),(14,14),(12,14),(12,12), # hole 2.1 |
| 133 | + (15,15),(17,15),(17,17),(15,17),(15,15), # hole 2.2 |
| 134 | + (95,95),(97,95),(97,97),(95,97),(95,95), # hole x.1 (orphaned hole, should be interpreted as exterior) |
| 135 | + (2,2),(4,2),(4,4),(2,4),(2,2), # hole 1.1 |
| 136 | + (5,5),(7,5),(7,7),(5,7),(5,5), # hole 1.2 |
| 137 | + ], |
| 138 | + [0,5,10,15,20,25,30], |
| 139 | + {'type':'MultiPolygon','coordinates':[ |
| 140 | + [ # poly 1 |
| 141 | + [(1,1),(1,9),(9,9),(9,1),(1,1)], # exterior |
| 142 | + [(2,2),(4,2),(4,4),(2,4),(2,2)], # hole 1 |
| 143 | + [(5,5),(7,5),(7,7),(5,7),(5,5)], # hole 2 |
| 144 | + ], |
| 145 | + [ # poly 2 |
| 146 | + [(11,11),(11,19),(19,19),(19,11),(11,11)], # exterior |
| 147 | + [(12,12),(14,12),(14,14),(12,14),(12,12)], # hole 1 |
| 148 | + [(15,15),(17,15),(17,17),(15,17),(15,15)], # hole 2 |
| 149 | + ], |
| 150 | + [ # poly 3 (orphaned hole) |
| 151 | + [(95,95),(97,95),(97,97),(95,97),(95,95)], # exterior |
| 152 | + ], |
| 153 | + ]} |
| 154 | + ), |
| 155 | + (shapefile.POLYGON, # multi polygon, exteriors with wrong orientation (be nice and interpret as such) |
| 156 | + [(1,1),(9,1),(9,9),(1,9),(1,1), # exterior with hole-orientation |
| 157 | + (11,11),(19,11),(19,19),(11,19),(11,11), # exterior with hole-orientation |
| 158 | + ], |
| 159 | + [0,5], |
| 160 | + {'type':'MultiPolygon','coordinates':[ |
| 161 | + [ # poly 1 |
| 162 | + [(1,1),(9,1),(9,9),(1,9),(1,1)], |
| 163 | + ], |
| 164 | + [ # poly 2 |
| 165 | + [(11,11),(19,11),(19,19),(11,19),(11,11)], |
| 166 | + ], |
| 167 | + ]} |
| 168 | + ), |
130 | 169 | ] |
131 | 170 |
|
132 | 171 | def test_empty_shape_geo_interface(): |
|
0 commit comments