Exemplo n.º 1
0
def get_ts(request):

    return_obj = {}

    if request.is_ajax() and request.method == 'POST':

        fType = request.POST["fType"]
        interaction = request.POST["interaction"]
        if interaction == 'Polygon':
            geom_data = request.POST["geom_data"]
            try:
                res_val = get_polygon_stats(geom_data,fType)
                return_obj["data"] = res_val
                return_obj["success"] = "success"
            except Exception as e:
                return_obj["error"] = "Error processing request: "+ str(e)
        else:
            geom_data = request.POST.getlist("geom_data[]")
            try:
                res_val = get_feature_stats(geom_data, fType)
                return_obj["data"] = res_val
                return_obj["success"] = "success"
            except Exception as e:
                return_obj["error"] = "Error processing request: "+ str(e)

    return JsonResponse(return_obj)
Exemplo n.º 2
0
def get_poly_ts(request):

    json_obj = {}

    if request.method == 'GET':
        info = request.GET

        suffix = info.get('variable')
        interval = info.get('interval')
        interval = interval.lower()
        year = info.get('year')
        geom = info.get('geom')

        try:

            ts = get_polygon_stats(suffix, geom, interval, year)

            json_obj["time_series"] = ts
            json_obj["success"] = "success"
            json_obj["interval"] = interval
        except Exception as e:
            json_obj["error"] = "Error processing request: " + str(e)

    return JsonResponse(json_obj)