Skip to content

Commit

Permalink
one more tweak to AREA_BOUND and removed the bit about interiors that…
Browse files Browse the repository at this point in the history
… intersect the edges of the city - didn't do what I wanted it too.
  • Loading branch information
ansate committed Jul 25, 2011
1 parent 91ef4a6 commit cba705b
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions blockr.py
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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():
Expand Down

0 comments on commit cba705b

Please sign in to comment.