Unverified Commit f0af152d authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8620 from mavlink/KMLWork

Plan: Output Survey polygons with KML save
parents 8ae259b4 8ce5c2d9
......@@ -575,7 +575,8 @@ HEADERS += \
src/Joystick/Joystick.h \
src/Joystick/JoystickManager.h \
src/JsonHelper.h \
src/KMLFileHelper.h \
src/KMLDomDocument.h \
src/KMLHelper.h \
src/LogCompressor.h \
src/MissionManager/CameraCalc.h \
src/MissionManager/CameraSection.h \
......@@ -780,7 +781,8 @@ SOURCES += \
src/Joystick/Joystick.cc \
src/Joystick/JoystickManager.cc \
src/JsonHelper.cc \
src/KMLFileHelper.cc \
src/KMLDomDocument.cc \
src/KMLHelper.cc \
src/LogCompressor.cc \
src/MissionManager/CameraCalc.cc \
src/MissionManager/CameraSection.cc \
......
/****************************************************************************
*
* (c) 2009-2020 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.
*
****************************************************************************/
#include "KMLDomDocument.h"
#include "QGCPalette.h"
#include "QGCApplication.h"
#include "MissionCommandTree.h"
#include "MissionCommandUIInfo.h"
#include "FactMetaData.h"
#include <QDomDocument>
#include <QStringList>
const char* KMLDomDocument::balloonStyleName = "BalloonStyle";
KMLDomDocument::KMLDomDocument(const QString& name)
{
QDomProcessingInstruction header = createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\""));
appendChild(header);
QDomElement kmlElement = createElement(QStringLiteral("kml"));
kmlElement.setAttribute(QStringLiteral("xmlns"), "http://www.opengis.net/kml/2.2");
_rootDocumentElement = createElement(QStringLiteral("Document"));
kmlElement.appendChild(_rootDocumentElement);
appendChild(kmlElement);
addTextElement(_rootDocumentElement, "name", name);
addTextElement(_rootDocumentElement, "open", "1");
_addStandardStyles();
}
QString KMLDomDocument::kmlCoordString(const QGeoCoordinate& coord)
{
double altitude = qIsNaN(coord.altitude() ) ? 0 : coord.altitude();
return QStringLiteral("%1,%2,%3").arg(QString::number(coord.longitude(), 'f', 7)).arg(QString::number(coord.latitude(), 'f', 7)).arg(QString::number(altitude, 'f', 2));
}
QString KMLDomDocument::kmlColorString (const QColor& color, double opacity)
{
return QStringLiteral("%1%2%3%4").arg(static_cast<int>(255.0 * opacity), 2, 16, QChar('0')).arg(color.blue(), 2, 16, QChar('0')).arg(color.green(), 2, 16, QChar('0')).arg(color.red(), 2, 16, QChar('0'));
}
void KMLDomDocument::_addStandardStyles(void)
{
QGCPalette palette;
QDomElement styleElementForBalloon = createElement("Style");
styleElementForBalloon.setAttribute("id", balloonStyleName);
QDomElement balloonStyleElement = createElement("BalloonStyle");
addTextElement(balloonStyleElement, "text", "$[description]");
styleElementForBalloon.appendChild(balloonStyleElement);
_rootDocumentElement.appendChild(styleElementForBalloon);
}
void KMLDomDocument::addTextElement(QDomElement& parentElement, const QString &name, const QString &value)
{
QDomElement textElement = createElement(name);
textElement.appendChild(createTextNode(value));
parentElement.appendChild(textElement);
}
void KMLDomDocument::addLookAt(QDomElement& parentElement, const QGeoCoordinate& coord)
{
QDomElement lookAtElement = createElement("LookAt");
addTextElement(lookAtElement, "latitude", QString::number(coord.latitude(), 'f', 7));
addTextElement(lookAtElement, "longitude", QString::number(coord.longitude(), 'f', 7));
addTextElement(lookAtElement, "altitude", QString::number(coord.longitude(), 'f', 2));
addTextElement(lookAtElement, "heading", "-100");
addTextElement(lookAtElement, "tilt", "45");
addTextElement(lookAtElement, "range", "2500");
parentElement.appendChild(lookAtElement);
}
QDomElement KMLDomDocument::addPlacemark(const QString& name, bool visible)
{
QDomElement placemarkElement = createElement("Placemark");
_rootDocumentElement.appendChild(placemarkElement);
addTextElement(placemarkElement, "name", name);
addTextElement(placemarkElement, "visibility", visible ? "1" : "0");
return placemarkElement;
}
void KMLDomDocument::appendChildToRoot(const QDomNode& child)
{
_rootDocumentElement.appendChild(child);
}
/****************************************************************************
*
* (c) 2009-2020 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.
*
****************************************************************************/
#pragma once
#include <QDomDocument>
#include <QDomElement>
#include <QGeoCoordinate>
class MissionItem;
class Vehicle;
/// Used to convert a Plan to a KML document
class KMLDomDocument : public QDomDocument
{
public:
KMLDomDocument(const QString& name);
void appendChildToRoot (const QDomNode& child);
QDomElement addPlacemark (const QString& name, bool visible);
void addTextElement (QDomElement& parentElement, const QString& name, const QString& value);
QString kmlColorString (const QColor& color, double opacity = 1);
QString kmlCoordString (const QGeoCoordinate& coord);
void addLookAt (QDomElement& parentElement, const QGeoCoordinate& coord);
static const char* balloonStyleName;
protected:
QDomElement _rootDocumentElement;
private:
void _addStandardStyles(void);
};
......@@ -7,14 +7,14 @@
*
****************************************************************************/
#include "KMLFileHelper.h"
#include "KMLHelper.h"
#include <QFile>
#include <QVariant>
const char* KMLFileHelper::_errorPrefix = QT_TR_NOOP("KML file load failed. %1");
const char* KMLHelper::_errorPrefix = QT_TR_NOOP("KML file load failed. %1");
QDomDocument KMLFileHelper::_loadFile(const QString& kmlFile, QString& errorString)
QDomDocument KMLHelper::_loadFile(const QString& kmlFile, QString& errorString)
{
QFile file(kmlFile);
......@@ -41,9 +41,9 @@ QDomDocument KMLFileHelper::_loadFile(const QString& kmlFile, QString& errorStri
return doc;
}
ShapeFileHelper::ShapeType KMLFileHelper::determineShapeType(const QString& kmlFile, QString& errorString)
ShapeFileHelper::ShapeType KMLHelper::determineShapeType(const QString& kmlFile, QString& errorString)
{
QDomDocument domDocument = KMLFileHelper::_loadFile(kmlFile, errorString);
QDomDocument domDocument = KMLHelper::_loadFile(kmlFile, errorString);
if (!errorString.isEmpty()) {
return ShapeFileHelper::Error;
}
......@@ -62,12 +62,12 @@ ShapeFileHelper::ShapeType KMLFileHelper::determineShapeType(const QString& kmlF
return ShapeFileHelper::Error;
}
bool KMLFileHelper::loadPolygonFromFile(const QString& kmlFile, QList<QGeoCoordinate>& vertices, QString& errorString)
bool KMLHelper::loadPolygonFromFile(const QString& kmlFile, QList<QGeoCoordinate>& vertices, QString& errorString)
{
errorString.clear();
vertices.clear();
QDomDocument domDocument = KMLFileHelper::_loadFile(kmlFile, errorString);
QDomDocument domDocument = KMLHelper::_loadFile(kmlFile, errorString);
if (!errorString.isEmpty()) {
return false;
}
......@@ -123,12 +123,12 @@ bool KMLFileHelper::loadPolygonFromFile(const QString& kmlFile, QList<QGeoCoordi
return true;
}
bool KMLFileHelper::loadPolylineFromFile(const QString& kmlFile, QList<QGeoCoordinate>& coords, QString& errorString)
bool KMLHelper::loadPolylineFromFile(const QString& kmlFile, QList<QGeoCoordinate>& coords, QString& errorString)
{
errorString.clear();
coords.clear();
QDomDocument domDocument = KMLFileHelper::_loadFile(kmlFile, errorString);
QDomDocument domDocument = KMLHelper::_loadFile(kmlFile, errorString);
if (!errorString.isEmpty()) {
return false;
}
......
......@@ -16,7 +16,7 @@
#include "ShapeFileHelper.h"
class KMLFileHelper : public QObject
class KMLHelper : public QObject
{
Q_OBJECT
......
......@@ -107,3 +107,8 @@ QJsonObject ComplexMissionItem::_loadPresetJson(const QString& name)
settings.beginGroup(_presetSettingsKey);
return QJsonDocument::fromBinaryData(settings.value(name).toByteArray()).object();
}
void ComplexMissionItem::addKMLVisuals(KMLPlanDomDocument& /* domDocument */)
{
// Default implementation has no visuals
}
......@@ -13,6 +13,7 @@
#include "QGCGeo.h"
#include "QGCToolbox.h"
#include "SettingsManager.h"
#include "KMLPlanDomDocument.h"
#include <QSettings>
......@@ -51,7 +52,7 @@ public:
/// @param name User visible name for preset. Will replace existing preset if already exists.
Q_INVOKABLE virtual void savePreset(const QString& name);
Q_INVOKABLE void deletePreset(const QString& name);
Q_INVOKABLE void deletePreset(const QString& name);
/// Get the point of complex mission item furthest away from a coordinate
......@@ -68,6 +69,8 @@ public:
/// Empty string signals no support for presets.
virtual QString presetsSettingsGroup(void) { return QString(); }
virtual void addKMLVisuals(KMLPlanDomDocument& domDocument);
bool presetsSupported (void) { return !presetsSettingsGroup().isEmpty(); }
bool isIncomplete (void) const { return _isIncomplete; }
......
......@@ -13,54 +13,39 @@
#include "MissionCommandTree.h"
#include "MissionCommandUIInfo.h"
#include "FactMetaData.h"
#include "ComplexMissionItem.h"
#include "QmlObjectListModel.h"
#include <QDomDocument>
#include <QStringList>
const char* KMLPlanDomDocument::_missionLineStyleName = "MissionLineStyle";
const char* KMLPlanDomDocument::_ballonStyleName = "BalloonStyle";
const char* KMLPlanDomDocument::_missionLineStyleName = "MissionLineStyle";
const char* KMLPlanDomDocument::surveyPolygonStyleName = "SurveyPolygonStyle";
KMLPlanDomDocument::KMLPlanDomDocument()
: KMLDomDocument(QStringLiteral("%1 Plan KML").arg(qgcApp()->applicationName()))
{
QDomProcessingInstruction header = createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\""));
appendChild(header);
QDomElement kmlElement = createElement(QStringLiteral("kml"));
kmlElement.setAttribute(QStringLiteral("xmlns"), "http://www.opengis.net/kml/2.2");
_documentElement = createElement(QStringLiteral("Document"));
kmlElement.appendChild(_documentElement);
appendChild(kmlElement);
_addTextElement(_documentElement, "name", QStringLiteral("%1 Plan KML").arg(qgcApp()->applicationName()));
_addTextElement(_documentElement, "open", "1");
_addStyles();
}
QString KMLPlanDomDocument::_kmlCoordString(const QGeoCoordinate& coord)
{
return QStringLiteral("%1,%2,%3").arg(QString::number(coord.longitude(), 'f', 7)).arg(QString::number(coord.latitude(), 'f', 7)).arg(QString::number(coord.altitude(), 'f', 2));
}
void KMLPlanDomDocument::addMissionItems(Vehicle* vehicle, QList<MissionItem*> rgMissionItems)
void KMLPlanDomDocument::_addFlightPath(Vehicle* vehicle, QList<MissionItem*> rgMissionItems)
{
if (rgMissionItems.count() == 0) {
return;
}
QDomElement itemFolderElement = createElement("Folder");
_documentElement.appendChild(itemFolderElement);
_rootDocumentElement.appendChild(itemFolderElement);
_addTextElement(itemFolderElement, "name", "Items");
addTextElement(itemFolderElement, "name", "Items");
QDomElement flightPathElement = createElement("Placemark");
_documentElement.appendChild(flightPathElement);
_rootDocumentElement.appendChild(flightPathElement);
_addTextElement(flightPathElement, "styleUrl", QStringLiteral("#%1").arg(_missionLineStyleName));
_addTextElement(flightPathElement, "name", "Flight Path");
_addTextElement(flightPathElement, "visibility", "1");
_addLookAt(flightPathElement, rgMissionItems[0]->coordinate());
addTextElement(flightPathElement, "styleUrl", QStringLiteral("#%1").arg(_missionLineStyleName));
addTextElement(flightPathElement, "name", "Flight Path");
addTextElement(flightPathElement, "visibility", "1");
addLookAt(flightPathElement, rgMissionItems[0]->coordinate());
// Build up the mission trajectory line coords
QList<QGeoCoordinate> rgFlightCoords;
......@@ -87,13 +72,13 @@ void KMLPlanDomDocument::addMissionItems(Vehicle* vehicle, QList<MissionItem*> r
// Add a place mark for each WP
QDomElement wpPlacemarkElement = createElement("Placemark");
_addTextElement(wpPlacemarkElement, "name", QStringLiteral("%1 %2").arg(QString::number(item->sequenceNumber())).arg(item->command() == MAV_CMD_NAV_WAYPOINT ? "" : uiInfo->friendlyName()));
_addTextElement(wpPlacemarkElement, "styleUrl", QStringLiteral("#%1").arg(_ballonStyleName));
addTextElement(wpPlacemarkElement, "name", QStringLiteral("%1 %2").arg(QString::number(item->sequenceNumber())).arg(item->command() == MAV_CMD_NAV_WAYPOINT ? "" : uiInfo->friendlyName()));
addTextElement(wpPlacemarkElement, "styleUrl", QStringLiteral("#%1").arg(balloonStyleName));
QDomElement wpPointElement = createElement("Point");
_addTextElement(wpPointElement, "altitudeMode", "absolute");
_addTextElement(wpPointElement, "coordinates", _kmlCoordString(coord));
_addTextElement(wpPointElement, "extrude", "1");
addTextElement(wpPointElement, "altitudeMode", "absolute");
addTextElement(wpPointElement, "coordinates", kmlCoordString(coord));
addTextElement(wpPointElement, "extrude", "1");
QDomElement descriptionElement = createElement("description");
QString htmlString;
......@@ -118,20 +103,31 @@ void KMLPlanDomDocument::addMissionItems(Vehicle* vehicle, QList<MissionItem*> r
QDomElement lineStringElement = createElement("LineString");
flightPathElement.appendChild(lineStringElement);
_addTextElement(lineStringElement, "extruder", "1");
_addTextElement(lineStringElement, "tessellate", "1");
_addTextElement(lineStringElement, "altitudeMode", "absolute");
addTextElement(lineStringElement, "extruder", "1");
addTextElement(lineStringElement, "tessellate", "1");
addTextElement(lineStringElement, "altitudeMode", "absolute");
QString coordString;
for (const QGeoCoordinate& coord : rgFlightCoords) {
coordString += QStringLiteral("%1\n").arg(_kmlCoordString(coord));
coordString += QStringLiteral("%1\n").arg(kmlCoordString(coord));
}
_addTextElement(lineStringElement, "coordinates", coordString);
addTextElement(lineStringElement, "coordinates", coordString);
}
QString KMLPlanDomDocument::_kmlColorString (const QColor& color)
void KMLPlanDomDocument::_addComplexItems(QmlObjectListModel* visualItems)
{
return QStringLiteral("ff%1%2%3").arg(color.blue(), 2, 16, QChar('0')).arg(color.green(), 2, 16, QChar('0')).arg(color.red(), 2, 16, QChar('0'));
for (int i=0; i<visualItems->count(); i++) {
ComplexMissionItem* complexItem = visualItems->value<ComplexMissionItem*>(i);
if (complexItem) {
complexItem->addKMLVisuals(*this);
}
}
}
void KMLPlanDomDocument::addMission(Vehicle* vehicle, QmlObjectListModel* visualItems, QList<MissionItem*> rgMissionItems)
{
_addFlightPath(vehicle, rgMissionItems);
_addComplexItems(visualItems);
}
void KMLPlanDomDocument::_addStyles(void)
......@@ -141,35 +137,20 @@ void KMLPlanDomDocument::_addStyles(void)
QDomElement styleElement1 = createElement("Style");
styleElement1.setAttribute("id", _missionLineStyleName);
QDomElement lineStyleElement = createElement("LineStyle");
_addTextElement(lineStyleElement, "color", _kmlColorString(palette.mapMissionTrajectory()));
_addTextElement(lineStyleElement, "width", "4");
addTextElement(lineStyleElement, "color", kmlColorString(palette.mapMissionTrajectory()));
addTextElement(lineStyleElement, "width", "4");
styleElement1.appendChild(lineStyleElement);
QString kmlSurveyColorString = kmlColorString(palette.surveyPolygonInterior(), 0.5 /* opacity */);
QDomElement styleElement2 = createElement("Style");
styleElement2.setAttribute("id", _ballonStyleName);
QDomElement balloonStyleElement = createElement("BalloonStyle");
_addTextElement(balloonStyleElement, "text", "$[description]");
styleElement2.appendChild(balloonStyleElement);
_documentElement.appendChild(styleElement1);
_documentElement.appendChild(styleElement2);
}
void KMLPlanDomDocument::_addTextElement(QDomElement &element, const QString &name, const QString &value)
{
QDomElement textElement = createElement(name);
textElement.appendChild(createTextNode(value));
element.appendChild(textElement);
}
void KMLPlanDomDocument::_addLookAt(QDomElement& element, const QGeoCoordinate& coord)
{
QDomElement lookAtElement = createElement("LookAt");
_addTextElement(lookAtElement, "latitude", QString::number(coord.latitude(), 'f', 7));
_addTextElement(lookAtElement, "longitude", QString::number(coord.longitude(), 'f', 7));
_addTextElement(lookAtElement, "altitude", QString::number(coord.longitude(), 'f', 2));
_addTextElement(lookAtElement, "heading", "-100");
_addTextElement(lookAtElement, "tilt", "45");
_addTextElement(lookAtElement, "range", "2500");
element.appendChild(lookAtElement);
styleElement2.setAttribute("id", surveyPolygonStyleName);
QDomElement polygonStyleElement = createElement("PolyStyle");
addTextElement(polygonStyleElement, "color", kmlSurveyColorString);
QDomElement polygonLineStyleElement = createElement("LineStyle");
addTextElement(polygonLineStyleElement, "color", kmlSurveyColorString);
styleElement2.appendChild(polygonStyleElement);
styleElement2.appendChild(polygonLineStyleElement);
_rootDocumentElement.appendChild(styleElement1);
_rootDocumentElement.appendChild(styleElement2);
}
......@@ -9,31 +9,27 @@
#pragma once
#include <QDomDocument>
#include <QDomElement>
#include <QGeoCoordinate>
#include "KMLDomDocument.h"
class MissionItem;
class Vehicle;
class QmlObjectListModel;
/// Used to convert a Plan to a KML document
class KMLPlanDomDocument : public QDomDocument
class KMLPlanDomDocument : public KMLDomDocument
{
public:
KMLPlanDomDocument();
void addMissionItems(Vehicle* vehicle, QList<MissionItem*> rgMissionItems);
void addMission(Vehicle* vehicle, QmlObjectListModel* visualItems, QList<MissionItem*> rgMissionItems);
private:
void _addStyles (void);
QString _kmlColorString (const QColor& color);
void _addTextElement (QDomElement& element, const QString& name, const QString& value);
QString _kmlCoordString (const QGeoCoordinate& coord);
void _addLookAt(QDomElement& element, const QGeoCoordinate& coord);
static const char* surveyPolygonStyleName;
QDomElement _documentElement;
private:
void _addStyles (void);
void _addFlightPath (Vehicle* vehicle, QList<MissionItem*> rgMissionItems);
void _addComplexItems (QmlObjectListModel* visualItems);
static const char* _missionLineStyleName;
static const char* _ballonStyleName;
};
......@@ -279,7 +279,7 @@ void MissionController::addMissionToKML(KMLPlanDomDocument& planKML)
QList<MissionItem*> rgMissionItems;
_convertToMissionItems(_visualItems, rgMissionItems, deleteParent);
planKML.addMissionItems(_controllerVehicle, rgMissionItems);
planKML.addMission(_controllerVehicle, _visualItems, rgMissionItems);
deleteParent->deleteLater();
}
......
......@@ -555,3 +555,46 @@ void QGCMapPolygon::_endResetIfNotActive(void)
endReset();
}
}
QDomElement QGCMapPolygon::kmlPolygonElement(KMLDomDocument& domDocument)
{
#if 0
<Polygon id="ID">
<!-- specific to Polygon -->
<extrude>0</extrude> <!-- boolean -->
<tessellate>0</tessellate> <!-- boolean -->
<altitudeMode>clampToGround</altitudeMode>
<!-- kml:altitudeModeEnum: clampToGround, relativeToGround, or absolute -->
<!-- or, substitute gx:altitudeMode: clampToSeaFloor, relativeToSeaFloor -->
<outerBoundaryIs>
<LinearRing>
<coordinates>...</coordinates> <!-- lon,lat[,alt] -->
</LinearRing>
</outerBoundaryIs>
<innerBoundaryIs>
<LinearRing>
<coordinates>...</coordinates> <!-- lon,lat[,alt] -->
</LinearRing>
</innerBoundaryIs>
</Polygon>
#endif
QDomElement polygonElement = domDocument.createElement("Polygon");
domDocument.addTextElement(polygonElement, "altitudeMode", "clampToGround");
QDomElement outerBoundaryIsElement = domDocument.createElement("outerBoundaryIs");
QDomElement linearRingElement = domDocument.createElement("LinearRing");
outerBoundaryIsElement.appendChild(linearRingElement);
polygonElement.appendChild(outerBoundaryIsElement);
QString coordString;
for (const QVariant& varCoord : _polygonPath) {
coordString += QStringLiteral("%1\n").arg(domDocument.kmlCoordString(varCoord.value<QGeoCoordinate>()));
}
coordString += QStringLiteral("%1\n").arg(domDocument.kmlCoordString(_polygonPath.first().value<QGeoCoordinate>()));
domDocument.addTextElement(linearRingElement, "coordinates", coordString);
return polygonElement;
}
......@@ -16,6 +16,7 @@
#include <QPolygon>
#include "QmlObjectListModel.h"
#include "KMLDomDocument.h"
/// The QGCMapPolygon class provides a polygon which can be displayed on a map using a map visuals control.
/// It maintains a representation of the polygon on QVariantList and QmlObjectListModel format.
......@@ -92,6 +93,8 @@ public:
/// Returns the area of the polygon in meters squared
double area(void) const;
QDomElement kmlPolygonElement(KMLDomDocument& domDocument);
// Property methods
int count (void) const { return _polygonPath.count(); }
......
......@@ -12,7 +12,7 @@
#include "JsonHelper.h"
#include "QGCQGeoCoordinate.h"
#include "QGCApplication.h"
#include "KMLFileHelper.h"
#include "KMLHelper.h"
#include <QGeoRectangle>
#include <QDebug>
......@@ -352,7 +352,7 @@ bool QGCMapPolyline::loadKMLFile(const QString& kmlFile)
QString errorString;
QList<QGeoCoordinate> rgCoords;
if (!KMLFileHelper::loadPolylineFromFile(kmlFile, rgCoords, errorString)) {
if (!KMLHelper::loadPolylineFromFile(kmlFile, rgCoords, errorString)) {
qgcApp()->showMessage(errorString);
return false;
}
......
......@@ -989,3 +989,15 @@ void TransectStyleComplexItem::_appendLoadedMissionItems(QList<MissionItem*>& it
items.append(item);
}
}
void TransectStyleComplexItem::addKMLVisuals(KMLPlanDomDocument& domDocument)
{
// We add the survey area polygon as a Placemark
QDomElement placemarkElement = domDocument.addPlacemark(QStringLiteral("Survey Area"), true);
QDomElement polygonElement = _surveyAreaPolygon.kmlPolygonElement(domDocument);
placemarkElement.appendChild(polygonElement);
domDocument.addTextElement(placemarkElement, "styleUrl", QStringLiteral("#%1").arg(domDocument.surveyPolygonStyleName));
domDocument.appendChildToRoot(placemarkElement);
}
......@@ -78,10 +78,10 @@ public:
int _transectCount(void) const { return _transects.count(); }
// Overrides from ComplexMissionItem
int lastSequenceNumber (void) const final;
QString mapVisualQML (void) const override = 0;
bool load (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) override = 0;
int lastSequenceNumber (void) const final;
QString mapVisualQML (void) const override = 0;
bool load (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) override = 0;
void addKMLVisuals (KMLPlanDomDocument& domDocument) final;
double complexDistance (void) const final { return _complexDistance; }
double greatestDistanceTo (const QGeoCoordinate &other) const final;
......
......@@ -73,7 +73,7 @@ Item {
interactive: polygonInteractive && _missionItem.isCurrentItem
borderWidth: 1
borderColor: "black"
interiorColor: "green"
interiorColor: QGroundControl.globalPalette.surveyPolygonInterior
interiorOpacity: 0.5
}
......
......@@ -87,9 +87,10 @@ void QGCPalette::_buildMap()
DECLARE_QGC_NONTHEMED_COLOR(brandingBlue, "#48D6FF", "#6045c5")
// Colors not affecting by theming or enable/disable
DECLARE_QGC_SINGLE_COLOR(mapWidgetBorderLight, "#ffffff")
DECLARE_QGC_SINGLE_COLOR(mapWidgetBorderDark, "#000000")
DECLARE_QGC_SINGLE_COLOR(mapMissionTrajectory, "#be781c")
DECLARE_QGC_SINGLE_COLOR(mapWidgetBorderLight, "#ffffff")
DECLARE_QGC_SINGLE_COLOR(mapWidgetBorderDark, "#000000")
DECLARE_QGC_SINGLE_COLOR(mapMissionTrajectory, "#be781c")
DECLARE_QGC_SINGLE_COLOR(surveyPolygonInterior, "green")
}
void QGCPalette::setColorGroupEnabled(bool enabled)
......
......@@ -147,6 +147,7 @@ public:
DEFINE_QGC_COLOR(statusFailedText, setstatusFailedText)
DEFINE_QGC_COLOR(statusPassedText, setstatusPassedText)
DEFINE_QGC_COLOR(statusPendingText, setstatusPendingText)
DEFINE_QGC_COLOR(surveyPolygonInterior, setSurveyPolygonInterior)
QGCPalette(QObject* parent = nullptr);
~QGCPalette();
......
......@@ -9,7 +9,7 @@
#include "ShapeFileHelper.h"
#include "AppSettings.h"
#include "KMLFileHelper.h"
#include "KMLHelper.h"
#include "SHPFileHelper.h"
#include <QFile>
......@@ -52,7 +52,7 @@ ShapeFileHelper::ShapeType ShapeFileHelper::determineShapeType(const QString& fi
bool fileIsKML = _fileIsKML(file, errorString);
if (errorString.isEmpty()) {
if (fileIsKML) {
shapeType = KMLFileHelper::determineShapeType(file, errorString);
shapeType = KMLHelper::determineShapeType(file, errorString);
} else {
shapeType = SHPFileHelper::determineShapeType(file, errorString);
}
......@@ -71,7 +71,7 @@ bool ShapeFileHelper::loadPolygonFromFile(const QString& file, QList<QGeoCoordin
bool fileIsKML = _fileIsKML(file, errorString);
if (errorString.isEmpty()) {
if (fileIsKML) {
success = KMLFileHelper::loadPolygonFromFile(file, vertices, errorString);
success = KMLHelper::loadPolygonFromFile(file, vertices, errorString);
} else {
success = SHPFileHelper::loadPolygonFromFile(file, vertices, errorString);
}
......@@ -88,7 +88,7 @@ bool ShapeFileHelper::loadPolylineFromFile(const QString& file, QList<QGeoCoordi
bool fileIsKML = _fileIsKML(file, errorString);
if (errorString.isEmpty()) {
if (fileIsKML) {
KMLFileHelper::loadPolylineFromFile(file, coords, errorString);
KMLHelper::loadPolylineFromFile(file, coords, errorString);
} else {
errorString = QString(_errorPrefix).arg(tr("Polyline not support from SHP files."));
}
......
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