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
dd1ea23a
Unverified
Commit
dd1ea23a
authored
Mar 20, 2018
by
Don Gagne
Committed by
GitHub
Mar 20, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6239 from DonLakeFlyer/PolyLineLoadKML
PolyLine load kml support
parents
5e705032
3f1b3bf2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
111 additions
and
84 deletions
+111
-84
QGCMapPolygon.cc
src/MissionManager/QGCMapPolygon.cc
+5
-6
QGCMapPolyline.cc
src/MissionManager/QGCMapPolyline.cc
+16
-25
QGCMapPolyline.h
src/MissionManager/QGCMapPolyline.h
+1
-0
QGCMapPolylineVisuals.qml
src/MissionManager/QGCMapPolylineVisuals.qml
+33
-2
TransectStyle.SettingsGroup.json
src/MissionManager/TransectStyle.SettingsGroup.json
+3
-3
TransectStyleComplexItem.cc
src/MissionManager/TransectStyleComplexItem.cc
+53
-48
No files found.
src/MissionManager/QGCMapPolygon.cc
View file @
dd1ea23a
...
...
@@ -56,9 +56,11 @@ const QGCMapPolygon& QGCMapPolygon::operator=(const QGCMapPolygon& other)
clear
();
QVariantList
vertices
=
other
.
path
();
for
(
int
i
=
0
;
i
<
vertices
.
count
();
i
++
)
{
appendVertex
(
vertices
[
i
].
value
<
QGeoCoordinate
>
());
QList
<
QGeoCoordinate
>
rgCoord
;
foreach
(
const
QVariant
&
vertexVar
,
vertices
)
{
rgCoord
.
append
(
vertexVar
.
value
<
QGeoCoordinate
>
());
}
appendVertices
(
rgCoord
);
setDirty
(
true
);
...
...
@@ -270,7 +272,6 @@ void QGCMapPolygon::appendVertices(const QList<QGeoCoordinate>& coordinates)
emit
pathChanged
();
}
void
QGCMapPolygon
::
_polygonModelDirtyChanged
(
bool
dirty
)
{
if
(
dirty
)
{
...
...
@@ -447,9 +448,7 @@ void QGCMapPolygon::offset(double distance)
// Update internals
clear
();
for
(
int
i
=
0
;
i
<
rgNewPolygon
.
count
();
i
++
)
{
appendVertex
(
rgNewPolygon
[
i
]);
}
appendVertices
(
rgNewPolygon
);
}
bool
QGCMapPolygon
::
loadKMLFile
(
const
QString
&
kmlFile
)
...
...
src/MissionManager/QGCMapPolyline.cc
View file @
dd1ea23a
...
...
@@ -358,13 +358,13 @@ bool QGCMapPolyline::loadKMLFile(const QString& kmlFile)
return
false
;
}
QDomNodeList
rgNodes
=
doc
.
elementsByTagName
(
"
Polygon
"
);
QDomNodeList
rgNodes
=
doc
.
elementsByTagName
(
"
LineString
"
);
if
(
rgNodes
.
count
()
==
0
)
{
qgcApp
()
->
showMessage
(
tr
(
"Unable to find
Polygon
node in KML"
));
qgcApp
()
->
showMessage
(
tr
(
"Unable to find
LineString
node in KML"
));
return
false
;
}
QDomNode
coordinatesNode
=
rgNodes
.
item
(
0
).
namedItem
(
"
outerBoundaryIs"
).
namedItem
(
"LinearRing"
).
namedItem
(
"
coordinates"
);
QDomNode
coordinatesNode
=
rgNodes
.
item
(
0
).
namedItem
(
"coordinates"
);
if
(
coordinatesNode
.
isNull
())
{
qgcApp
()
->
showMessage
(
tr
(
"Internal error: Unable to find coordinates node in KML"
));
return
false
;
...
...
@@ -386,29 +386,8 @@ bool QGCMapPolyline::loadKMLFile(const QString& kmlFile)
rgCoords
.
append
(
coord
);
}
// Determine winding, reverse if needed
double
sum
=
0
;
for
(
int
i
=
0
;
i
<
rgCoords
.
count
();
i
++
)
{
QGeoCoordinate
coord1
=
rgCoords
[
i
];
QGeoCoordinate
coord2
=
(
i
==
rgCoords
.
count
()
-
1
)
?
rgCoords
[
0
]
:
rgCoords
[
i
+
1
];
sum
+=
(
coord2
.
longitude
()
-
coord1
.
longitude
())
*
(
coord2
.
latitude
()
+
coord1
.
latitude
());
}
bool
reverse
=
sum
<
0.0
;
if
(
reverse
)
{
QList
<
QGeoCoordinate
>
rgReversed
;
for
(
int
i
=
0
;
i
<
rgCoords
.
count
();
i
++
)
{
rgReversed
.
prepend
(
rgCoords
[
i
]);
}
rgCoords
=
rgReversed
;
}
clear
();
for
(
int
i
=
0
;
i
<
rgCoords
.
count
();
i
++
)
{
appendVertex
(
rgCoords
[
i
]);
}
appendVertices
(
rgCoords
);
return
true
;
}
...
...
@@ -438,3 +417,15 @@ double QGCMapPolyline::length(void) const
return
length
;
}
void
QGCMapPolyline
::
appendVertices
(
const
QList
<
QGeoCoordinate
>&
coordinates
)
{
QList
<
QObject
*>
objects
;
foreach
(
const
QGeoCoordinate
&
coordinate
,
coordinates
)
{
objects
.
append
(
new
QGCQGeoCoordinate
(
coordinate
,
this
));
_polylinePath
.
append
(
QVariant
::
fromValue
(
coordinate
));
}
_polylineModel
.
append
(
objects
);
emit
pathChanged
();
}
src/MissionManager/QGCMapPolyline.h
View file @
dd1ea23a
...
...
@@ -34,6 +34,7 @@ public:
Q_INVOKABLE
void
clear
(
void
);
Q_INVOKABLE
void
appendVertex
(
const
QGeoCoordinate
&
coordinate
);
Q_INVOKABLE
void
removeVertex
(
int
vertexIndex
);
Q_INVOKABLE
void
appendVertices
(
const
QList
<
QGeoCoordinate
>&
coordinates
);
/// Adjust the value for the specified coordinate
/// @param vertexIndex Polygon point index to modify (0-based)
...
...
src/MissionManager/QGCMapPolylineVisuals.qml
View file @
dd1ea23a
...
...
@@ -120,13 +120,28 @@ Item {
selectExisting
:
true
nameFilters
:
[
qsTr
(
"
KML files (*.kml)
"
)
]
onAcceptedForLoad
:
{
mapPolyline
.
loadKMLFile
(
file
)
close
()
}
}
Menu
{
id
:
menu
property
int
removeVertex
MenuItem
{
text
:
qsTr
(
"
Remove vertex
"
)
onTriggered
:
mapPolyline
.
removeVertex
(
parent
.
removeVertex
)
}
MenuItem
{
text
:
qsTr
(
"
Load KML...
"
)
onTriggered
:
kmlLoadDialog
.
openForLoad
()
}
}
Component
{
id
:
polylineComponent
...
...
@@ -227,7 +242,15 @@ Item {
}
}
onClicked
:
mapPolyline
.
removeVertex
(
polylineVertex
)
onClicked
:
{
if
(
polylineVertex
==
0
)
{
menu
.
removeVertex
=
polylineVertex
menu
.
popup
()
}
else
{
mapPolyline
.
removeVertex
(
polylineVertex
)
}
}
}
}
...
...
@@ -249,6 +272,14 @@ Item {
radius
:
width
/
2
color
:
"
white
"
opacity
:
.
90
QGCLabel
{
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.verticalCenter
:
parent
.
verticalCenter
text
:
"
...
"
color
:
"
black
"
visible
:
polylineVertex
==
0
}
}
}
}
...
...
src/MissionManager/TransectStyle.SettingsGroup.json
View file @
dd1ea23a
...
...
@@ -37,7 +37,7 @@
},
{
"name"
:
"TerrainAdjustTolerance"
,
"shortDescription"
:
"
TerrainAdjustTolerance
"
,
"shortDescription"
:
"
If adjacent terrain waypoints are within this tolerence they will be removed.
"
,
"type"
:
"double"
,
"decimalPlaces"
:
2
,
"min"
:
0
,
...
...
@@ -46,7 +46,7 @@
},
{
"name"
:
"TerrainAdjustMaxClimbRate"
,
"shortDescription"
:
"T
errainAdjustMaxClimbRate
"
,
"shortDescription"
:
"T
he maximum climb rate from one waypoint to another when adjusting for terrain. Set to 0 for no max.
"
,
"type"
:
"double"
,
"decimalPlaces"
:
2
,
"min"
:
0
,
...
...
@@ -55,7 +55,7 @@
},
{
"name"
:
"TerrainAdjustMaxDescentRate"
,
"shortDescription"
:
"T
errainAdjustMaxDescentRate
"
,
"shortDescription"
:
"T
he maximum descent rate from one waypoint to another when adjusting for terrain. Set to 0 for no max.
"
,
"type"
:
"double"
,
"decimalPlaces"
:
2
,
"min"
:
0
,
...
...
src/MissionManager/TransectStyleComplexItem.cc
View file @
dd1ea23a
...
...
@@ -500,7 +500,7 @@ int TransectStyleComplexItem::_maxPathHeight(const TerrainPathQuery::PathHeightI
void
TransectStyleComplexItem
::
_adjustForMaxRates
(
QList
<
CoordInfo_t
>&
transect
)
{
double
maxClimbRate
=
_terrainAdjustMaxClimbRateFact
.
rawValue
().
toDouble
();
double
maxDescentRate
=
-
_terrainAdjustMaxDescentRateFact
.
rawValue
().
toDouble
();
double
maxDescentRate
=
_terrainAdjustMaxDescentRateFact
.
rawValue
().
toDouble
();
double
flightSpeed
=
_missionFlightStatus
.
vehicleSpeed
;
if
(
qIsNaN
(
flightSpeed
)
||
(
maxClimbRate
==
0
&&
maxDescentRate
==
0
))
{
...
...
@@ -510,55 +510,60 @@ void TransectStyleComplexItem::_adjustForMaxRates(QList<CoordInfo_t>& transect)
return
;
}
// Adjust climb rates
bool
climbRateAdjusted
;
do
{
//qDebug() << "climbrate pass";
climbRateAdjusted
=
false
;
for
(
int
i
=
0
;
i
<
transect
.
count
()
-
1
;
i
++
)
{
QGeoCoordinate
&
fromCoord
=
transect
[
i
].
coord
;
QGeoCoordinate
&
toCoord
=
transect
[
i
+
1
].
coord
;
double
altDifference
=
toCoord
.
altitude
()
-
fromCoord
.
altitude
();
double
distance
=
fromCoord
.
distanceTo
(
toCoord
);
double
seconds
=
distance
/
flightSpeed
;
double
climbRate
=
altDifference
/
seconds
;
//qDebug() << QString("Index:%1 altDifference:%2 distance:%3 seconds:%4 climbRate:%5").arg(i).arg(altDifference).arg(distance).arg(seconds).arg(climbRate);
if
(
climbRate
>
0
&&
climbRate
-
maxClimbRate
>
0.1
)
{
double
maxAltitudeDelta
=
maxClimbRate
*
seconds
;
fromCoord
.
setAltitude
(
toCoord
.
altitude
()
-
maxAltitudeDelta
);
//qDebug() << "Adjusting";
climbRateAdjusted
=
true
;
if
(
maxClimbRate
>
0
)
{
// Adjust climb rates
bool
climbRateAdjusted
;
do
{
//qDebug() << "climbrate pass";
climbRateAdjusted
=
false
;
for
(
int
i
=
0
;
i
<
transect
.
count
()
-
1
;
i
++
)
{
QGeoCoordinate
&
fromCoord
=
transect
[
i
].
coord
;
QGeoCoordinate
&
toCoord
=
transect
[
i
+
1
].
coord
;
double
altDifference
=
toCoord
.
altitude
()
-
fromCoord
.
altitude
();
double
distance
=
fromCoord
.
distanceTo
(
toCoord
);
double
seconds
=
distance
/
flightSpeed
;
double
climbRate
=
altDifference
/
seconds
;
//qDebug() << QString("Index:%1 altDifference:%2 distance:%3 seconds:%4 climbRate:%5").arg(i).arg(altDifference).arg(distance).arg(seconds).arg(climbRate);
if
(
climbRate
>
0
&&
climbRate
-
maxClimbRate
>
0.1
)
{
double
maxAltitudeDelta
=
maxClimbRate
*
seconds
;
fromCoord
.
setAltitude
(
toCoord
.
altitude
()
-
maxAltitudeDelta
);
//qDebug() << "Adjusting";
climbRateAdjusted
=
true
;
}
}
}
}
while
(
climbRateAdjusted
);
// Adjust descent rates
bool
descentRateAdjusted
;
do
{
//qDebug() << "descent rate pass";
descentRateAdjusted
=
false
;
for
(
int
i
=
1
;
i
<
transect
.
count
();
i
++
)
{
QGeoCoordinate
&
fromCoord
=
transect
[
i
-
1
].
coord
;
QGeoCoordinate
&
toCoord
=
transect
[
i
].
coord
;
double
altDifference
=
toCoord
.
altitude
()
-
fromCoord
.
altitude
();
double
distance
=
fromCoord
.
distanceTo
(
toCoord
);
double
seconds
=
distance
/
flightSpeed
;
double
descentRate
=
altDifference
/
seconds
;
//qDebug() << QString("Index:%1 altDifference:%2 distance:%3 seconds:%4 descentRate:%5").arg(i).arg(altDifference).arg(distance).arg(seconds).arg(descentRate);
if
(
descentRate
<
0
&&
descentRate
-
maxDescentRate
<
-
0.1
)
{
double
maxAltitudeDelta
=
maxDescentRate
*
seconds
;
toCoord
.
setAltitude
(
fromCoord
.
altitude
()
+
maxAltitudeDelta
);
//qDebug() << "Adjusting";
descentRateAdjusted
=
true
;
}
while
(
climbRateAdjusted
);
}
if
(
maxDescentRate
>
0
)
{
// Adjust descent rates
bool
descentRateAdjusted
;
maxDescentRate
=
-
maxDescentRate
;
do
{
//qDebug() << "descent rate pass";
descentRateAdjusted
=
false
;
for
(
int
i
=
1
;
i
<
transect
.
count
();
i
++
)
{
QGeoCoordinate
&
fromCoord
=
transect
[
i
-
1
].
coord
;
QGeoCoordinate
&
toCoord
=
transect
[
i
].
coord
;
double
altDifference
=
toCoord
.
altitude
()
-
fromCoord
.
altitude
();
double
distance
=
fromCoord
.
distanceTo
(
toCoord
);
double
seconds
=
distance
/
flightSpeed
;
double
descentRate
=
altDifference
/
seconds
;
//qDebug() << QString("Index:%1 altDifference:%2 distance:%3 seconds:%4 descentRate:%5").arg(i).arg(altDifference).arg(distance).arg(seconds).arg(descentRate);
if
(
descentRate
<
0
&&
descentRate
-
maxDescentRate
<
-
0.1
)
{
double
maxAltitudeDelta
=
maxDescentRate
*
seconds
;
toCoord
.
setAltitude
(
fromCoord
.
altitude
()
+
maxAltitudeDelta
);
//qDebug() << "Adjusting";
descentRateAdjusted
=
true
;
}
}
}
}
while
(
descentRateAdjusted
);
}
while
(
descentRateAdjusted
);
}
}
void
TransectStyleComplexItem
::
_adjustForTolerance
(
QList
<
CoordInfo_t
>&
transect
)
...
...
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