@@ -305,7 +305,7 @@ def organize_polygon_rings(rings):
305305 ext_i = sorted (exterior_candidates , key = lambda x : abs (signed_area (exteriors [x ])))[0 ]
306306 hole_exteriors [hole_i ] = [ext_i ]
307307
308- # check for holes that are orphaned (not contained by any exterior)
308+ # separate out holes that are orphaned (not contained by any exterior)
309309 orphan_holes = []
310310 for hole_i ,exterior_candidates in list (hole_exteriors .items ()):
311311 if not exterior_candidates :
@@ -321,7 +321,6 @@ def organize_polygon_rings(rings):
321321 # find relevant holes
322322 poly_holes = []
323323 for hole_i ,exterior_candidates in list (hole_exteriors .items ()):
324-
325324 # hole is relevant if previously matched with this exterior
326325 if exterior_candidates [0 ] == ext_i :
327326 poly_holes .append ( holes [hole_i ] )
@@ -330,12 +329,13 @@ def organize_polygon_rings(rings):
330329
331330 # add orphan holes as exteriors
332331 for hole_i in orphan_holes :
333- poly = [holes [hole_i ]]
332+ ext = holes [hole_i ] # could potentially reverse their order, but in geojson winding order doesn't matter
333+ poly = [ext ]
334334 polys .append (poly )
335335
336336 return polys
337337
338- # no exteriors, bug?
338+ # no exteriors, be nice and assume due to incorrect winding order
339339 else :
340340 warnings .warn ('Shapefile shape has invalid polygon: no exterior rings found (must have clockwise orientation); interpreting holes as exteriors.' )
341341 exteriors = holes # could potentially reverse their order, but in geojson winding order doesn't matter
0 commit comments