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) ...@@ -1208,31 +1208,43 @@ double MissionController::_normalizeLon(double lon)
/// Add the home position item to the front of the list /// Add the home position item to the front of the list
void MissionController::_addPlannedHomePosition(QmlObjectListModel* visualItems, bool addToCenter) void MissionController::_addPlannedHomePosition(QmlObjectListModel* visualItems, bool addToCenter)
{ {
bool homePositionSet = false;
SimpleMissionItem* homeItem = new SimpleMissionItem(_activeVehicle, this); SimpleMissionItem* homeItem = new SimpleMissionItem(_activeVehicle, this);
visualItems->insert(0, homeItem); visualItems->insert(0, homeItem);
if (visualItems->count() > 1 && addToCenter) { if (visualItems->count() > 1 && addToCenter) {
VisualMissionItem* item = qobject_cast<VisualMissionItem*>(visualItems->get(1)); double north, south, east, west;
bool firstCoordSet = false;
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 lat = _normalizeLat(item->coordinate().latitude()); for (int i=1; i<visualItems->count(); i++) {
double lon = _normalizeLon(item->coordinate().longitude()); 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); if (firstCoordSet) {
south = fmin(south, lat); homePositionSet = true;
east = fmax(east, lon); homeItem->setCoordinate(QGeoCoordinate((south + ((north - south) / 2)) - 90.0, (west + ((east - west) / 2)) - 180.0, 0.0));
west = fmin(west, lon);
} }
}
homeItem->setCoordinate(QGeoCoordinate((south + ((north - south) / 2)) - 90.0, (west + ((east - west) / 2)) - 180.0, 0.0)); if (!homePositionSet) {
} else {
homeItem->setCoordinate(qgcApp()->lastKnownHomePosition()); 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