def main(): device = xy.Device() time.sleep(2) device.pen_up() time.sleep(1) device.home() print 'main' im = cv2.imread('/Users/fogleman/Workspace/maptiles/zoom20clean.png') im = isolate_buildings(im) # im = combine_images() contours = find_contours(im) contours = filter_contours(contours) print len(contours) im[:] = 0 cv2.drawContours(im, contours, -1, 255, -1) cv2.imwrite('out.png', im) paths = contour_paths(contours) print 'scaling paths' drawing = xy.Drawing(paths).rotate_and_scale_to_fit(315, 380, step=90).scale(1, -1) drawing = drawing.move(300, 0, 1, 0) drawing.render().write_to_png('buildings.png') print 'drawing paths' paths = drawing.paths paths.sort(key=lambda path: path[0][1]) n = 100 for i in range(0, len(paths), n): print i group = paths[i:i + n] group.sort(key=lambda path: path[0][0]) for path in group: device.draw(xy.simplify(path, 0.05))
def main(): device = xy.Device() time.sleep(2) device.pen_up() time.sleep(1) device.home() model = Model() for x, y in polygon(5, 0.35): model.add(x, y, 1) model.add(0.5, 0.5, 0.1) total = 0 while True: paths = [] print 'generating paths' for _ in range(250): x = random.random() y = random.random() path = create_path(model, 315, 0, 35, x, y, -1, 100) path = xy.simplify(path) paths.append(path) print 'sorting paths' paths = xy.sort_paths(paths, 1000000) print 'drawing paths' for path in paths: total += 1 print '%5d: %2d points @ (%.3f, %.3f)' % ( total, len(path), path[0][0], path[0][1]) device.draw(path)
def main(): device = xy.Device() time.sleep(2) device.pen_up() time.sleep(1) device.home() model = Model() for x, y in polygon(5, 0.35): model.add(x, y, 1) model.add(0.5, 0.5, 0.1) total = 0 while True: paths = [] print 'generating paths' for _ in range(250): x = random.random() y = random.random() path = create_path(model, 315, 0, 35, x, y, -1, 100) path = xy.simplify(path) paths.append(path) print 'sorting paths' paths = xy.sort_paths(paths, 1000000) print 'drawing paths' for path in paths: total += 1 print '%5d: %2d points @ (%.3f, %.3f)' % (total, len(path), path[0][0], path[0][1]) device.draw(path)
def main(): device = xy.Device() time.sleep(2) device.pen_up() time.sleep(1) device.home() print "main" im = cv2.imread("/Users/fogleman/Workspace/maptiles/zoom20clean.png") im = isolate_buildings(im) # im = combine_images() contours = find_contours(im) contours = filter_contours(contours) print len(contours) im[:] = 0 cv2.drawContours(im, contours, -1, 255, -1) cv2.imwrite("out.png", im) paths = contour_paths(contours) print "scaling paths" drawing = xy.Drawing(paths).rotate_and_scale_to_fit(315, 380, step=90).scale(1, -1) drawing = drawing.move(300, 0, 1, 0) drawing.render().write_to_png("buildings.png") print "drawing paths" paths = drawing.paths paths.sort(key=lambda path: path[0][1]) n = 100 for i in range(0, len(paths), n): print i group = paths[i : i + n] group.sort(key=lambda path: path[0][0]) for path in group: device.draw(xy.simplify(path, 0.05))
def main(): device = xy.Device() time.sleep(2) device.pen_up() time.sleep(1) device.home() print 'parsing osm file' h = Handler() p = OSMParser(None, h.on_nodes, h.on_ways, h.on_relations, h.on_coords) p.parse('/Users/fogleman/Workspace/Manhattan/osm/manhattan.osm.pbf') print 'creating paths' paths = h.create_paths() print len(paths) print 'creating drawing' drawing = xy.Drawing(paths).scale(1, -1).scale_to_fit(315, 380) # print 'rendering drawing' # drawing.render().write_to_png('manhattan.png') paths = drawing.paths paths.sort(key=lambda path: path[0][1]) n = 250 for i in range(0, len(paths), n): print i for path in xy.sort_paths(paths[i:i+n], 500000): device.draw(xy.simplify(path, 0.1))
def main(): device = xy.Device() time.sleep(2) device.pen_up() time.sleep(1) device.home() print 'parsing osm file' h = Handler() p = OSMParser(None, h.on_nodes, h.on_ways, h.on_relations, h.on_coords) p.parse('/Users/fogleman/Workspace/Manhattan/osm/manhattan.osm.pbf') print 'creating paths' paths = h.create_paths() print len(paths) print 'creating drawing' drawing = xy.Drawing(paths).scale(1, -1).scale_to_fit(315, 380) # print 'rendering drawing' # drawing.render().write_to_png('manhattan.png') paths = drawing.paths paths.sort(key=lambda path: path[0][1]) n = 250 for i in range(0, len(paths), n): print i for path in xy.sort_paths(paths[i:i + n], 500000): device.draw(xy.simplify(path, 0.1))