Update Trajectory
Description: Update an existing trajectory
URI: /datasets/trajectory/<name>?tid=<tid>
http method: PUT
Code
@app.route('/datasets/trajectory/<string:name>', methods=['PUT'])
def updateTrajectory(name):
args = request.args
if 'tid' in args:
tid = args['tid']
query = "DELETE FROM " + name +" WHERE tid=" + tid + ";"
conn.query(query)
if not request.json:
abort(400)
json_args = request.json
traj_points = json_args.get('trajectory')
for point in traj_points:
lon = point.get('lon')
lat = point.get('lat')
timestamp = point.get('timestamp')
query= "INSERT INTO " + name +" (tid,lon, lat, timestamp) VALUES ("+str(tid) +","+ str(lon)+","+ str(lat)+", "+str(timestamp)+");"
print query
conn.query(query)
return "Update trajectory :" + tid
else:
return "Missing parameter 'tid' "