diff --git a/src/MissionManager/TransectStyleComplexItem.cc b/src/MissionManager/TransectStyleComplexItem.cc index e22dd92b2f9195c1fa1dc02cf41e3de1ca503cd0..258b599685cbcf0dc4cd6c3cacc448547f7018af 100644 --- a/src/MissionManager/TransectStyleComplexItem.cc +++ b/src/MissionManager/TransectStyleComplexItem.cc @@ -412,7 +412,7 @@ void TransectStyleComplexItem::_reallyQueryTransectsPathHeightInfo(void) if (transectPoints.count() > 1) { _terrainPolyPathQuery = new TerrainPolyPathQuery(this); - connect(_terrainPolyPathQuery, &TerrainPolyPathQuery::terrainData, this, &TransectStyleComplexItem::_polyPathTerrainData); + connect(_terrainPolyPathQuery, &TerrainPolyPathQuery::terrainDataReceived, this, &TransectStyleComplexItem::_polyPathTerrainData); _terrainPolyPathQuery->requestData(transectPoints); } } diff --git a/src/MissionManager/VisualMissionItem.cc b/src/MissionManager/VisualMissionItem.cc index aa7ee72b8559d4717b41afd6f39860447a637bd5..70ccdbc5bce8b2957fba0ab34e63d03cfdb61967 100644 --- a/src/MissionManager/VisualMissionItem.cc +++ b/src/MissionManager/VisualMissionItem.cc @@ -186,7 +186,7 @@ void VisualMissionItem::_reallyUpdateTerrainAltitude(void) _lastLatTerrainQuery = coord.latitude(); _lastLonTerrainQuery = coord.longitude(); TerrainAtCoordinateQuery* terrain = new TerrainAtCoordinateQuery(this); - connect(terrain, &TerrainAtCoordinateQuery::terrainData, this, &VisualMissionItem::_terrainDataReceived); + connect(terrain, &TerrainAtCoordinateQuery::terrainDataReceived, this, &VisualMissionItem::_terrainDataReceived); QList rgCoord; rgCoord.append(coordinate()); terrain->requestData(rgCoord); diff --git a/src/QmlControls/AppMessages.qml b/src/QmlControls/AppMessages.qml index 77cfe33dbcf87568996f245e31fb97a963e3b85c..49eeda94880215a028832da70a28d541f4440eae 100644 --- a/src/QmlControls/AppMessages.qml +++ b/src/QmlControls/AppMessages.qml @@ -43,8 +43,22 @@ QGCView { id: categoryColumn spacing: ScreenTools.defaultFontPixelHeight / 2 + QGCButton { + text: qsTr("Clear All") + onClicked: { + var logCats = QGroundControl.loggingCategories() + for (var i=0; i& coordinates) { if (qgcApp()->runningUnitTests()) { - emit coordinateHeights(false, QList()); + emit coordinateHeightsReceived(false, QList()); return; } @@ -62,7 +62,7 @@ void TerrainAirMapQuery::requestCoordinateHeights(const QList& c void TerrainAirMapQuery::requestPathHeights(const QGeoCoordinate& fromCoord, const QGeoCoordinate& toCoord) { if (qgcApp()->runningUnitTests()) { - emit pathHeights(false, qQNaN(), qQNaN(), QList()); + emit pathHeightsReceived(false, qQNaN(), qQNaN(), QList()); return; } @@ -82,7 +82,7 @@ void TerrainAirMapQuery::requestPathHeights(const QGeoCoordinate& fromCoord, con void TerrainAirMapQuery::requestCarpetHeights(const QGeoCoordinate& swCoord, const QGeoCoordinate& neCoord, bool statsOnly) { if (qgcApp()->runningUnitTests()) { - emit carpetHeights(false, qQNaN(), qQNaN(), QList>()); + emit carpetHeightsReceived(false, qQNaN(), qQNaN(), QList>()); return; } @@ -204,13 +204,13 @@ void TerrainAirMapQuery::_requestFailed(void) { switch (_queryMode) { case QueryModeCoordinates: - emit coordinateHeights(false /* success */, QList() /* heights */); + emit coordinateHeightsReceived(false /* success */, QList() /* heights */); break; case QueryModePath: - emit pathHeights(false /* success */, qQNaN() /* latStep */, qQNaN() /* lonStep */, QList() /* heights */); + emit pathHeightsReceived(false /* success */, qQNaN() /* latStep */, qQNaN() /* lonStep */, QList() /* heights */); break; case QueryModeCarpet: - emit carpetHeights(false /* success */, qQNaN() /* minHeight */, qQNaN() /* maxHeight */, QList>() /* carpet */); + emit carpetHeightsReceived(false /* success */, qQNaN() /* minHeight */, qQNaN() /* maxHeight */, QList>() /* carpet */); break; } } @@ -223,7 +223,7 @@ void TerrainAirMapQuery::_parseCoordinateData(const QJsonValue& coordinateJson) heights.append(dataArray[i].toDouble()); } - emit coordinateHeights(true /* success */, heights); + emit coordinateHeightsReceived(true /* success */, heights); } void TerrainAirMapQuery::_parsePathData(const QJsonValue& pathJson) @@ -240,7 +240,7 @@ void TerrainAirMapQuery::_parsePathData(const QJsonValue& pathJson) heights.append(profileValue.toDouble()); } - emit pathHeights(true /* success */, latStep, lonStep, heights); + emit pathHeightsReceived(true /* success */, latStep, lonStep, heights); } void TerrainAirMapQuery::_parseCarpetData(const QJsonValue& carpetJson) @@ -266,7 +266,7 @@ void TerrainAirMapQuery::_parseCarpetData(const QJsonValue& carpetJson) } } - emit carpetHeights(true /*success*/, minHeight, maxHeight, carpet); + emit carpetHeightsReceived(true /*success*/, minHeight, maxHeight, carpet); } TerrainOfflineAirMapQuery::TerrainOfflineAirMapQuery(QObject* parent) @@ -278,7 +278,7 @@ TerrainOfflineAirMapQuery::TerrainOfflineAirMapQuery(QObject* parent) void TerrainOfflineAirMapQuery::requestCoordinateHeights(const QList& coordinates) { if (qgcApp()->runningUnitTests()) { - emit coordinateHeights(false, QList()); + emit coordinateHeightsReceived(false, QList()); return; } @@ -292,7 +292,7 @@ void TerrainOfflineAirMapQuery::requestCoordinateHeights(const QListrunningUnitTests()) { - emit pathHeights(false, qQNaN(), qQNaN(), QList()); + emit pathHeightsReceived(false, qQNaN(), qQNaN(), QList()); return; } @@ -302,7 +302,7 @@ void TerrainOfflineAirMapQuery::requestPathHeights(const QGeoCoordinate& fromCoo void TerrainOfflineAirMapQuery::requestCarpetHeights(const QGeoCoordinate& swCoord, const QGeoCoordinate& neCoord, bool statsOnly) { if (qgcApp()->runningUnitTests()) { - emit carpetHeights(false, qQNaN(), qQNaN(), QList>()); + emit carpetHeightsReceived(false, qQNaN(), qQNaN(), QList>()); return; } @@ -315,17 +315,17 @@ void TerrainOfflineAirMapQuery::requestCarpetHeights(const QGeoCoordinate& swCoo void TerrainOfflineAirMapQuery::_signalCoordinateHeights(bool success, QList heights) { - emit coordinateHeights(success, heights); + emit coordinateHeightsReceived(success, heights); } void TerrainOfflineAirMapQuery::_signalPathHeights(bool success, double latStep, double lonStep, const QList& heights) { - emit pathHeights(success, latStep, lonStep, heights); + emit pathHeightsReceived(success, latStep, lonStep, heights); } void TerrainOfflineAirMapQuery::_signalCarpetHeights(bool success, double minHeight, double maxHeight, const QList>& carpet) { - emit carpetHeights(success, minHeight, maxHeight, carpet); + emit carpetHeightsReceived(success, minHeight, maxHeight, carpet); } TerrainTileManager::TerrainTileManager(void) @@ -335,11 +335,13 @@ TerrainTileManager::TerrainTileManager(void) void TerrainTileManager::addCoordinateQuery(TerrainOfflineAirMapQuery* terrainQueryInterface, const QList& coordinates) { + qCDebug(TerrainQueryLog) << "TerrainTileManager::addCoordinateQuery count" << coordinates.count(); + if (coordinates.length() > 0) { QList altitudes; if (!_getAltitudesForCoordinates(coordinates, altitudes)) { - QueuedRequestInfo_t queuedRequestInfo = { terrainQueryInterface, QueryMode::QueryModeCoordinates, coordinates }; + QueuedRequestInfo_t queuedRequestInfo = { terrainQueryInterface, QueryMode::QueryModeCoordinates, 0, 0, coordinates }; _requestQueue.append(queuedRequestInfo); return; } @@ -351,31 +353,32 @@ void TerrainTileManager::addCoordinateQuery(TerrainOfflineAirMapQuery* terrainQu void TerrainTileManager::addPathQuery(TerrainOfflineAirMapQuery* terrainQueryInterface, const QGeoCoordinate &startPoint, const QGeoCoordinate &endPoint) { + // Convert to individual coordinate queries QList coordinates; double lat = startPoint.latitude(); double lon = startPoint.longitude(); + double steps = ceil(endPoint.distanceTo(startPoint) / TerrainTile::terrainAltitudeSpacing); double latDiff = endPoint.latitude() - lat; double lonDiff = endPoint.longitude() - lon; - double steps = ceil(endPoint.distanceTo(startPoint) / TerrainTile::terrainAltitudeSpacing); for (double i = 0.0; i <= steps; i = i + 1) { coordinates.append(QGeoCoordinate(lat + latDiff * i / steps, lon + lonDiff * i / steps)); } + // We always have one too many and we always want the last one to be the endpoint + coordinates.last() = endPoint; + double latStep = coordinates[1].latitude() - coordinates[0].latitude(); + double lonStep = coordinates[1].longitude() - coordinates[0].longitude(); + + qCDebug(TerrainQueryLog) << "TerrainTileManager::addPathQuery start:end:coordCount" << startPoint << endPoint << coordinates.count(); QList altitudes; if (!_getAltitudesForCoordinates(coordinates, altitudes)) { - QueuedRequestInfo_t queuedRequestInfo = { terrainQueryInterface, QueryMode::QueryModePath, coordinates }; + QueuedRequestInfo_t queuedRequestInfo = { terrainQueryInterface, QueryMode::QueryModePath, latStep, lonStep, coordinates }; _requestQueue.append(queuedRequestInfo); return; } qCDebug(TerrainQueryLog) << "All altitudes taken from cached data"; - double stepLat = 0; - double stepLon = 0; - if (coordinates.count() > 1) { - stepLat = coordinates[1].latitude() - coordinates[0].latitude(); - stepLon = coordinates[1].longitude() - coordinates[0].longitude(); - } - terrainQueryInterface->_signalPathHeights(coordinates.count() == altitudes.count(), stepLat, stepLon, altitudes); + terrainQueryInterface->_signalPathHeights(coordinates.count() == altitudes.count(), latStep, lonStep, altitudes); } bool TerrainTileManager::_getAltitudesForCoordinates(const QList& coordinates, QList& altitudes) @@ -421,6 +424,8 @@ void TerrainTileManager::_tileFailed(void) foreach (const QueuedRequestInfo_t& requestInfo, _requestQueue) { if (requestInfo.queryMode == QueryMode::QueryModeCoordinates) { requestInfo.terrainQueryInterface->_signalCoordinateHeights(false, noAltitudes); + } else if (requestInfo.queryMode == QueryMode::QueryModePath) { + requestInfo.terrainQueryInterface->_signalPathHeights(false, requestInfo.latStep, requestInfo.lonStep, noAltitudes); } } _requestQueue.clear(); @@ -473,9 +478,13 @@ void TerrainTileManager::_terrainDone(QByteArray responseBytes, QNetworkReply::N // now try to query the data again for (int i = _requestQueue.count() - 1; i >= 0; i--) { QList altitudes; - if (_getAltitudesForCoordinates(_requestQueue[i].coordinates, altitudes)) { - if (_requestQueue[i].queryMode == QueryMode::QueryModeCoordinates) { - _requestQueue[i].terrainQueryInterface->_signalCoordinateHeights(_requestQueue[i].coordinates.count() == altitudes.count(), altitudes); + QueuedRequestInfo_t& requestInfo = _requestQueue[i]; + + if (_getAltitudesForCoordinates(requestInfo.coordinates, altitudes)) { + if (requestInfo.queryMode == QueryMode::QueryModeCoordinates) { + requestInfo.terrainQueryInterface->_signalCoordinateHeights(requestInfo.coordinates.count() == altitudes.count(), altitudes); + } else if (requestInfo.queryMode == QueryMode::QueryModePath) { + requestInfo.terrainQueryInterface->_signalPathHeights(requestInfo.coordinates.count() == altitudes.count(), requestInfo.latStep, requestInfo.lonStep, altitudes); } _requestQueue.removeAt(i); } @@ -495,7 +504,7 @@ TerrainAtCoordinateBatchManager::TerrainAtCoordinateBatchManager(void) _batchTimer.setSingleShot(true); _batchTimer.setInterval(_batchTimeout); connect(&_batchTimer, &QTimer::timeout, this, &TerrainAtCoordinateBatchManager::_sendNextBatch); - connect(&_terrainQuery, &TerrainQueryInterface::coordinateHeights, this, &TerrainAtCoordinateBatchManager::_coordinateHeights); + connect(&_terrainQuery, &TerrainQueryInterface::coordinateHeightsReceived, this, &TerrainAtCoordinateBatchManager::_coordinateHeights); } void TerrainAtCoordinateBatchManager::addQuery(TerrainAtCoordinateQuery* terrainAtCoordinateQuery, const QList& coordinates) @@ -512,7 +521,7 @@ void TerrainAtCoordinateBatchManager::addQuery(TerrainAtCoordinateQuery* terrain void TerrainAtCoordinateBatchManager::_sendNextBatch(void) { - qCDebug(TerrainQueryLog) << "_sendNextBatch _state:_requestQueue.count:_sentRequests.count" << _stateToString(_state) << _requestQueue.count() << _sentRequests.count(); + qCDebug(TerrainQueryLog) << "TerrainAtCoordinateBatchManager::_sendNextBatch _state:_requestQueue.count:_sentRequests.count" << _stateToString(_state) << _requestQueue.count() << _sentRequests.count(); if (_state != State::Idle) { // Waiting for last download the complete, wait some more @@ -540,7 +549,7 @@ void TerrainAtCoordinateBatchManager::_sendNextBatch(void) } } _requestQueue = _requestQueue.mid(requestQueueAdded); - qCDebug(TerrainQueryLog) << "TerrainAtCoordinateBatchManager::_sendNextBatch - batch count:request queue count" << coords.count() << _requestQueue.count(); + qCDebug(TerrainQueryLog) << "_sendNextBatch - batch count:request queue count" << coords.count() << _requestQueue.count(); _state = State::Downloading; _terrainQuery.requestCoordinateHeights(coords); @@ -601,7 +610,7 @@ void TerrainAtCoordinateBatchManager::_coordinateHeights(bool success, QList& coordina void TerrainAtCoordinateQuery::_signalTerrainData(bool success, QList& heights) { - emit terrainData(success, heights); + emit terrainDataReceived(success, heights); } TerrainPathQuery::TerrainPathQuery(QObject* parent) : QObject(parent) { qRegisterMetaType(); - connect(&_terrainQuery, &TerrainQueryInterface::pathHeights, this, &TerrainPathQuery::_pathHeights); + connect(&_terrainQuery, &TerrainQueryInterface::pathHeightsReceived, this, &TerrainPathQuery::_pathHeights); } void TerrainPathQuery::requestData(const QGeoCoordinate& fromCoord, const QGeoCoordinate& toCoord) @@ -662,14 +671,14 @@ void TerrainPathQuery::_pathHeights(bool success, double latStep, double lonStep pathHeightInfo.latStep = latStep; pathHeightInfo.lonStep = lonStep; pathHeightInfo.heights = heights; - emit terrainData(success, pathHeightInfo); + emit terrainDataReceived(success, pathHeightInfo); } TerrainPolyPathQuery::TerrainPolyPathQuery(QObject* parent) : QObject (parent) , _curIndex (0) { - connect(&_pathQuery, &TerrainPathQuery::terrainData, this, &TerrainPolyPathQuery::_terrainDataReceived); + connect(&_pathQuery, &TerrainPathQuery::terrainDataReceived, this, &TerrainPolyPathQuery::_terrainDataReceived); } void TerrainPolyPathQuery::requestData(const QVariantList& polyPath) @@ -699,7 +708,7 @@ void TerrainPolyPathQuery::_terrainDataReceived(bool success, const TerrainPathQ if (!success) { _rgPathHeightInfo.clear(); - emit terrainData(false /* success */, _rgPathHeightInfo); + emit terrainDataReceived(false /* success */, _rgPathHeightInfo); return; } @@ -708,7 +717,7 @@ void TerrainPolyPathQuery::_terrainDataReceived(bool success, const TerrainPathQ if (++_curIndex >= _rgCoords.count() - 1) { // We've finished all requests qCDebug(TerrainQueryLog) << "TerrainPolyPathQuery::_terrainDataReceived complete"; - emit terrainData(true /* success */, _rgPathHeightInfo); + emit terrainDataReceived(true /* success */, _rgPathHeightInfo); } else { _pathQuery.requestData(_rgCoords[_curIndex], _rgCoords[_curIndex+1]); } @@ -717,7 +726,7 @@ void TerrainPolyPathQuery::_terrainDataReceived(bool success, const TerrainPathQ TerrainCarpetQuery::TerrainCarpetQuery(QObject* parent) : QObject(parent) { - connect(&_terrainQuery, &TerrainQueryInterface::carpetHeights, this, &TerrainCarpetQuery::terrainData); + connect(&_terrainQuery, &TerrainQueryInterface::carpetHeightsReceived, this, &TerrainCarpetQuery::terrainDataReceived); } void TerrainCarpetQuery::requestData(const QGeoCoordinate& swCoord, const QGeoCoordinate& neCoord, bool statsOnly) diff --git a/src/Terrain/TerrainQuery.h b/src/Terrain/TerrainQuery.h index 3f53f6ca9034060a3f0bb0b3150bc335af00d6c0..b913d06f6ccdb0867f5dff4f97dae8d4fd18848f 100644 --- a/src/Terrain/TerrainQuery.h +++ b/src/Terrain/TerrainQuery.h @@ -50,9 +50,9 @@ public: virtual void requestCarpetHeights(const QGeoCoordinate& swCoord, const QGeoCoordinate& neCoord, bool statsOnly) = 0; signals: - void coordinateHeights(bool success, QList heights); - void pathHeights(bool success, double latStep, double lonStep, const QList& heights); - void carpetHeights(bool success, double minHeight, double maxHeight, const QList>& carpet); + void coordinateHeightsReceived(bool success, QList heights); + void pathHeightsReceived(bool success, double latStep, double lonStep, const QList& heights); + void carpetHeightsReceived(bool success, double minHeight, double maxHeight, const QList>& carpet); }; /// AirMap online implementation of terrain queries @@ -136,6 +136,7 @@ private: typedef struct { TerrainOfflineAirMapQuery* terrainQueryInterface; QueryMode queryMode; + double latStep, lonStep; QList coordinates; } QueuedRequestInfo_t; @@ -210,7 +211,7 @@ public: void _signalTerrainData(bool success, QList& heights); signals: - void terrainData(bool success, QList heights); + void terrainDataReceived(bool success, QList heights); }; class TerrainPathQuery : public QObject @@ -233,7 +234,7 @@ public: signals: /// Signalled when terrain data comes back from server - void terrainData(bool success, const PathHeightInfo_t& pathHeightInfo); + void terrainDataReceived(bool success, const PathHeightInfo_t& pathHeightInfo); private slots: void _pathHeights(bool success, double latStep, double lonStep, const QList& heights); @@ -259,7 +260,7 @@ public: signals: /// Signalled when terrain data comes back from server - void terrainData(bool success, const QList& rgPathHeightInfo); + void terrainDataReceived(bool success, const QList& rgPathHeightInfo); private slots: void _terrainDataReceived(bool success, const TerrainPathQuery::PathHeightInfo_t& pathHeightInfo); @@ -288,7 +289,7 @@ public: signals: /// Signalled when terrain data comes back from server - void terrainData(bool success, double minHeight, double maxHeight, const QList>& carpet); + void terrainDataReceived(bool success, double minHeight, double maxHeight, const QList>& carpet); private: TerrainAirMapQuery _terrainQuery;