增加 航点与航点间 距离显示功能
增加 可选按钮
1,新建 MissionLineInfoView.qml 文件 用于显示航线长度
import QtQuick 2.4
import QtLocation 5.3
import QtPositioning 5.3
import QGroundControl 1.0
import QGroundControl.Palette 1.0
//航线 长度显示
MapItemView {
id:_root
delegate: MapQuickItem {
function toRadian(deg) {
return deg * Math.PI / 180
}
function toDegree(rad) {
return rad * 180 / Math.PI
}
function midPoint(lat1, lat2, lon1, lon2) {
var dLon = toRadian(lon2 - lon1);
lat1 = toRadian(lat1);
lat2 = toRadian(lat2);
lon1 = toRadian(lon1);
var Bx = Math.cos(lat2) * Math.cos(dLon);
var By = Math.cos(lat2) * Math.sin(dLon);
var lat3 = Math.atan2(Math.sin(lat1) + Math.sin(lat2), Math.sqrt((Math.cos(lat1) + Bx) * (Math.cos(lat1) + Bx) + By * By));
var lon3 = lon1 + Math.atan2(By, Math.cos(lat1) + Bx);
return QtPositioning.coordinate(toDegree(lat3), toDegree(lon3))
}
coordinate: midPoint(object.coordinate1.latitude,object.coordinate2.latitude,object.coordinate1.longitude,object.coordinate2.longitude) //计算起点 和终点的 中点
sourceItem: Column {
// Image { id: image; source: "marker.png" }
Text {
text: " "+ Math.round(object.coordinate1.distanceTo(object.coordinate2)) //显示距离
color: "red"
font.bold:true
}
}
}
}
2,加入到 飞行界面中( FlightDisplayViewMap.qml)
MissionLineInfoView {
model: (_mainIsMap&&_showLineDistance) ? missionController.waypointLines : 0
}
3,添加 左侧按钮 可选功能(CenterMapDropButton.qml)
QGCCheckBox {
id: showLineDistanceCheckBox
text: qsTr("Show Distance")
checked: showLineDistance
visible: showFollowVehicle
onClicked: {
dropButton.hideDropDown()
dropButton.showLineDistance = checked
}
}