Commit 5ddddfda authored by Don Gagne's avatar Don Gagne

Correct use of specifiesCoordinate

parent b25cde07
......@@ -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());
}
}
......
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