Add a new ROI
Description: Add a new ROI to dataset
URI: /datasets/ROI/<name>
http method: POST
@app.route('/datasets/ROI/<string:name>', methods=['POST'])
def insert_roi(name):
if not request.json or 'range' not in request.json:
return('',400)
density = request.json.get('density',"NULL")
score = request.json.get('score',"NULL")
bound = request.json.get('range',"NULL")
try:
range = "BOX '"+str(bound['east'])+","+str(bound['north'])+","+str(bound['west'])+","+str(bound['south'])+"'"
except KeyError:
return('',400)
cur = conn.cursor()
query = "INSERT INTO roi."+name+"(density,score,range) VALUES ("+str(density)+","+str(score)+","+range+");"
try:
cur.execute(query)
except psycopg2.Error as e:
conn.rollback()
cur.close()
return(e.pgerror,400)
conn.commit()
cur.close()
return ('',200)