Permalink
Browse files

checking that the holes are not on the edges

doesn't quite work yet though..
  • Loading branch information...
1 parent 338d82f commit 91ef4a6356d5f561bca6669598606c0b5e1018c4 @ansate ansate committed Jul 22, 2011
Showing with 6 additions and 1 deletion.
  1. +6 −1 blockr.py
View
@@ -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)

0 comments on commit 91ef4a6

Please sign in to comment.