Commit ed926c07 authored by Valentin Platzgummer's avatar Valentin Platzgummer

about to add Dijkstra

parent 29a10bab
......@@ -220,6 +220,7 @@
<file alias="QGroundControl/Controls/WimaGOperationAreaEditor.qml">src/WimaView/WimaGOperationAreaEditor.qml</file>
<file alias="QGroundControl/Controls/WimaServiceAreaEditor.qml">src/WimaView/WimaServiceAreaEditor.qml</file>
<file alias="QGroundControl/Controls/WimaVCorridorMapVisual.qml">src/WimaView/WimaVCorridorMapVisual.qml</file>
<file alias="QGroundControl/Controls/WimaAreaMapVisual.qml">src/WimaView/WimaAreaMapVisual.qml</file>
</qresource>
<qresource prefix="/json">
<file alias="APMMavlinkStreamRate.SettingsGroup.json">src/Settings/APMMavlinkStreamRate.SettingsGroup.json</file>
......
......@@ -89,6 +89,7 @@ WimaMapVisual 1.0 WimaMapVisual.qml
WimaGOperationAreaMapVisual 1.0 WimaGOperationAreaMapVisual.qml
WimaGOperationAreaEditor 1.0 WimaGOperationAreaEditor.qml
WimaServiceAreaMapVisual 1.0 WimaServiceAreaMapVisual.qml
WimaAreaMapVisual 1.0 WimaAreaMapVisual.qml
WimaServiceAreaEditor 1.0 WimaServiceAreaEditor.qml
WimaVCorridorMapVisual 1.0 WimaVCorridorMapVisual.qml
WimaItemEditor 1.0 WimaItemEditor.qml
......
......@@ -108,17 +108,16 @@ QGCMapPolygon* WimaArea::toQGCPolygon(WimaArea *poly)
}
}
WimaArea *WimaArea::joinPolygons(QList<WimaArea *>* polyList)
void WimaArea::join(QList<WimaArea *>* polyList, WimaArea* joinedPoly)
{
return nullptr;
return;
}
WimaArea *WimaArea::joinPolygons(WimaArea *poly1, WimaArea *poly2)
void WimaArea::join(WimaArea *poly1, WimaArea *poly2, WimaArea* joinedPoly)
{
if (poly1 != nullptr && poly2 != nullptr) {
if (poly1->count() >= 3 && poly2->count() >= 3) {
WimaArea* joinedPolygon = new WimaArea(this);
poly1->verifyClockwiseWinding();
poly2->verifyClockwiseWinding();
......@@ -127,62 +126,117 @@ WimaArea *WimaArea::joinPolygons(WimaArea *poly1, WimaArea *poly2)
WimaArea* crossPoly = poly2; // check for crossings with this polygon while "walking"
// and swicht to this polygon on a intersection,
// continue to walk towards higher indices
QGCMapPolyline lineSegment; // segment of walkerPoly, containing only two coordinates
int currentPolyIndex = 0;
QGeoCoordinate currentVertex = walkerPoly->vertexCoordinate(currentPolyIndex);
// begin with the first index which is not inside crosspoly, if all Vertices are inside crosspoly return crosspoly
int startIndex = 0;
bool crossContainsWalker = true;
for (int i = 0; i < walkerPoly->count(); i++) {
if ( !crossPoly->containsCoordinate(walkerPoly->vertexCoordinate(i)) ) {
crossContainsWalker = false;
startIndex = i;
break;
}
}
if ( crossContainsWalker == true) {
joinedPoly->appendVertices(crossPoly->coordinateList());
return;
}
QGeoCoordinate currentVertex = walkerPoly->vertexCoordinate(startIndex);
QGeoCoordinate startVertex = currentVertex;
// possible nextVertex (if no intersection between currentVertex and protoVertex with crossPoly)
QGeoCoordinate protoNextVertex = walkerPoly->vertexCoordinate(walkerPoly->nextVertexIndex(currentPolyIndex));
do {
joinedPolygon->appendVertex(currentVertex);
QGeoCoordinate protoNextVertex = walkerPoly->vertexCoordinate(walkerPoly->nextVertexIndex(startIndex));
int nextVertexIndex = walkerPoly->nextVertexIndex(startIndex);
while (1) {
qDebug("nextVertexIndex: %i", nextVertexIndex);
joinedPoly->appendVertex(currentVertex);
QGCMapPolyline walkerPolySegment;
walkerPolySegment.appendVertex(currentVertex);
walkerPolySegment.appendVertex(protoNextVertex);
QList<QGeoCoordinate>* intersectionList = intersects(&walkerPolySegment, crossPoly);
QList<QPair<int, int>> neighbourList;
QList<QGeoCoordinate> intersectionList;
qDebug("IntersectionList.size() on init: %i", intersectionList.size());
intersects(&walkerPolySegment, crossPoly, &intersectionList, &neighbourList);
qDebug("IntersectionList.size(): %i", intersectionList.size());
if (intersectionList != nullptr) {
if (intersectionList->size() > 1*3) {
if (intersectionList.size() >= 1) {
int minDistIndex = 0;
} else if ( intersectionList->size() == 1*3) {
// intersectionList->takeAt(0); intersection pt.
// intersectionList->takeAt(1); neighbour of intersec. pt. inside crossPoly, lower index
// intersectionList->takeAt(2); neighbour of intersec. pt. inside crossPoly, higher index
currentVertex = intersectionList->takeAt(0);
protoNextVertex = intersectionList->takeAt(2);
if (intersectionList.size() > 1) {
double minDist = currentVertex.distanceTo(intersectionList.value(minDistIndex));
for (int i = 1; i < intersectionList.size(); i++) {
double currentDist = currentVertex.distanceTo(intersectionList.value(i));
//currentPolyIndex = crossPoly->
if ( minDist > currentDist ) {
minDist = currentDist;
minDistIndex = i;
}
}
}
qDebug("MinDistIndex: %i", minDistIndex);
QGeoCoordinate protoCurrentVertex = intersectionList.value(minDistIndex);
// take numerical erros into account
if (protoCurrentVertex.distanceTo(currentVertex) > WimaArea::numericalAccuracy) {
currentVertex = protoCurrentVertex;
QPair<int, int> neighbours = neighbourList.value(minDistIndex);
protoNextVertex = crossPoly->vertexCoordinate(neighbours.second);
nextVertexIndex = neighbours.second;
// swap walker and cross poly
WimaArea* temp = walkerPoly;
walkerPoly = crossPoly;
crossPoly = temp;
} else {
currentPolyIndex++;
currentVertex = walkerPoly->vertexCoordinate(currentPolyIndex);// change req.
protoNextVertex = walkerPoly->vertexCoordinate(walkerPoly->nextVertexIndex(currentPolyIndex));
currentVertex = walkerPoly->vertexCoordinate(nextVertexIndex);
protoNextVertex = walkerPoly->vertexCoordinate(walkerPoly->nextVertexIndex(nextVertexIndex));
nextVertexIndex = walkerPoly->nextVertexIndex(nextVertexIndex);
}
} else {
return nullptr;
currentVertex = walkerPoly->vertexCoordinate(nextVertexIndex);
protoNextVertex = walkerPoly->vertexCoordinate(walkerPoly->nextVertexIndex(nextVertexIndex));
nextVertexIndex = walkerPoly->nextVertexIndex(nextVertexIndex);
}
if (currentVertex == startVertex) {
return;
}
} while (currentPolyIndex != 0 || walkerPoly != poly1);
}
return joinedPolygon;
} else {
qWarning("WimaArea::joinPolygons(poly1, poly2): poly->count() < 3");
return nullptr;
return;
}
} else {
qWarning("WimaArea::joinPolygons(poly1, poly2): nullptr");
return nullptr;
return;
}
}
void WimaArea::join(WimaArea *poly)
{
WimaArea joinedArea(this);
join(this, poly, &joinedArea);
this->setPath(joinedArea.path());
return;
}
bool WimaArea::isDisjunct(QList<WimaArea *>* polyList)
{
// needs improvement
if (polyList != nullptr){
for (int i = 0;i < polyList->size()-1; i++) {
WimaArea* currPoly = polyList->takeAt(i);
WimaArea* currPoly = polyList->value(i);
for (int j = i+1; i < polyList->size(); j++) {
if (isDisjunct(currPoly, polyList->takeAt(j))) {
if (isDisjunct(currPoly, polyList->value(j))) {
return false;
}
}
......@@ -236,82 +290,126 @@ int WimaArea::previousVertexIndex(int index)
}
}
QGeoCoordinate* WimaArea::intersects(QGCMapPolyline *geoLine1, QGCMapPolyline *geoLine2)
bool WimaArea::intersects(QGCMapPolyline *line1, QGCMapPolyline *line2, QGeoCoordinate *intersectionPt)
{
if (geoLine1 != nullptr && geoLine2 != nullptr) {
if (geoLine1->count() == 2 && geoLine2->count() == 2 ) {
if (line1 != nullptr && line2 != nullptr && intersectionPt != nullptr) {
if (line1->count() == 2 && line2->count() == 2 ) {
QPointF pt11(0, 0);
double x, y, z;
QGeoCoordinate origin = geoLine1->vertexCoordinate(0);
convertGeoToNed(geoLine1->vertexCoordinate(1), origin, &x, &y, &z);
QGeoCoordinate origin = line1->vertexCoordinate(0);
convertGeoToNed(line1->vertexCoordinate(1), origin, &x, &y, &z);
QPointF pt12(x, y);
QLineF kartLine1(pt11, pt12);
convertGeoToNed(geoLine2->vertexCoordinate(0), origin, &x, &y, &z);
convertGeoToNed(line2->vertexCoordinate(0), origin, &x, &y, &z);
QPointF pt21(x, y);
convertGeoToNed(geoLine2->vertexCoordinate(1), origin, &x, &y, &z);
convertGeoToNed(line2->vertexCoordinate(1), origin, &x, &y, &z);
QPointF pt22(x, y);
QLineF kartLine2(pt21, pt22);
QPointF intersectionPoint;
if (kartLine1.intersect(kartLine2, &intersectionPoint) != QLineF::NoIntersection) {
QGeoCoordinate* retValue = new QGeoCoordinate();
convertNedToGeo(intersectionPoint.x(), intersectionPoint.y(), origin.altitude(), origin, retValue);
return retValue;
if (kartLine1.intersect(kartLine2, &intersectionPoint) == QLineF::BoundedIntersection) {
convertNedToGeo(intersectionPoint.x(), intersectionPoint.y(), origin.altitude(), origin, intersectionPt);
return true;
} else {
return nullptr;
return false;
}
} else {
qWarning("WimaArea::intersect(geoLine1, geoLine2): geoLine1->count() != 2 || geoLine2->count() != 2!");
return nullptr;
qWarning("WimaArea::intersect(line1, line2): line1->count() != 2 || line2->count() != 2!");
return false;
}
} else {
qWarning("WimaArea::intersect(geoLine1, geoLine2): geoLine1 == nullptr || geoLine2 == nullptr!");
return nullptr;
qWarning("WimaArea::intersect(line1, line2): nullptr!");
return false;
}
}
QList<QGeoCoordinate>* WimaArea::intersects(QGCMapPolyline *line, WimaArea *poly)
bool WimaArea::intersects(QGCMapPolyline *line, WimaArea *poly, QList<QGeoCoordinate> *intersectionList, QList<QPair<int, int> > *neighbourlist)
{
QList<QGeoCoordinate>* intersectionList = new QList<QGeoCoordinate>();
if (line != nullptr && poly != nullptr) {
if (line != nullptr && poly != nullptr && neighbourlist != nullptr && intersectionList != nullptr) {
neighbourlist->clear();
intersectionList->clear();
if (line->count() == 2 && poly->count() >= 3) {
QVariantList polyPath = poly->path();
QGeoCoordinate pt1;
QGeoCoordinate pt2;
for (int i = 0; i < poly->count(); i++) {
QGCMapPolyline polySegment;
QGeoCoordinate currentVertex = polyPath.takeAt(i).value<QGeoCoordinate>();
QGeoCoordinate nextVertex = polyPath.takeAt(poly->nextVertexIndex(i)).value<QGeoCoordinate>();
QGeoCoordinate currentVertex = poly->vertexCoordinate(i);
QGeoCoordinate nextVertex = poly->vertexCoordinate(poly->nextVertexIndex(i));
polySegment.appendVertex(currentVertex);
polySegment.appendVertex(nextVertex);
QGeoCoordinate* intersectionPoint = intersects(line, &polySegment);
QGeoCoordinate intersectionPoint;
bool retVal = intersects(line, &polySegment, &intersectionPoint);
if (retVal != false){
intersectionList->append(intersectionPoint);
if (intersectionPoint != nullptr){
intersectionList->append(*intersectionPoint);
intersectionList->append(currentVertex);
intersectionList->append(nextVertex);
QPair<int, int> neighbours;
neighbours.first = i;
neighbours.second = poly->nextVertexIndex(i);
neighbourlist->append(neighbours);
}
}
return intersectionList;
if (intersectionList->count() > 0) {
return true;
} else {
return false;
}
} else {
qWarning("WimaArea::intersects(line, poly): line->count() != 2 || poly->count() < 3");
return nullptr;
return false;
}
} else {
qWarning("WimaArea::intersects(line, poly): line == nullptr || poly == nullptr!");
return nullptr;
qWarning("WimaArea::intersects(line, poly): nullptr!");
return false;
}
}
double WimaArea::distInsidePoly(QGeoCoordinate *c1, QGeoCoordinate *c2, WimaArea *poly)
{
if (c1 != nullptr && c2 != nullptr && poly != nullptr) {
QGCMapPolyline line;
line.appendVertex(*c1);
line.appendVertex(*c2);
QList<QGeoCoordinate> intersectionList;
QList<QPair<int, int> > neighbourlist;
if (poly->containsCoordinate(*c1) && poly->containsCoordinate(*c2) && !intersects(&line, poly, &intersectionList, &neighbourlist)) {
return c1->distanceTo(*c2);
} else {
return std::numeric_limits<qreal>::infinity();
}
} else {
qWarning("WimaArea::distInsidePoly(QGeoCoordinate*, QGeoCoordinate*, WimaArea*): nullptr!");
return std::numeric_limits<qreal>::infinity();
}
}
void WimaArea::dijkstraPath(QGeoCoordinate *c1, QGeoCoordinate *c2, WimaArea *poly, QGCMapPolyline* dijkistraPath)
{
if (c1 != nullptr && c2 != nullptr && poly != nullptr && dijkistraPath != nullptr) {
struct Node{
QGeoCoordinate c;
double predecessorIndex;
double distane;
};
QList<Node> nodeList;
QList<Node> visitedNodesList;
} else {
qWarning(" WimaArea::dijkstraPath(QGeoCoordinate*, QGeoCoordinate*, WimaArea*): nullptr!");
}
}
......@@ -9,6 +9,7 @@
#include <QLineF>
#include <QPointF>
#include "QGCGeo.h"
#include <QPair>
class WimaArea : public QGCMapPolygon //abstract base class for all WimaAreas
{
......@@ -42,34 +43,41 @@ public:
template <class T>
QList<T*>* splitArea (int numberOfFractions); // use QScopedPointer to store return value*/
//iterates over all vertices in _polygon and returns the index of that one closest to coordinate
int getClosestVertexIndex (QGeoCoordinate coordinate);
int getClosestVertexIndex (QGeoCoordinate coordinate);
//iterates over all vertices in _polygon and returns that one closest to coordinate
QGeoCoordinate getClosestVertex (QGeoCoordinate coordinate);
QGCMapPolygon* toQGCPolygon (WimaArea* poly);
WimaArea* joinPolygons (QList<WimaArea*>* polyList);
QGeoCoordinate getClosestVertex (QGeoCoordinate coordinate);
QGCMapPolygon* toQGCPolygon (WimaArea* poly);
static void join (QList<WimaArea*>* polyList, WimaArea* joinedPoly);
/// joins the poly1 and poly2 if possible, joins the polygons to form a simple polygon (no holes)
/// see https://en.wikipedia.org/wiki/Simple_polygon
/// @return the joined polygon of poly1 and poly2 if possible, poly1 else
WimaArea* joinPolygons (WimaArea* poly1, WimaArea* poly2);
bool isDisjunct (QList<WimaArea*>* polyList);
bool isDisjunct (WimaArea* poly1, WimaArea* poly2);
static void join (WimaArea* poly1, WimaArea* poly2, WimaArea* joinedPoly);
void join (WimaArea* poly);
bool isDisjunct (QList<WimaArea*>* polyList);
bool isDisjunct (WimaArea* poly1, WimaArea* poly2);
/// calculates the next polygon vertex index
/// @return index + 1 if index < poly->count()-1 && index >= 0, or 0 if index == poly->count()-1, -1 else
int nextVertexIndex (int index);
int nextVertexIndex (int index);
/// calculates the previous polygon vertex index
/// @return index - 1 if index < poly->count() && index > 0, or poly->count()-1 if index == 0, -1 else
int previousVertexIndex (int index);
int previousVertexIndex (int index);
/// checks if line1 and line2 intersect with each other, takes latitude and longitute into account only (height neglected)
/// @param line1 line containing two coordinates, height not taken into account
/// @param line2 line containing two coordinates, height not taken into account
/// @return the intersection point if line1 intersects line2, nullptr else
QGeoCoordinate* intersects(QGCMapPolyline* line1, QGCMapPolyline* line2);
/// @param intersectionPt Coordinate item to store intersection pt. in.
/// @return false on error or no intersection, true else
static bool intersects(QGCMapPolyline* line1, QGCMapPolyline* line2, QGeoCoordinate* intersectionPt);
/// checks if line1 and poly intersect with each other, takes latitude and longitute into account only (height neglected)
/// @param line line containing two coordinates, height not taken into account
/// @return a list of intersection points and the two neares neighbours of poly to the intersection point if line intersects poly, or an empty list else.
/// The first entry is the first intersec. pt. (if existing). The second and third entries are the nearest neighbours of the first intersec. pt. in poly
/// The fourth entry is the second intersec. pt. (if existing). The fifth and sixth entries are the nearest neighbours of the second intersec. pt. in poly
QList<QGeoCoordinate>* intersects(QGCMapPolyline* line, WimaArea* poly);
/// @param intersectionList Empty list to store intersection points in.
/// @param neighbourList Empty list to store the indices of the neighbours (the two Vertices of poly with the smallest distance to the intersection pt.)
/// @return false on error or no intersection, true else
static bool intersects(QGCMapPolyline* line, WimaArea* poly, QList<QGeoCoordinate>* intersectionList, QList<QPair<int, int>>* neighbourlist);
/// calculates the distance between to geo coordinates, returns the distance if the path lies within the polygon and inf. else.
/// @return the distance if the path lies within the polygon and inf. else.
static double distInsidePoly(QGeoCoordinate *c1, QGeoCoordinate *c2, WimaArea *poly);
/// calculates the shortes path between two geo coordinates inside a polygon using the Dijkstra Algorithm
static void dijkstraPath(QGeoCoordinate *c1, QGeoCoordinate *c2, WimaArea *poly, QGCMapPolyline *dijkstraPath);
// Accurracy used to compute isDisjunct
static const double numericalAccuracy;
......
......@@ -73,55 +73,13 @@ void WimaController::addServiceArea()
emit visualItemsChanged();
}
bool WimaController::addVehicleCorridor(WimaGOperationArea *opArea, WimaServiceArea *serviceArea)
void WimaController::addVehicleCorridor()
{
WimaVCorridor* corridor = nullptr;
if (opArea != nullptr && serviceArea != nullptr){
for (int i = 0; i < _visualItems->count(); i++) {
corridor = qobject_cast<WimaVCorridor*>(_visualItems->get(i));
if (corridor != nullptr){
if (corridor->serviceArea() == serviceArea && corridor->opArea() == opArea){
break;
}else {
corridor = nullptr;
}
}
}
bool newCorridorCreated = false;
if(corridor == nullptr){
corridor = new WimaVCorridor(opArea);
newCorridorCreated = true;
}else {
corridor->clear();
}
QList<QGeoCoordinate> opAreaPolyline = opArea->polyline()->coordinateList();
QList<QGeoCoordinate> serAreaPolyline = serviceArea->polyline()->coordinateList();
if (opAreaPolyline.size() > 1 && serAreaPolyline.size() > 1){
corridor->appendVertices(opAreaPolyline);
corridor->appendVertices(serAreaPolyline);
if (newCorridorCreated){
corridor->setServiceArea(serviceArea);
corridor->setOpArea(opArea);
serviceArea->setVehicleCorridor(corridor);
opArea->setVehicleCorridor(corridor);
_visualItems->append(corridor);
emit visualItemsChanged();
}
return true;
}else {
qWarning("WimaController::addVehicleCorridor(): OpArea or serviceArea polyline size <= 1!");
if (newCorridorCreated){
corridor->deleteLater();
}
return false;
}
}else {
return false;
}
WimaVCorridor* corridor = new WimaVCorridor(this);
_visualItems->append(corridor);
int newIndex = _visualItems->count()-1;
setCurrentPolygonIndex(newIndex);
emit visualItemsChanged();
}
void WimaController::startMission()
......@@ -166,14 +124,23 @@ bool WimaController::updateMission()
}
}
// calc. vehicle corridor
if (opArea != nullptr && serArea != nullptr){
if(!addVehicleCorridor(opArea, serArea)){
return false;
// pick first WimaVCorridor
WimaVCorridor* corridor = nullptr;
for (int i = 0; i < _visualItems->count(); i++) {
WimaVCorridor* currentArea = qobject_cast<WimaVCorridor*>(_visualItems->get(i));
if (currentArea != nullptr){
corridor = currentArea;
break;
}
}else{
return false;
}
// join service area and op area
WimaArea* joinedArea = new WimaArea(this);
WimaArea::join(corridor, serArea, joinedArea);
joinedArea->join(opArea);
_visualItems->append(joinedArea);
// reset visual items
_missionController->removeAll();
......
......@@ -50,7 +50,7 @@ public:
Q_INVOKABLE void removeArea(int index);
Q_INVOKABLE void addServiceArea();
/// @return true if a vehicle corridor was added sucessfully and false otherwise.
bool addVehicleCorridor(WimaGOperationArea* opArea, WimaServiceArea* serviceArea);
Q_INVOKABLE void addVehicleCorridor();
Q_INVOKABLE void startMission();
Q_INVOKABLE void abortMission();
......
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtLocation 5.3
import QtPositioning 5.3
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FlightMap 1.0
/// Wima Area visuals
Item {
id: _root
property var map ///< Map control to place item in
property var qgcView ///< QGCView to use for popping dialogs
property var areaItem: object
property var _polygon: areaItem
signal clicked(int sequenceNumber)
/// Add an initial 4 sided polygon if there is none
function _addInitialPolygon() {
if (_polygon.count < 3) {
// Initial polygon is inset to take 2/3rds space
var rect = Qt.rect(map.centerViewport.x, map.centerViewport.y, map.centerViewport.width, map.centerViewport.height)
rect.x += (rect.width * 0.25) / 2
rect.y += (rect.height * 0.25) / 2
rect.width *= 0.75
rect.height *= 0.75
var centerCoord = map.toCoordinate(Qt.point(rect.x + (rect.width / 2), rect.y + (rect.height / 2)), false /* clipToViewPort */)
var topLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y), false /* clipToViewPort */)
var topRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y), false /* clipToViewPort */)
var bottomLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y + rect.height), false /* clipToViewPort */)
var bottomRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */)
// Adjust polygon to max size
var maxSize = 100
var halfWidthMeters = Math.min(topLeftCoord.distanceTo(topRightCoord), maxSize) / 2
var halfHeightMeters = Math.min(topLeftCoord.distanceTo(bottomLeftCoord), maxSize) / 2
topLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 0)
topRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 0)
bottomLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 180)
bottomRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 180)
_polygon.appendVertex(topLeftCoord)
_polygon.appendVertex(topRightCoord)
_polygon.appendVertex(bottomRightCoord)
_polygon.appendVertex(bottomLeftCoord)
}
}
Component.onCompleted: {
_addInitialPolygon()
}
Component.onDestruction: {
}
WimaMapPolygonVisuals {
qgcView: _root.qgcView
mapControl: map
mapPolygon: _polygon
borderWidth: 1
borderColor: "black"
interiorColor: "gray"
interiorOpacity: 0.25
}
}
......@@ -33,6 +33,7 @@ Item {
property int borderWidth: 0
property color borderColor: "black"
property bool initPolygon: false
property bool showVertexIndex: true
property var _polygonComponent
property var _dragHandlesComponent
......@@ -417,6 +418,13 @@ Item {
color: Qt.rgba(1,1,1,0.8)
border.color: Qt.rgba(0,0,0,0.25)
border.width: 1
QGCLabel {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
color: "black"
text: showVertexIndex ? polygonVertex : ""
}
}
}
}
......
......@@ -71,7 +71,7 @@ Item {
Component.onCompleted: {
//_addInitialPolygon()
_addInitialPolygon()
//_addInitialPolyline()
}
......@@ -85,7 +85,6 @@ Item {
borderWidth: 1
borderColor: "black"
interiorColor: "blue"
interactive: false
interiorOpacity: 0.2
}
......
......@@ -576,11 +576,15 @@ QGCView {
dropPanelComponent: syncDropPanel
},
{
name: qsTr("Global Area"),
name: qsTr("Global"),
iconSource: "/qmlimages/Target.svg"
},
{
name: qsTr("Service Area"),
name: qsTr("Service"),
iconSource: "/qmlimages/noFlyArea.svg"
},
{
name: qsTr("Corridor"),
iconSource: "/qmlimages/noFlyArea.svg"
},
{
......@@ -621,16 +625,19 @@ QGCView {
_addWaypointOnClick = false*/
break
case 3:
wimaController.addVehicleCorridor();
break
case 4:
/*if (_singleComplexItem) {
addComplexItem(_missionController.complexMissionItemNames[0])
}*/
wimaController.updateMission();
break
case 5:
case 6:
editorMap.zoomLevel += 0.5
break
case 6:
case 7:
editorMap.zoomLevel -= 0.5
break
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment