From cba705bf14656fc150c3c6f7acb0494edecca55e Mon Sep 17 00:00:00 2001 From: ansate Date: Mon, 25 Jul 2011 22:23:23 +0000 Subject: [PATCH] one more tweak to AREA_BOUND and removed the bit about interiors that intersect the edges of the city - didn't do what I wanted it too. --- blockr.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/blockr.py b/blockr.py index 37fa310..ef0f988 100644 --- a/blockr.py +++ b/blockr.py @@ -10,7 +10,7 @@ SCALE_FACTOR = 111111.0 # meters per degree latitude #ACTION_THRESHOLD = 2.0/math.sqrt(1000.0) # 1 point closer than 1km ACTION_THRESHOLD = 20.0/math.sqrt(1000.0) # 1 point closer than 1km -AREA_BOUND = 0.002 +AREA_BOUND = 0.001 TARGET_ASSIGN_LEVEL = 0.75 name_file, line_file, point_file = sys.argv[1:4] @@ -199,19 +199,14 @@ def score_block(polygon): #pull out any holes in the resulting Polygon/Multipolygon if type(city) is Polygon: 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) @@ -243,7 +238,6 @@ def score_block(polygon): holes = unassigned print >>sys.stderr, "%d retried, %d unassigned." % (retries, len(unassigned)) - print >>sys.stderr, "Buffering polygons." for place_id, polygon in polygons.items(): if type(polygon) is Polygon: @@ -256,6 +250,7 @@ def score_block(polygon): polygon = MultiPolygon(bits) polygons[place_id] = polygon.buffer(0) + print >>sys.stderr, "Writing output." features = [] for place_id, poly in polygons.items():