def flask_to_geojson(source: MapSource): if not source.is_loaded: source.load() resp = render_geojson(source) return resp
def get_geojson(request, source: MapSource): if not source.is_loaded: source.load() response = render_geojson(source) return JsonResponse(response, safe=False)
def get_tile(request, source: MapSource, z=0, x=0, y=0): if not source.is_loaded: print(f'Dynamically Loading Data {source.name}', file=sys.stdout) source.load() img = render_map(source, x=int(x), y=int(y), z=int(z)) return StreamingHttpResponse(img.to_bytesio(), content_type='image/png')
def flask_to_tile(source: MapSource, z=0, x=0, y=0): if not source.is_loaded: print(f'Dynamically Loading Data {source.name}', file=sys.stdout) source.load() img = render_map(source, x=int(x), y=int(y), z=int(z)) return send_file(img.to_bytesio(), mimetype='image/png')
def get_image(request, source: MapSource, xmin=-20e6, ymin=-20e6, xmax=20e6, ymax=20e6, height=500, width=500): if not source.is_loaded: source.load() img = render_map(source, xmin=float(xmin), ymin=float(ymin), xmax=float(xmax), ymax=float(ymax), height=int(height), width=int(width)) return StreamingHttpResponse(img.to_bytesio(), content_type='image/png')
def flask_to_image(source: MapSource, xmin=-20e6, ymin=-20e6, xmax=20e6, ymax=20e6, height=500, width=500): if not source.is_loaded: source.load() img = render_map(source, xmin=float(xmin), ymin=float(ymin), xmax=float(xmax), ymax=float(ymax), height=int(height), width=int(width)) return send_file(img.to_bytesio(), mimetype='image/png')
def flask_to_wms(source: MapSource): if not source.is_loaded: source.load() height = request.args.get('height') width = request.args.get('width') bbox = request.args.get('bbox') xmin, ymin, xmax, ymax = bbox.split(',') img = render_map(source, xmin=float(xmin), ymin=float(ymin), xmax=float(xmax), ymax=float(ymax), height=int(height), width=int(width)) return send_file(img.to_bytesio(), mimetype='image/png')
def get_wms(request, source: MapSource): if not source.is_loaded: source.load() height = request.GET.get('height') width = request.GET.get('width') bbox = request.GET.get('bbox', '') xmin, ymin, xmax, ymax = bbox.split(',') img = render_map(source, xmin=float(xmin), ymin=float(ymin), xmax=float(xmax), ymax=float(ymax), height=int(height), width=int(width)) return StreamingHttpResponse(img.to_bytesio(), content_type='image/png')
def flask_to_geojson(source: MapSource): if not source.is_loaded: source.load() q = request.args.get('q') limit = request.args.get('limit') offset = request.args.get('offset') simplify = request.args.get('simplify') bbox = request.args.get('bbox') resp = render_geojson(source) return resp