diff --git a/src/PlanView/FWLandingPatternMapVisual.qml b/src/PlanView/FWLandingPatternMapVisual.qml index 03c85493e49022c5e9d20bc508e4616d94ac4d5c..43828046169a717b4f38422f05af7c10837ad4b9 100644 --- a/src/PlanView/FWLandingPatternMapVisual.qml +++ b/src/PlanView/FWLandingPatternMapVisual.qml @@ -36,8 +36,8 @@ Item { readonly property int _flightPathIndex: 0 readonly property int _loiterPointIndex: 1 readonly property int _loiterRadiusIndex: 2 - readonly property int _landPointIndex: 3 - readonly property int _landingAreaIndex: 4 + readonly property int _landingAreaIndex: 3 + readonly property int _landPointIndex: 4 function hideItemVisuals() { for (var i=0; i<_itemVisuals.length; i++) { @@ -57,12 +57,12 @@ Item { itemVisual = loiterRadiusComponent.createObject(map) map.addMapItem(itemVisual) _itemVisuals[_loiterRadiusIndex] = itemVisual - itemVisual = landPointComponent.createObject(map) - map.addMapItem(itemVisual) - _itemVisuals[_landPointIndex] = itemVisual itemVisual = landingAreaComponent.createObject(map) map.addMapItem(itemVisual) _itemVisuals[_landingAreaIndex] = itemVisual + itemVisual = landPointComponent.createObject(map) + map.addMapItem(itemVisual) + _itemVisuals[_landPointIndex] = itemVisual } } @@ -258,20 +258,36 @@ Item { Component { id: landingAreaComponent - MapRectangle { + MapPolygon { z: QGroundControl.zOrderMapItems border.width: 1 border.color: "black" color: "green" opacity: 0.5 - topLeft: _missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, -angleDegrees) - bottomRight: _missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, 180 - angleDegrees) - readonly property real landingWidth: 10 + readonly property real landingWidth: 15 readonly property real landingLength: 100 readonly property real angleRadians: Math.atan((landingWidth / 2) / (landingLength / 2)) - readonly property real angleDegrees: angleRadians * (180 / Math.PI) + readonly property real angleDegrees: (angleRadians * (180 / Math.PI)) readonly property real hypotenuse: (landingWidth / 2) / Math.sin(angleRadians) + + property real landingAreaAngle: _missionItem.landingCoordinate.azimuthTo(_missionItem.loiterTangentCoordinate) + + function calcPoly() { + path = [ ] + addCoordinate(_missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, landingAreaAngle - angleDegrees)) + addCoordinate(_missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, landingAreaAngle + angleDegrees)) + addCoordinate(_missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, landingAreaAngle + (180 - angleDegrees))) + addCoordinate(_missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, landingAreaAngle - (180 - angleDegrees))) + } + + Component.onCompleted: calcPoly() + + Connections { + target: _missionItem + onLandingCoordinateChanged: calcPoly() + onLoiterTangentCoordinateChanged: calcPoly() + } } } }