QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
MissionLineView.qml
Go to the documentation of this file.
1import QtQuick
2import QtLocation
3import QtPositioning
4
5import QGroundControl
6
7/// The MissionLineView control is used to add lines between mission items
8MapItemView {
9 property bool showSpecialVisual: false
10 delegate: MapPolyline {
11 line.width: 3
12 // Note: Special visuals for ROI are hacked out for now since they are not working correctly
13 line.color: _terrainCollision ?
14 "red" :
15 (false/*showSpecialVisual*/ ? "green" : QGroundControl.globalPalette.mapMissionTrajectory)
16 z: QGroundControl.zOrderWaypointLines
17 path: _calcMissionLinePath()
18
19 property bool _terrainCollision: object && object.terrainCollision
20 property bool _showSpecialVisual: object && showSpecialVisual && object.specialVisual
21
22 readonly property real _maxSegmentLengthM: 50000 // 50 km
23
24 function _calcMissionLinePath() {
25 if (!object || !object.coordinate1.isValid || !object.coordinate2.isValid) {
26 return []
27 }
28
29 var coord1 = object.coordinate1
30 var coord2 = object.coordinate2
31
32 var distance = coord1.distanceTo(coord2)
33 if (distance <= _maxSegmentLengthM) {
34 return [coord1, coord2]
35 }
36
37 // For longer distances, draw great circle path
38 var pathPoints = [coord1]
39 var numSegments = Math.ceil(distance / _maxSegmentLengthM)
40
41 for (var i = 1; i < numSegments; i++) {
42 var segmentDist = (i * distance) / numSegments
43 var interpolatedCoord = coord1.atDistanceAndAzimuth(segmentDist, coord1.azimuthTo(coord2))
44 pathPoints.push(interpolatedCoord)
45 }
46
47 pathPoints.push(coord2)
48 return pathPoints
49 }
50 }
51}