Trajectory to ROI sequence

Description: Convert trajectory to a list of ROI
URI: /algo/tra2seq/<name>
args: d = <density>
http method: GET

@app.route('/algo/tra2seq/<name>', methods=['GET'])
def tra2seq(name):
    #cur = conn.cursor()

    if not request.json or 'points' not in request.json:
        return jsonify({'rid':[-1]})

    points = request.json.get("points","NULL");

    rid_list = []

    for point in points:
        lat = point['lat'];
        lon = point['lon'];

        if 'd' in request.args:
            url = "http://127.0.0.1:5566/datasets/ROI/"+name+"?p="+str(lon)+","+str(lat)+"&d="+str(request.args['d'])
        else:
            url = "http://127.0.0.1:5566/datasets/ROI/"+name+"?p="+str(lon)+","+str(lat)

        r = requests.get(url)

        if not len(r.json()['ROI']): continue

        rid = r.json()['ROI'][0]['rid']

        print rid

        if(len(rid_list) == 0):
            rid_list.append(rid)
        elif(rid_list[-1] != rid):
            rid_list.append(rid)

    return jsonify({'seq':rid_list})

results matching ""

    No results matching ""