calculate the density of ROI

Description: calculate the density of ROI
URI: /algo/density/<name>
args: rid = <ROI id> #MUST
http method: GET

@app.route('/algo/density/<name>', methods=['GET'])
def density(name):
    if 'rid' not in request.args:
        jsonify({"density":-1})
    ROI = name
    rid = request.args['rid']
    payload = {'rid':str(rid)}
    r = requests.get('http://127.0.0.1:5566/datasets/ROI/'+name+'?rid='+str(rid))


    if not len(r.json()['ROI']): return jsonify({"density":-1})

    if r.json()['name'] == 'error' : return jsonify({"density":-1})

    range = r.json()['ROI'][0]['range']
    payload = {'lon_s':str(range['west']), 'lon_e': str(range['east']),
        'lat_s':str(range['south']), 'lat_e': str(range['north'])}
    r = requests.get('http://127.0.0.1:5566/datasets/trajectory/'+name,params=payload)

    count = len(r.json()['trajectory'])

    return jsonify({"density":count})

results matching ""

    No results matching ""