Skip to content

Commit a9caa32

Browse files
committed
Revert "Replace another test of in dict_.keys() with a defaultdict, and simplify nearby code."
This reverts commit 7a4b00f.
1 parent 7a4b00f commit a9caa32

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

shapefile.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
__version__ = "2.3.1"
1010

1111
import array
12-
import collections
1312
import io
1413
import logging
1514
import os
@@ -394,11 +393,12 @@ def organize_polygon_rings(rings, return_errors=None):
394393
return polys
395394

396395
# first determine each hole's candidate exteriors based on simple bbox contains test
397-
hole_exteriors = collections.defaultdict(list)
398-
for hole_i in xrange(len(holes)):
396+
hole_exteriors = dict([(hole_i, []) for hole_i in xrange(len(holes))])
397+
exterior_bboxes = [ring_bbox(ring) for ring in exteriors]
398+
for hole_i in hole_exteriors.keys():
399399
hole_bbox = ring_bbox(holes[hole_i])
400-
for ext_i, ring in enumerate(exteriors):
401-
if bbox_contains(ring_bbox(ring), hole_bbox):
400+
for ext_i, ext_bbox in enumerate(exterior_bboxes):
401+
if bbox_contains(ext_bbox, hole_bbox):
402402
hole_exteriors[hole_i].append(ext_i)
403403

404404
# then, for holes with still more than one possible exterior, do more detailed hole-in-ring test

0 commit comments

Comments
 (0)