|
@@ -9,6 +9,8 @@ app = Flask(__name__)
|
|
# 存储dddd数据、satellite数据
|
|
# 存储dddd数据、satellite数据
|
|
dddd_array = []
|
|
dddd_array = []
|
|
satellite_array = []
|
|
satellite_array = []
|
|
|
|
+global final_data
|
|
|
|
+final_data = []
|
|
|
|
|
|
@app.route("/")
|
|
@app.route("/")
|
|
def hello_world():
|
|
def hello_world():
|
|
@@ -61,10 +63,27 @@ def get_traj():
|
|
satellite_array.append((read_satellite_data("C:\\fire\\simulation",str)))
|
|
satellite_array.append((read_satellite_data("C:\\fire\\simulation",str)))
|
|
|
|
|
|
# 获取最终要返回给请求端的json list
|
|
# 获取最终要返回给请求端的json list
|
|
|
|
+ global final_data
|
|
final_data = get_position_by_time(starttime, stoptime, dddd_array, satellite_array, timestep, redunit, satellite)
|
|
final_data = get_position_by_time(starttime, stoptime, dddd_array, satellite_array, timestep, redunit, satellite)
|
|
|
|
|
|
return jsonify({"status":"success"},{"data":final_data}), 200
|
|
return jsonify({"status":"success"},{"data":final_data}), 200
|
|
|
|
|
|
-# @app.route("/pos", methods=["GET","POST"])
|
|
|
|
-# def get_pos():
|
|
|
|
-
|
|
|
|
|
|
+@app.route("/pos", methods=["GET","POST"])
|
|
|
|
+def get_pos():
|
|
|
|
+ if len(final_data) == 0:
|
|
|
|
+ return jsonify({}), 200
|
|
|
|
+ posjson = request.form.to_dict()
|
|
|
|
+ currentTime = posjson['simulation_time']
|
|
|
|
+ print(currentTime)
|
|
|
|
+ currentTime = datetime.datetime.strptime(currentTime, "%Y-%m-%d %H:%M:%S.%f")
|
|
|
|
+
|
|
|
|
+ # 越界检查
|
|
|
|
+ starttime = datetime.datetime.strptime(final_data[0]["dateTime"], "%d %b %Y %H:%M:%S.%f")
|
|
|
|
+ stoptime = datetime.datetime.strptime(final_data[-2]["dateTime"], "%d %b %Y %H:%M:%S.%f")
|
|
|
|
+ steptime = (datetime.datetime.strptime(final_data[1]["dateTime"], "%d %b %Y %H:%M:%S.%f") - datetime.datetime.strptime(final_data[0]["dateTime"], "%d %b %Y %H:%M:%S.%f")).total_seconds()
|
|
|
|
+ if currentTime < starttime or currentTime > stoptime:
|
|
|
|
+ return jsonify({"status":"success"},{"data":None}), 200
|
|
|
|
+ else:
|
|
|
|
+ # 计算下标
|
|
|
|
+ idx = int((currentTime - starttime).total_seconds()/steptime)
|
|
|
|
+ return jsonify({"status":"success"},{"data":final_data[idx]}), 200
|