Skip to content

Commit

Permalink
checking that the holes are not on the edges
Browse files Browse the repository at this point in the history
doesn't quite work yet though..
  • Loading branch information
ansate committed Jul 22, 2011
1 parent 338d82f commit 91ef4a6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion blockr.py
Expand Up @@ -198,15 +198,20 @@ def score_block(polygon):

#pull out any holes in the resulting Polygon/Multipolygon
if type(city) is Polygon:
over = [city]
over = [city]
city_edges = [LinearRing(city.exterior.coords)]
elif type(city) is MultiPolygon:
over = city.geoms
city_edges = [LinearRing(p.exterior.coords) for p in city.geoms]
else:
print >>sys.stderr, "\rcity is of type %s, wtf." % (type(city))

holes = []
for poly in over:
holes.extend((Polygon(LinearRing(interior.coords)) for interior in poly.interiors))
print >>sys.stderr, "num holes %d" % len(holes)
holes = [hole for hole in holes if max([int(hole.intersects(edge)) for edge in city_edges]) == 0]
print >>sys.stderr, "num holes %d" % len(holes)

count = 0
total = len(holes)
Expand Down

0 comments on commit 91ef4a6

Please sign in to comment.