QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GeoMapRallyPoint.qml
Go to the documentation of this file.
1import QtQuick
2import QtPositioning
3
4import QGroundControl
5import QGroundControl.GeoMap
6
7/// Rally point marker. A PX4 rally point is a position on the ground (its altitude is the ground elevation), so it lies
8/// flat on the terrain. Other firmware flies to the point's altitude, so the marker floats there.
9GeoMapMissionLabel {
10 id: root
11
12 property var rallyPoint ///< RallyPoint
13 property var vehicle ///< Vehicle whose firmware decides the meaning of the altitude
14 property real homeAltitude: NaN ///< Home AMSL, for the relative altitude frame
15 property real homeTerrainBias: 0 ///< See GeoMapWaypointItem.homeTerrainBias
16
17 readonly property bool onGround: vehicle ? vehicle.px4Firmware : false
18
19 // terrainHeightAt does not notify, so _terrainRev re-evaluates a terrain frame altitude as tiles arrive
20 property int _terrainRev: 0
21 readonly property bool _terrainFrame: !!rallyPoint && rallyPoint.altitudeFrame === QGroundControl.AltitudeFrameTerrain
22
23 // Rendered height: the rendered terrain is homeTerrainBias above AMSL
24 readonly property real _renderedAltitude: {
25 root._terrainRev
26 if (!rallyPoint) {
27 return NaN
28 }
29 const altitude = rallyPoint.coordinate.altitude
30 switch (rallyPoint.altitudeFrame) {
31 case QGroundControl.AltitudeFrameAbsolute:
32 return altitude + homeTerrainBias
33 case QGroundControl.AltitudeFrameTerrain:
34 return (surfaceModel ? surfaceModel.terrainHeightAt(rallyPoint.coordinate) : 0) + altitude
35 default:
36 return homeAltitude + altitude + homeTerrainBias
37 }
38 }
39
40 objectName: "geoMapRallyPoint"
41 label: qsTr("R", "rally point map item label")
42 groundMarker: onGround
43 altitudeMode: onGround ? GeoMapItem.ClampToGround : GeoMapItem.Absolute
44 dragHeightAt: _terrainFrame && surfaceModel
45 ? (position) => surfaceModel.terrainHeightAt(position) + rallyPoint.coordinate.altitude
46 : null
47 coordinate: {
48 if (!rallyPoint) {
49 return QtPositioning.coordinate()
50 }
51 if (onGround) {
52 return rallyPoint.coordinate
53 }
54 return QtPositioning.coordinate(rallyPoint.coordinate.latitude, rallyPoint.coordinate.longitude, _renderedAltitude)
55 }
56
57 Connections {
58 target: root.surfaceModel
59 enabled: !root.onGround && root._terrainFrame
60
61 function onTerrainHeightsChanged() {
62 root._terrainRev++
63 }
64 }
65}