def handle(self, *args, **options): routes = glob(options['input']+'/routes-*.json') routes = sorted(routes, lambda x,y:cmp(stat(path.abspath(x))[8], stat(path.abspath(y))[8])) segment = 0 img = None for route in routes: self.stdout.write('Opening route "%s"\n' % route) rfile = open(route, 'r') fc = json.load(rfile) rfile.close() if segment == 0: self.stdout.write('Creating image file.\n') img = Image('1280x720', 'white') img.draw(DrawableStrokeColor('black')) img.draw(DrawableStrokeOpacity(0.01)) img.draw(DrawableStrokeWidth(1.0)) for i,feature in enumerate(fc['features']): coords = feature['geometry']['coordinates'] coords = map(lambda x:self.proj(x), coords) for start,end in zip(coords[0:-1],coords[1:]): img.draw(DrawableLine(start[0], start[1], end[0], end[1])) segment += 1 if segment == options['number']: self.stdout.write('Writing image file "%s.png".\n' % route) img.write(route + '.png') segment = 0
def handle(self, *args, **options): routes = glob(options['input'] + '/routes-*.json') routes = sorted( routes, lambda x, y: cmp( stat(path.abspath(x))[8], stat(path.abspath(y))[8])) segment = 0 img = None for route in routes: self.stdout.write('Opening route "%s"\n' % route) rfile = open(route, 'r') fc = json.load(rfile) rfile.close() if segment == 0: self.stdout.write('Creating image file.\n') img = Image('1280x720', 'white') img.draw(DrawableStrokeColor('black')) img.draw(DrawableStrokeOpacity(0.01)) img.draw(DrawableStrokeWidth(1.0)) for i, feature in enumerate(fc['features']): coords = feature['geometry']['coordinates'] coords = map(lambda x: self.proj(x), coords) for start, end in zip(coords[0:-1], coords[1:]): img.draw(DrawableLine(start[0], start[1], end[0], end[1])) segment += 1 if segment == options['number']: self.stdout.write('Writing image file "%s.png".\n' % route) img.write(route + '.png') segment = 0