def output(): north = float(request.args.get('north', 1.0)) south = float(request.args.get('south', -1.0)) east = float(request.args.get('east', -1.0)) west = float(request.args.get('west', 1.0)) width = int(float(request.args.get('width', 1024))) height = int(float(request.args.get('height', 1024))) svg = bool(request.args.get('svg', False)) scale = float(request.args.get('scale', 1.0)) save = bool(request.args.get('save', False)) mr = MapRenderer(ACTUAL_PATH) mr.setBounds(west, south, east, north) mr.setSvg(svg) headers = {'Content-Type': 'image/png'} if save: headers = { 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename="output.png"' } return Response(mr.render(width, height, scale), headers=headers)
#!/usr/bin/env python from sys import argv from MapRenderer import MapRenderer if len(argv) < 8: print("usage: {0} <outputfile> <width> <height> <scale> <south> <west> <north> <east> <svg>\n coords in WGS84".format(argv[0])) exit() output = argv[1] width = int(argv[2]) height = int(argv[3]) scale = float(argv[4]) south = float(argv[5]) west = float(argv[6]) north = float(argv[7]) east = float(argv[8]) svg = len(argv) == 10 mr = MapRenderer() mr.setBounds(west, south, east, north) mr.setSvg(svg) fh = open(output, 'w') fh.write(mr.render(width, height, scale)) fh.close