Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
0a2fc71e
Commit
0a2fc71e
authored
Mar 28, 2020
by
DoinLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent
52a10716
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
293 additions
and
109 deletions
+293
-109
qgroundcontrol.pro
qgroundcontrol.pro
+4
-2
KMLDomDocument.cc
src/KMLDomDocument.cc
+96
-0
KMLDomDocument.h
src/KMLDomDocument.h
+41
-0
KMLHelper.cc
src/KMLHelper.cc
+9
-9
KMLHelper.h
src/KMLHelper.h
+1
-1
ComplexMissionItem.cc
src/MissionManager/ComplexMissionItem.cc
+5
-0
ComplexMissionItem.h
src/MissionManager/ComplexMissionItem.h
+4
-1
KMLPlanDomDocument.cc
src/MissionManager/KMLPlanDomDocument.cc
+49
-68
KMLPlanDomDocument.h
src/MissionManager/KMLPlanDomDocument.h
+9
-13
MissionController.cc
src/MissionManager/MissionController.cc
+1
-1
QGCMapPolygon.cc
src/MissionManager/QGCMapPolygon.cc
+43
-0
QGCMapPolygon.h
src/MissionManager/QGCMapPolygon.h
+3
-0
QGCMapPolyline.cc
src/MissionManager/QGCMapPolyline.cc
+2
-2
TransectStyleComplexItem.cc
src/MissionManager/TransectStyleComplexItem.cc
+12
-0
TransectStyleComplexItem.h
src/MissionManager/TransectStyleComplexItem.h
+4
-4
TransectStyleMapVisuals.qml
src/PlanView/TransectStyleMapVisuals.qml
+1
-1
QGCPalette.cc
src/QGCPalette.cc
+4
-3
QGCPalette.h
src/QGCPalette.h
+1
-0
ShapeFileHelper.cc
src/ShapeFileHelper.cc
+4
-4
No files found.
qgroundcontrol.pro
View file @
0a2fc71e
...
...
@@ -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
\
...
...
src/KMLDomDocument.cc
0 → 100644
View file @
0a2fc71e
/****************************************************************************
*
* (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
;
}
QDomNode
KMLDomDocument
::
appendChildToRoot
(
const
QDomNode
&
child
)
{
_rootDocumentElement
.
appendChild
(
child
);
}
src/KMLDomDocument.h
0 → 100644
View file @
0a2fc71e
/****************************************************************************
*
* (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
);
QDomNode
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
);
};
src/KML
File
Helper.cc
→
src/KMLHelper.cc
View file @
0a2fc71e
...
...
@@ -7,14 +7,14 @@
*
****************************************************************************/
#include "KML
File
Helper.h"
#include "KMLHelper.h"
#include <QFile>
#include <QVariant>
const
char
*
KML
File
Helper
::
_errorPrefix
=
QT_TR_NOOP
(
"KML file load failed. %1"
);
const
char
*
KMLHelper
::
_errorPrefix
=
QT_TR_NOOP
(
"KML file load failed. %1"
);
QDomDocument
KML
File
Helper
::
_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
KML
File
Helper
::
determineShapeType
(
const
QString
&
kmlFile
,
QString
&
errorString
)
ShapeFileHelper
::
ShapeType
KMLHelper
::
determineShapeType
(
const
QString
&
kmlFile
,
QString
&
errorString
)
{
QDomDocument
domDocument
=
KML
File
Helper
::
_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
KML
File
Helper
::
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
=
KML
File
Helper
::
_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
KML
File
Helper
::
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
=
KML
File
Helper
::
_loadFile
(
kmlFile
,
errorString
);
QDomDocument
domDocument
=
KMLHelper
::
_loadFile
(
kmlFile
,
errorString
);
if
(
!
errorString
.
isEmpty
())
{
return
false
;
}
...
...
src/KML
File
Helper.h
→
src/KMLHelper.h
View file @
0a2fc71e
...
...
@@ -16,7 +16,7 @@
#include "ShapeFileHelper.h"
class
KML
File
Helper
:
public
QObject
class
KMLHelper
:
public
QObject
{
Q_OBJECT
...
...
src/MissionManager/ComplexMissionItem.cc
View file @
0a2fc71e
...
...
@@ -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
}
src/MissionManager/ComplexMissionItem.h
View file @
0a2fc71e
...
...
@@ -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
;
}
...
...
src/MissionManager/KMLPlanDomDocument.cc
View file @
0a2fc71e
...
...
@@ -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
=
"Ballo
onStyle"
;
const
char
*
KMLPlanDomDocument
::
_missionLineStyleName
=
"MissionLineStyle"
;
const
char
*
KMLPlanDomDocument
::
surveyPolygonStyleName
=
"SurveyPolyg
onStyle"
;
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"
);
_
d
ocumentElement
.
appendChild
(
itemFolderElement
);
_
rootD
ocumentElement
.
appendChild
(
itemFolderElement
);
_
addTextElement
(
itemFolderElement
,
"name"
,
"Items"
);
addTextElement
(
itemFolderElement
,
"name"
,
"Items"
);
QDomElement
flightPathElement
=
createElement
(
"Placemark"
);
_
d
ocumentElement
.
appendChild
(
flightPathElement
);
_
rootD
ocumentElement
.
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
(
_ball
onStyleName
));
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
(
ballo
onStyleName
));
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
);
}
src/MissionManager/KMLPlanDomDocument.h
View file @
0a2fc71e
...
...
@@ -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
Q
DomDocument
class
KMLPlanDomDocument
:
public
KML
DomDocument
{
public:
KMLPlanDomDocument
();
void
addMission
Items
(
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
;
};
src/MissionManager/MissionController.cc
View file @
0a2fc71e
...
...
@@ -279,7 +279,7 @@ void MissionController::addMissionToKML(KMLPlanDomDocument& planKML)
QList
<
MissionItem
*>
rgMissionItems
;
_convertToMissionItems
(
_visualItems
,
rgMissionItems
,
deleteParent
);
planKML
.
addMission
Items
(
_controllerVehicle
,
rgMissionItems
);
planKML
.
addMission
(
_controllerVehicle
,
_visualItems
,
rgMissionItems
);
deleteParent
->
deleteLater
();
}
...
...
src/MissionManager/QGCMapPolygon.cc
View file @
0a2fc71e
...
...
@@ -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
;
}
src/MissionManager/QGCMapPolygon.h
View file @
0a2fc71e
...
...
@@ -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
();
}
...
...
src/MissionManager/QGCMapPolyline.cc
View file @
0a2fc71e
...
...
@@ -12,7 +12,7 @@
#include "JsonHelper.h"
#include "QGCQGeoCoordinate.h"
#include "QGCApplication.h"
#include "KML
File
Helper.h"
#include "KMLHelper.h"
#include <QGeoRectangle>
#include <QDebug>
...
...
@@ -352,7 +352,7 @@ bool QGCMapPolyline::loadKMLFile(const QString& kmlFile)
QString
errorString
;
QList
<
QGeoCoordinate
>
rgCoords
;
if
(
!
KML
File
Helper
::
loadPolylineFromFile
(
kmlFile
,
rgCoords
,
errorString
))
{
if
(
!
KMLHelper
::
loadPolylineFromFile
(
kmlFile
,
rgCoords
,
errorString
))
{
qgcApp
()
->
showMessage
(
errorString
);
return
false
;
}
...
...
src/MissionManager/TransectStyleComplexItem.cc
View file @
0a2fc71e
...
...
@@ -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
);
}
src/MissionManager/TransectStyleComplexItem.h
View file @
0a2fc71e
...
...
@@ -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
;
...
...
src/PlanView/TransectStyleMapVisuals.qml
View file @
0a2fc71e
...
...
@@ -73,7 +73,7 @@ Item {
interactive
:
polygonInteractive
&&
_missionItem
.
isCurrentItem
borderWidth
:
1
borderColor
:
"
black
"
interiorColor
:
"
green
"
interiorColor
:
QGroundControl
.
globalPalette
.
surveyPolygonInterior
interiorOpacity
:
0.5
}
...
...
src/QGCPalette.cc
View file @
0a2fc71e
...
...
@@ -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
)
...
...
src/QGCPalette.h
View file @
0a2fc71e
...
...
@@ -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
();
...
...
src/ShapeFileHelper.cc
View file @
0a2fc71e
...
...
@@ -9,7 +9,7 @@
#include "ShapeFileHelper.h"
#include "AppSettings.h"
#include "KML
File
Helper.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
=
KML
File
Helper
::
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
=
KML
File
Helper
::
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
)
{
KML
File
Helper
::
loadPolylineFromFile
(
file
,
coords
,
errorString
);
KMLHelper
::
loadPolylineFromFile
(
file
,
coords
,
errorString
);
}
else
{
errorString
=
QString
(
_errorPrefix
).
arg
(
tr
(
"Polyline not support from SHP files."
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment