tmap
This commit is contained in:
parent
64ae3e310f
commit
1332c38f5e
@ -383,9 +383,20 @@ def amap_key_input():
|
|||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
postvars = request.form.to_dict()
|
postvars = request.form.to_dict()
|
||||||
fleet.amap_key_input(postvars)
|
fleet.amap_key_input(postvars)
|
||||||
return redirect(url_for('amap_addr_input'))
|
return redirect(url_for('amap_key_input'))
|
||||||
else:
|
else:
|
||||||
return render_template("amap_key_input.html")
|
amap_key, amap_key_2 = fleet.get_amap_key()
|
||||||
|
return render_template("amap_key_input.html", amap_key=amap_key, amap_key_2=amap_key_2)
|
||||||
|
|
||||||
|
@app.route("/tmap_key_input", methods=['GET', 'POST'])
|
||||||
|
def tmap_key_input():
|
||||||
|
if request.method == 'POST':
|
||||||
|
postvars = request.form.to_dict()
|
||||||
|
fleet.tmap_key_input(postvars)
|
||||||
|
return redirect(url_for('tmap_key_input'))
|
||||||
|
else:
|
||||||
|
tmap_key = fleet.get_tmap_key()
|
||||||
|
return render_template("tmap_key_input.html", tmap_key=tmap_key)
|
||||||
|
|
||||||
@app.route("/amap_addr_input", methods=['GET', 'POST'])
|
@app.route("/amap_addr_input", methods=['GET', 'POST'])
|
||||||
def amap_addr_input():
|
def amap_addr_input():
|
||||||
@ -398,6 +409,16 @@ def amap_addr_input():
|
|||||||
amap_key, amap_key_2 = fleet.get_amap_key()
|
amap_key, amap_key_2 = fleet.get_amap_key()
|
||||||
return render_template("amap_addr_input.html", lon=lon, lat=lat, amap_key=amap_key, amap_key_2=amap_key_2)
|
return render_template("amap_addr_input.html", lon=lon, lat=lat, amap_key=amap_key, amap_key_2=amap_key_2)
|
||||||
|
|
||||||
|
@app.route("/tmap_addr_input", methods=['GET', 'POST'])
|
||||||
|
def tmap_addr_input():
|
||||||
|
if request.method == 'POST':
|
||||||
|
postvars = request.form.to_dict()
|
||||||
|
fleet.nav_confirmed(postvars)
|
||||||
|
return redirect(url_for('tmap_addr_input'))
|
||||||
|
else:
|
||||||
|
lon, lat = fleet.get_last_lon_lat()
|
||||||
|
return render_template("tmap_addr_input.html", lon=lon, lat=lat)
|
||||||
|
|
||||||
@app.route("/CurrentStep.json", methods=['GET'])
|
@app.route("/CurrentStep.json", methods=['GET'])
|
||||||
def find_CurrentStep():
|
def find_CurrentStep():
|
||||||
directory = "/data/openpilot/selfdrive/manager/"
|
directory = "/data/openpilot/selfdrive/manager/"
|
||||||
@ -453,6 +474,34 @@ def store_toggle_values_route():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({"error": "Failed to update values", "details": str(e)}), 400
|
return jsonify({"error": "Failed to update values", "details": str(e)}), 400
|
||||||
|
|
||||||
|
@app.route("/get_nav_status", methods=['GET'])
|
||||||
|
def get_nav_status():
|
||||||
|
nav_active = fleet.get_nav_active()
|
||||||
|
return jsonify({
|
||||||
|
"active": nav_active
|
||||||
|
})
|
||||||
|
|
||||||
|
@app.route("/get_system_status", methods=['GET'])
|
||||||
|
def get_system_status():
|
||||||
|
nav_active = fleet.get_nav_active()
|
||||||
|
gps_status = fleet.get_gps_status()
|
||||||
|
network_status = fleet.check_network_status()
|
||||||
|
|
||||||
|
return jsonify({
|
||||||
|
"nav_status": {
|
||||||
|
"active": nav_active,
|
||||||
|
"state": "导航中" if nav_active else "待机"
|
||||||
|
},
|
||||||
|
"gps_status": {
|
||||||
|
"active": gps_status["active"],
|
||||||
|
"signal": gps_status["signal"]
|
||||||
|
},
|
||||||
|
"network_status": {
|
||||||
|
"connected": network_status["connected"],
|
||||||
|
"type": network_status["type"]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
@app.route("/carinfo")
|
@app.route("/carinfo")
|
||||||
def carinfo():
|
def carinfo():
|
||||||
try:
|
try:
|
||||||
|
@ -410,7 +410,17 @@ def amap_key_input(postvars):
|
|||||||
token2 = postvars.get("amap_key_val_2").strip()
|
token2 = postvars.get("amap_key_val_2").strip()
|
||||||
params.put("AMapKey1", token)
|
params.put("AMapKey1", token)
|
||||||
params.put("AMapKey2", token2)
|
params.put("AMapKey2", token2)
|
||||||
return token
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def tmap_key_input(postvars):
|
||||||
|
try:
|
||||||
|
token = postvars["tmap_key"]
|
||||||
|
params.put("TMapKey", token)
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
def gcj02towgs84(lng, lat):
|
def gcj02towgs84(lng, lat):
|
||||||
dlat = transform_lat(lng - 105.0, lat - 35.0)
|
dlat = transform_lat(lng - 105.0, lat - 35.0)
|
||||||
@ -464,3 +474,28 @@ def store_toggle_values(updated_values):
|
|||||||
#params_memory.put_bool("FrogPilotTogglesUpdated", True)
|
#params_memory.put_bool("FrogPilotTogglesUpdated", True)
|
||||||
#time.sleep(1)
|
#time.sleep(1)
|
||||||
#params_memory.put_bool("FrogPilotTogglesUpdated", False)
|
#params_memory.put_bool("FrogPilotTogglesUpdated", False)
|
||||||
|
|
||||||
|
def get_gps_status():
|
||||||
|
try:
|
||||||
|
# 读取GPS状态
|
||||||
|
with open('/data/params/d/LastGPSPosition', 'r') as f:
|
||||||
|
content = f.read().strip()
|
||||||
|
if not content:
|
||||||
|
return {"active": False, "signal": "无信号"}
|
||||||
|
return {
|
||||||
|
"active": True,
|
||||||
|
"signal": "正常"
|
||||||
|
}
|
||||||
|
except:
|
||||||
|
return {"active": False, "signal": "未知"}
|
||||||
|
|
||||||
|
def check_network_status():
|
||||||
|
try:
|
||||||
|
# 检查网络连接
|
||||||
|
result = subprocess.run(['ping', '-c', '1', '-W', '1', '8.8.8.8'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
return {
|
||||||
|
"connected": result.returncode == 0,
|
||||||
|
"type": "已连接" if result.returncode == 0 else "未连接"
|
||||||
|
}
|
||||||
|
except:
|
||||||
|
return {"connected": False, "type": "未知"}
|
||||||
|
@ -15,4 +15,76 @@
|
|||||||
<br><a href='/error_logs'>Access Error Logs</a><br>
|
<br><a href='/error_logs'>Access Error Logs</a><br>
|
||||||
<br><a href='/about'>About Fleet Manager</a><br>
|
<br><a href='/about'>About Fleet Manager</a><br>
|
||||||
<br><a href='/amap_nav'>高德导航</a><br>
|
<br><a href='/amap_nav'>高德导航</a><br>
|
||||||
|
<br><a href='/tmap_addr_input'>TMap导航</a><br>
|
||||||
|
<br><a href='/tmap_key_input'>设置TMap API密钥</a><br>
|
||||||
|
|
||||||
|
<!-- 系统状态部分 -->
|
||||||
|
<div class="uk-card uk-card-default uk-card-body uk-margin-medium">
|
||||||
|
<h3 class="uk-card-title">系统状态</h3>
|
||||||
|
<div id="system-status" class="uk-grid-small uk-child-width-1-3@s uk-text-center" uk-grid>
|
||||||
|
<div>
|
||||||
|
<div class="uk-card uk-card-default uk-card-body uk-box-shadow-small">
|
||||||
|
<h4>导航状态</h4>
|
||||||
|
<div id="nav-status">
|
||||||
|
<span class="uk-label uk-label-warning">待机</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="uk-card uk-card-default uk-card-body uk-box-shadow-small">
|
||||||
|
<h4>GPS信号</h4>
|
||||||
|
<div id="gps-status">
|
||||||
|
<span class="uk-label uk-label-warning">检测中</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="uk-card uk-card-default uk-card-body uk-box-shadow-small">
|
||||||
|
<h4>网络状态</h4>
|
||||||
|
<div id="network-status">
|
||||||
|
<span class="uk-label uk-label-warning">检测中</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// 定期更新系统状态
|
||||||
|
function updateSystemStatus() {
|
||||||
|
fetch('/get_system_status')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
// 更新导航状态
|
||||||
|
document.getElementById('nav-status').innerHTML =
|
||||||
|
`<span class="uk-label ${data.nav_status.active ? 'uk-label-success' : 'uk-label-warning'}">
|
||||||
|
${data.nav_status.state}
|
||||||
|
</span>`;
|
||||||
|
|
||||||
|
// 更新GPS状态
|
||||||
|
document.getElementById('gps-status').innerHTML =
|
||||||
|
`<span class="uk-label ${data.gps_status.active ? 'uk-label-success' : 'uk-label-warning'}">
|
||||||
|
${data.gps_status.signal}
|
||||||
|
</span>`;
|
||||||
|
|
||||||
|
// 更新网络状态
|
||||||
|
document.getElementById('network-status').innerHTML =
|
||||||
|
`<span class="uk-label ${data.network_status.connected ? 'uk-label-success' : 'uk-label-warning'}">
|
||||||
|
${data.network_status.type}
|
||||||
|
</span>`;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
// 发生错误时显示错误状态
|
||||||
|
['nav-status', 'gps-status', 'network-status'].forEach(id => {
|
||||||
|
document.getElementById(id).innerHTML =
|
||||||
|
`<span class="uk-label uk-label-danger">错误</span>`;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 每5秒更新一次状态
|
||||||
|
setInterval(updateSystemStatus, 5000);
|
||||||
|
updateSystemStatus(); // 初始更新
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
253
selfdrive/frogpilot/fleetmanager/templates/tmap_addr_input.html
Normal file
253
selfdrive/frogpilot/fleetmanager/templates/tmap_addr_input.html
Normal file
@ -0,0 +1,253 @@
|
|||||||
|
{% extends "layout.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
tmap_addr_input
|
||||||
|
{% endblock %}
|
||||||
|
{% block main %}
|
||||||
|
<!-- Head section moved into body -->
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
||||||
|
<title>输入提示后查询</title>
|
||||||
|
<!-- UIkit CSS -->
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uikit@3.9.2/dist/css/uikit.min.css" />
|
||||||
|
<!-- UIkit JS -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/uikit@3.9.2/dist/js/uikit.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/uikit@3.9.2/dist/js/uikit-icons.min.js"></script>
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
#mapContainer {
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tmap-container {
|
||||||
|
height: 400px; /* Adjust height as needed */
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-group {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-group .button {
|
||||||
|
height: 28px;
|
||||||
|
line-height: 28px;
|
||||||
|
background-color: #0D9BF2;
|
||||||
|
color: #FFF;
|
||||||
|
border: 0;
|
||||||
|
outline: none;
|
||||||
|
padding-left: 5px;
|
||||||
|
padding-right: 5px;
|
||||||
|
border-radius: 3px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tmap-info-content {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- 地图和搜索区域 -->
|
||||||
|
<div>
|
||||||
|
<div class="uk-grid-match uk-grid-small uk-text-center" uk-grid>
|
||||||
|
<div class="uk-width-1-3@m">
|
||||||
|
<select id="save_type" class="uk-select">
|
||||||
|
<option value="recent">最近</option>
|
||||||
|
<option value="home">住家</option>
|
||||||
|
<option value="work">工作</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="uk-width-expand@m">
|
||||||
|
<input class="uk-input" type="text" id="keyword" name="keyword"
|
||||||
|
placeholder="请输入关键字:(选定后搜索)" onfocus='this.value=""' />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<input type="hidden" id="longitude" />
|
||||||
|
<input type="hidden" id="latitude" />
|
||||||
|
<div style="height: 600px" id="container"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="https://map.qq.com/api/gljs?v=1.exp&key=VXYBZ-HKFR6-7WYSQ-MSZCE-ZLFAJ-33FIW"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var map, marker, infoWindow;
|
||||||
|
var searchService, geocoder;
|
||||||
|
|
||||||
|
// 初始化地图
|
||||||
|
function initMap() {
|
||||||
|
const center = new TMap.LatLng({{lat}}, {{lon}});
|
||||||
|
//初始化地图
|
||||||
|
map = new TMap.Map(document.getElementById('container'), {
|
||||||
|
center: center,
|
||||||
|
zoom: 14,
|
||||||
|
pitch: 0,
|
||||||
|
rotation: 0,
|
||||||
|
viewMode: '2D',
|
||||||
|
showControl: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// 创建标记
|
||||||
|
marker = new TMap.MultiMarker({
|
||||||
|
map: map,
|
||||||
|
styles: {
|
||||||
|
"normal": new TMap.MarkerStyle({
|
||||||
|
width: 25,
|
||||||
|
height: 35,
|
||||||
|
anchor: { x: 16, y: 32 }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
geometries: []
|
||||||
|
});
|
||||||
|
|
||||||
|
// 初始化信息窗口
|
||||||
|
infoWindow = new TMap.InfoWindow({
|
||||||
|
map: map,
|
||||||
|
position: center,
|
||||||
|
offset: { x: 0, y: -32 }
|
||||||
|
});
|
||||||
|
infoWindow.close();
|
||||||
|
|
||||||
|
// 创建检索服务
|
||||||
|
searchService = new TMap.service.Search({
|
||||||
|
complete: function(result) {
|
||||||
|
handleSearchResult(result);
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
alert("搜索失败,请检查关键词");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 创建地理编码服务
|
||||||
|
geocoder = new TMap.service.Geocoder();
|
||||||
|
|
||||||
|
// 绑定搜索事件
|
||||||
|
document.getElementById('keyword').addEventListener('keydown', function(e) {
|
||||||
|
if (e.keyCode === 13) {
|
||||||
|
var keyword = this.value.trim();
|
||||||
|
if (keyword) {
|
||||||
|
searchService.searchAddressDetail({
|
||||||
|
keyword: keyword,
|
||||||
|
region: '全国',
|
||||||
|
pageIndex: 1,
|
||||||
|
pageSize: 10
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 地图点击事件
|
||||||
|
map.on('click', function(evt) {
|
||||||
|
var latLng = evt.latLng;
|
||||||
|
|
||||||
|
document.getElementById('longitude').value = latLng.lng;
|
||||||
|
document.getElementById('latitude').value = latLng.lat;
|
||||||
|
|
||||||
|
// 清除现有标记
|
||||||
|
marker.setGeometries([]);
|
||||||
|
|
||||||
|
// 添加新标记
|
||||||
|
addMarker(latLng, "选定位置");
|
||||||
|
|
||||||
|
// 反向地理编码获取地址信息
|
||||||
|
geocoder.getAddress({
|
||||||
|
location: latLng
|
||||||
|
}).then(function(result) {
|
||||||
|
var address = "";
|
||||||
|
if (result.result && result.result.address) {
|
||||||
|
address = result.result.address;
|
||||||
|
}
|
||||||
|
showInfoWindow(latLng, "选定位置", address, latLng.lat, latLng.lng);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理搜索结果
|
||||||
|
function handleSearchResult(result) {
|
||||||
|
if (result && result.data && result.data.length > 0) {
|
||||||
|
// 清除现有标记
|
||||||
|
marker.setGeometries([]);
|
||||||
|
|
||||||
|
// 添加标记并设置地图中心
|
||||||
|
var firstResult = result.data[0];
|
||||||
|
var newLatLng = new TMap.LatLng(firstResult.location.lat, firstResult.location.lng);
|
||||||
|
|
||||||
|
for (var i = 0; i < result.data.length; i++) {
|
||||||
|
var poi = result.data[i];
|
||||||
|
var poiLatLng = new TMap.LatLng(poi.location.lat, poi.location.lng);
|
||||||
|
addMarker(poiLatLng, poi.title);
|
||||||
|
|
||||||
|
// 为标记添加点击事件
|
||||||
|
(function(p, ll) {
|
||||||
|
var markerGeometry = marker.getGeometries()[i];
|
||||||
|
marker.on('click', function(evt) {
|
||||||
|
if (evt.geometry.id === markerGeometry.id) {
|
||||||
|
showInfoWindow(ll, p.title, p.address, p.location.lat, p.location.lng);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})(poi, poiLatLng);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置地图中心为第一个结果
|
||||||
|
map.setCenter(newLatLng);
|
||||||
|
map.setZoom(15);
|
||||||
|
} else {
|
||||||
|
alert("未找到相关地点");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加标记
|
||||||
|
function addMarker(latLng, title) {
|
||||||
|
var markerGeometry = {
|
||||||
|
id: title + "_" + Date.now(),
|
||||||
|
styleId: 'normal',
|
||||||
|
position: latLng,
|
||||||
|
properties: {
|
||||||
|
title: title
|
||||||
|
}
|
||||||
|
};
|
||||||
|
marker.add(markerGeometry);
|
||||||
|
return markerGeometry;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示信息窗口
|
||||||
|
function showInfoWindow(latLng, title, address, lat, lng) {
|
||||||
|
var content = '<div class="uk-card uk-card-default uk-card-body" style="width:250px;">' +
|
||||||
|
'<h3 class="uk-card-title">' + title + '</h3>' +
|
||||||
|
'<p>' + (address || "(" + lat + ", " + lng + ")") + '</p>' +
|
||||||
|
'<div class="uk-card-footer">' +
|
||||||
|
'<form name="navForm" method="post">' +
|
||||||
|
' <input type="hidden" name="lat" value="' + lat + '">' +
|
||||||
|
' <input type="hidden" name="lon" value="' + lng + '">' +
|
||||||
|
' <input type="hidden" name="save_type" value="' + document.getElementById("save_type").value + '">' +
|
||||||
|
' <input type="hidden" name="name" value="' + title + '">' +
|
||||||
|
' <input class="uk-button uk-button-primary" type="submit" value="导航" >' +
|
||||||
|
'</form>' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>';
|
||||||
|
|
||||||
|
infoWindow.setContent(content);
|
||||||
|
infoWindow.setPosition(latLng);
|
||||||
|
infoWindow.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 页面加载完成后初始化地图
|
||||||
|
window.onload = function() {
|
||||||
|
initMap();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
@ -0,0 +1,22 @@
|
|||||||
|
{% extends "layout.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
TMap API 设置
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
<h1>TMap API 密钥设置</h1><br>
|
||||||
|
<form action="{{ request.path }}" method="post">
|
||||||
|
<div class="uk-margin">
|
||||||
|
<label class="uk-form-label" for="tmap_key">TMap 应用密钥:</label>
|
||||||
|
<div class="uk-form-controls">
|
||||||
|
<input class="uk-input" id="tmap_key" name="tmap_key" type="text" value="{{ tmap_key if tmap_key }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button class="uk-button uk-button-primary" type="submit">保存</button>
|
||||||
|
</form>
|
||||||
|
<br>
|
||||||
|
<div>
|
||||||
|
<p>申请TMap API密钥请访问: <a href="https://lbs.qq.com/" target="_blank" rel="noopener noreferrer">腾讯位置服务</a></p>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user