Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
0ca437cd
Commit
0ca437cd
authored
Dec 03, 2016
by
Don Gagne
Committed by
GitHub
Dec 03, 2016
Browse files
Merge pull request #4283 from DonLakeFlyer/AddPlannedHomePosition
Correct use of specifiesCoordinate
parents
9f760e33
5ddddfda
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/MissionManager/MissionController.cc
View file @
0ca437cd
...
...
@@ -1208,31 +1208,43 @@ double MissionController::_normalizeLon(double lon)
/// Add the home position item to the front of the list
void
MissionController
::
_addPlannedHomePosition
(
QmlObjectListModel
*
visualItems
,
bool
addToCenter
)
{
bool
homePositionSet
=
false
;
SimpleMissionItem
*
homeItem
=
new
SimpleMissionItem
(
_activeVehicle
,
this
);
visualItems
->
insert
(
0
,
homeItem
);
if
(
visualItems
->
count
()
>
1
&&
addToCenter
)
{
VisualMissionItem
*
item
=
qobject_cast
<
VisualMissionItem
*>
(
visualItems
->
get
(
1
));
double
north
=
_normalizeLat
(
item
->
coordinate
().
latitude
());
double
south
=
north
;
double
east
=
_normalizeLon
(
item
->
coordinate
().
longitude
());
double
west
=
east
;
for
(
int
i
=
2
;
i
<
visualItems
->
count
();
i
++
)
{
item
=
qobject_cast
<
VisualMissionItem
*>
(
visualItems
->
get
(
i
));
double
north
,
south
,
east
,
west
;
bool
firstCoordSet
=
false
;
double
lat
=
_normalizeLat
(
item
->
coordinate
().
latitude
());
double
lon
=
_normalizeLon
(
item
->
coordinate
().
longitude
());
for
(
int
i
=
1
;
i
<
visualItems
->
count
();
i
++
)
{
VisualMissionItem
*
item
=
qobject_cast
<
VisualMissionItem
*>
(
visualItems
->
get
(
i
));
if
(
item
->
specifiesCoordinate
())
{
if
(
firstCoordSet
)
{
double
lat
=
_normalizeLat
(
item
->
coordinate
().
latitude
());
double
lon
=
_normalizeLon
(
item
->
coordinate
().
longitude
());
north
=
fmax
(
north
,
lat
);
south
=
fmin
(
south
,
lat
);
east
=
fmax
(
east
,
lon
);
west
=
fmin
(
west
,
lon
);
}
else
{
firstCoordSet
=
true
;
north
=
_normalizeLat
(
item
->
coordinate
().
latitude
());
south
=
north
;
east
=
_normalizeLon
(
item
->
coordinate
().
longitude
());
west
=
east
;
}
}
}
north
=
fmax
(
north
,
lat
);
south
=
fmin
(
south
,
lat
);
east
=
fmax
(
east
,
lon
);
west
=
fmin
(
west
,
lon
);
if
(
firstCoordSet
)
{
homePositionSet
=
true
;
homeItem
->
setCoordinate
(
QGeoCoordinate
((
south
+
((
north
-
south
)
/
2
))
-
90.0
,
(
west
+
((
east
-
west
)
/
2
))
-
180.0
,
0.0
));
}
}
homeItem
->
setCoordinate
(
QGeoCoordinate
((
south
+
((
north
-
south
)
/
2
))
-
90.0
,
(
west
+
((
east
-
west
)
/
2
))
-
180.0
,
0.0
));
}
else
{
if
(
!
homePositionSet
)
{
homeItem
->
setCoordinate
(
qgcApp
()
->
lastKnownHomePosition
());
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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