コード例 #1
0
ファイル: views.py プロジェクト: adorsk-noaa/georefine
def get_map(project_id):
    project = get_project(project_id)

    # Parse parameters.
    json_params = ""
    # If params key was provided, load params string.
    if request.args.get('PARAMS_KEY'):
        json_params = ks_util.getString(request.args.get('PARAMS_KEY'))

    # Parse custom parameters (overrides params key for testing purposes).
    if request.args.get('PARAMS'):
        json_params = request.args.get('PARAMS')

    params = json.loads(json_params)

    # Fix for unicode keys (py2.5 doesn't like them).
    str_params = {}
    for k,v in params.items():
        str_params[str(k).lower()] = v
    params = str_params

    wms_parameters = get_wms_parameters(request.args)

    fn = projects_services.get_data_map
    fn_args = [project]
    fn_kwargs = dict([('wms_parameters', wms_parameters)] + params.items())
    if app.config.get('GR_PROJECTS_CACHE'):
        map_image = _get_cached(
            project,
            fn,
            fn_args=fn_args,
            fn_kwargs=fn_kwargs,
            key_args=['get_data_map'],
            key_kwargs=fn_kwargs,
        )
    else:
        map_image = fn(*fn_args, **fn_kwargs)
    return Response(map_image, mimetype=wms_parameters['FORMAT'])
コード例 #2
0
ファイル: views.py プロジェクト: adorsk-noaa/georefine
def getString(key):
    s = ks_util.getString(key)
    return jsonify(s=s)