Commit 9be24297 authored by liyuanhong's avatar liyuanhong

完成了模拟器的轨迹查询功能

parent bfc87ff7
{"time": {"dateTime": "2020-08-04 10:10:21", "date": "2020-08-04", "time": "10:10:21"}, "curDayTravel": {"todayTotalMilleage": 415, "todayTotalOil": 40, "todayTotalTime": 25, "theMilleage": 415, "theOil": 40, "theTime": 25}, "travelData": {"totalMilleage": 653410, "totalOil": 57475, "totalTime": 39385}, "event": {"threeRapid": {"totalRapidlyAccelerate": 58, "totalSharpSlowdown": 47, "totalSharpTurn": 49}}} {"time": {"dateTime": "2020-08-04 10:10:21", "date": "2020-08-04", "time": "10:10:21"}, "curDayTravel": {"todayTotalMilleage": 1093, "todayTotalOil": 88, "todayTotalTime": 67, "theMilleage": 678, "theOil": 48, "theTime": 42}, "travelData": {"totalMilleage": 654088, "totalOil": 57523, "totalTime": 39427}, "event": {"threeRapid": {"totalRapidlyAccelerate": 58, "totalSharpSlowdown": 47, "totalSharpTurn": 49}}}
\ No newline at end of file \ No newline at end of file
...@@ -21,6 +21,7 @@ from views.messageTools.M_simulater_view import M_simulater_view ...@@ -21,6 +21,7 @@ from views.messageTools.M_simulater_view import M_simulater_view
from views.messageTools.M_simulater_process import M_simulater_process from views.messageTools.M_simulater_process import M_simulater_process
from views.otherTools.mapTools_view import mapTools_view from views.otherTools.mapTools_view import mapTools_view
from views.otherTools.mapTools_process import mapTools_process
app = Flask(__name__) app = Flask(__name__)
app.register_blueprint(setting_view,url_prefix = "/protocolTools/setting_view") app.register_blueprint(setting_view,url_prefix = "/protocolTools/setting_view")
...@@ -44,6 +45,7 @@ app.register_blueprint(M_simulater_view,url_prefix = "/messageTools/M_simulater_ ...@@ -44,6 +45,7 @@ app.register_blueprint(M_simulater_view,url_prefix = "/messageTools/M_simulater_
app.register_blueprint(M_simulater_process,url_prefix = "/messageTools/M_simulater_process") app.register_blueprint(M_simulater_process,url_prefix = "/messageTools/M_simulater_process")
app.register_blueprint(mapTools_view,url_prefix = "/otherTools/mapTools_view") app.register_blueprint(mapTools_view,url_prefix = "/otherTools/mapTools_view")
app.register_blueprint(mapTools_process,url_prefix = "/otherTools/mapTools_process")
@app.route('/') @app.route('/')
def hello(): def hello():
......
...@@ -113,18 +113,17 @@ ...@@ -113,18 +113,17 @@
} }
格式'></textarea> 格式'></textarea>
<div> <div>
<select id="simulatorType" class="form-control" style="width:130px;"> <select id="simulatorType" class="form-control" style="width:130px;" onchange="getNewLines(this)">
<option value="0">M500模拟器</option> <option value="0">M500模拟器</option>
<option value="16">M300模拟器</option> <option value="1">M300模拟器</option>
<option value="32">车安优模拟器</option> <option value="2">车安优模拟器</option>
</select> </select>
<select id="witchLine" class="form-control" style="width:150px;"> <select id="witchLine" class="form-control" style="width:150px;">
<option value="0">自动模式</option> {% for key,value in arg["gpsLines"].items() %}
<option value="16">单GPS模式</option> <option value="{{ key }}">{{ value }}</option>
<option value="32">单BDS模式</option> {% endfor %}
<option value="48">GPS+BDS双模式</option>
</select> </select>
<button type="button" class="btn btn-default" onclick="distance()">查询</button> <button type="button" class="btn btn-default" onclick="showModGpsLine()">查询</button>
</div> </div>
</div> </div>
<div id="container" style="width:100%; height: 750px;"> <div id="container" style="width:100%; height: 750px;">
...@@ -415,7 +414,78 @@ ...@@ -415,7 +414,78 @@
} }
$("#lineData1").val(""); $("#lineData1").val("");
} }
//切换模拟器后获取新的轨迹数据
function getNewLines(e){
var type = $(e).val();
var data = {};
data["type"] = type;
var host = window.location.host;
$("#showFeedback").val("")
$.ajax({
url:"http://" + host + "/otherTools/mapTools_process/getGPSLineList",
type:"post",
data:data,
dataType:"json",
success:function(data){
if(data.status == 200){
$("#witchLine").children().remove();
var gpsLines = data.gpsLines;
for(var item in gpsLines){
$("#witchLine").append("<option value=" + item + ">" + gpsLines[item] + "</option>");
}
}else{
alert(data.message);
}
}
});
}
//点击查看gpsline
function showModGpsLine(){
var type = $("#simulatorType").val();
var gpsLine = $("#witchLine option:selected").val();
var data = {};
data["type"] = type;
data["gpsLine"] = gpsLine;
var host = window.location.host;
$("#showFeedback").val("")
$.ajax({
url:"http://" + host + "/otherTools/mapTools_process/getGPSLineData",
type:"post",
data:data,
dataType:"json",
success:function(data){
if(data.status == 200){
var modGpsLines = data["gpsLines"];
if(showLineObj != undefined){
map.remove(showLineObj);
}
for(var j = 0;j < modGpsLines.length;j++){
var cvtGps = coordtransform.wgs84togcj02(parseFloat(modGpsLines[j][0]), parseFloat(modGpsLines[j][1]));
cvtGps[0] = cvtGps[0].toFixed(6);
cvtGps[1] = cvtGps[1].toFixed(6);
modGpsLines[j] = cvtGps;
}
var centerPoint = modGpsLines[parseInt(modGpsLines.length / 2)];
// 绘制轨迹
showLineObj = new AMap.Polyline({
map: map,
path: modGpsLines,
showDir:true,
strokeColor: "#28F", //线颜色
// strokeOpacity: 1, //线透明度
strokeWeight: 6, //线宽
// strokeStyle: "solid" //线样式
});
map.setCenter(centerPoint);
}else{
alert(data.message);
}
}
});
}
</script> </script>
{% endblock %} {% endblock %}
</div> </div>
......
#coding:utf-8
from flask import Blueprint ,Response,request
from configparser import ConfigParser
from lib.protocol.reportPlateform.Common_res import Common_res
from lib.socket.ClientSocket import ClientSocket
import json
import traceback
import binascii
from lib.util import fileUtil
mapTools_process = Blueprint('mapTools_process', __name__)
##########################################
# 【接口类型】获取模拟器的GPSline
##########################################
@mapTools_process.route("/getGPSLineList",methods=['POST'])
def getGPSLineList():
type = int(request.form.get("type"))
data = {}
if (type == None):
data["status"] = "4003"
data["message"] = "Info: 请检查是否传入了空数据!"
return Response(json.dumps(data), mimetype='application/json')
else:
try:
if(type == 0):
data["status"] = "200"
data["gpsLines"] = fileUtil.getDirFilesListMap("data/protocolTools/GPSLines")
elif(type == 1):
data["status"] = "200"
data["gpsLines"] = fileUtil.getDirFilesListMap("data/m300Tools/GPSLines")
elif(type == 2):
data["status"] = "200"
data["gpsLines"] = fileUtil.getDirFilesListMap("data/messageTools/GPSLines")
except BaseException as e:
# 打印异常信息
traceback.print_exc()
data["status"] = "4003"
data["message"] = "Error: 处理失败!"
return Response(json.dumps(data), mimetype='application/json')
##########################################
# 【接口类型】获取GPSline 数据
##########################################
@mapTools_process.route("/getGPSLineData",methods=['POST'])
def getGPSLineData():
type = int(request.form.get("type"))
gpsLine = request.form.get("gpsLine")
data = {}
if (type == None or gpsLine == None):
data["status"] = "4003"
data["message"] = "Info: 请检查是否传入了空数据!"
return Response(json.dumps(data), mimetype='application/json')
else:
try:
if (type == 0):
with open("data/protocolTools/GPSLines/" + gpsLine, "r", encoding="utf-8") as fi:
content = fi.read()
conJson = json.loads(content)
gpsLines = conJson["GPSLine"]
theGpsLines = []
for item in gpsLines:
tem = []
tem.append(float(item["lng"].replace("\n","")))
tem.append(float(item["lat"].replace("\n","")))
theGpsLines.append(tem)
data["status"] = "200"
data["gpsLines"] = theGpsLines
elif (type == 1):
with open("data/m300Tools/GPSLines/" + gpsLine, "r", encoding="utf-8") as fi:
content = fi.read()
conJson = json.loads(content)
gpsLines = conJson["GPSLine"]
theGpsLines = []
for item in gpsLines:
tem = []
tem.append(float(item["lng"].replace("\n","")))
tem.append(float(item["lat"].replace("\n","")))
theGpsLines.append(tem)
data["status"] = "200"
data["gpsLines"] = theGpsLines
elif (type == 2):
with open("data/messageTools/GPSLines/" + gpsLine, "r", encoding="utf-8") as fi:
content = fi.read()
conJson = json.loads(content)
gpsLines = conJson["GPSLine"]
theGpsLines = []
for item in gpsLines:
tem = []
tem.append(float(item["lng"].replace("\n","")))
tem.append(float(item["lat"].replace("\n","")))
theGpsLines.append(tem)
data["status"] = "200"
data["gpsLines"] = theGpsLines
except BaseException as e:
# 打印异常信息
traceback.print_exc()
data["status"] = "4003"
data["message"] = "Error: 处理失败!"
return Response(json.dumps(data), mimetype='application/json')
...@@ -19,4 +19,5 @@ def maptool_page(): ...@@ -19,4 +19,5 @@ def maptool_page():
arg = {} arg = {}
path = "otherTools/maptool.html" path = "otherTools/maptool.html"
arg["path"] = reqPath.split("/") arg["path"] = reqPath.split("/")
arg["gpsLines"] = fileUtil.getDirFilesListMap("data/protocolTools/GPSLines")
return render_template(path,arg=arg) return render_template(path,arg=arg)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment