Browse Source

Merge pull request #6418 from DonLakeFlyer/TerrainAlt

Terrain batch fix, transect style generation fix
QGC4.4
Don Gagne 7 years ago committed by GitHub
parent
commit
7495626c33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      src/MissionManager/TransectStyleComplexItem.cc
  2. 14
      src/Terrain/TerrainQuery.cc
  3. 1
      src/Terrain/TerrainQuery.h

31
src/MissionManager/TransectStyleComplexItem.cc

@ -349,7 +349,23 @@ void TransectStyleComplexItem::_rebuildTransects(void) @@ -349,7 +349,23 @@ void TransectStyleComplexItem::_rebuildTransects(void)
_rebuildTransectsPhase1();
_queryTransectsPathHeightInfo();
if (_followTerrain) {
// Query the terrain data. Once available terrain heights will be calculated
_queryTransectsPathHeightInfo();
} else {
// Not following terrain, just add requested altitude to coords
double requestedAltitude = _cameraCalc.distanceToSurface()->rawValue().toDouble();
for (int i=0; i<_transects.count(); i++) {
QList<CoordInfo_t>& transect = _transects[i];
for (int j=0; j<transect.count(); j++) {
QGeoCoordinate& coord = transect[j].coord;
coord.setAltitude(requestedAltitude);
}
}
}
// Generate the visuals transect representation
_visualTransectPoints.clear();
@ -455,19 +471,6 @@ void TransectStyleComplexItem::_adjustTransectsForTerrain(void) @@ -455,19 +471,6 @@ void TransectStyleComplexItem::_adjustTransectsForTerrain(void)
}
emit lastSequenceNumberChanged(lastSequenceNumber());
} else {
// Not following terrain show just add requested altitude to coords
double requestedAltitude = _cameraCalc.distanceToSurface()->rawValue().toDouble();
for (int i=0; i<_transects.count(); i++) {
QList<CoordInfo_t>& transect = _transects[i];
for (int j=0; j<transect.count(); j++) {
QGeoCoordinate& coord = transect[j].coord;
coord.setAltitude(requestedAltitude);
}
}
}
}

14
src/Terrain/TerrainQuery.cc

@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
#include <cmath>
QGC_LOGGING_CATEGORY(TerrainQueryLog, "TerrainQueryLog")
QGC_LOGGING_CATEGORY(TerrainQueryVerboseLog, "TerrainQueryVerboseLog")
Q_GLOBAL_STATIC(TerrainAtCoordinateBatchManager, _TerrainAtCoordinateBatchManager)
Q_GLOBAL_STATIC(TerrainTileManager, _terrainTileManager)
@ -464,7 +465,7 @@ void TerrainTileManager::_terrainDone(QByteArray responseBytes, QNetworkReply::N @@ -464,7 +465,7 @@ void TerrainTileManager::_terrainDone(QByteArray responseBytes, QNetworkReply::N
QString TerrainTileManager::_getTileHash(const QGeoCoordinate& coordinate)
{
QString ret = QGCMapEngine::getTileHash(UrlFactory::AirmapElevation, QGCMapEngine::long2elevationTileX(coordinate.longitude(), 1), QGCMapEngine::lat2elevationTileY(coordinate.latitude(), 1), 1);
qCDebug(TerrainQueryLog) << "Computing unique tile hash for " << coordinate << ret;
qCDebug(TerrainQueryVerboseLog) << "Computing unique tile hash for " << coordinate << ret;
return ret;
}
@ -495,6 +496,7 @@ void TerrainAtCoordinateBatchManager::_sendNextBatch(void) @@ -495,6 +496,7 @@ void TerrainAtCoordinateBatchManager::_sendNextBatch(void)
if (_state != State::Idle) {
// Waiting for last download the complete, wait some more
qCDebug(TerrainQueryLog) << "_sendNextBatch restarting timer";
_batchTimer.start();
return;
}
@ -517,8 +519,8 @@ void TerrainAtCoordinateBatchManager::_sendNextBatch(void) @@ -517,8 +519,8 @@ void TerrainAtCoordinateBatchManager::_sendNextBatch(void)
break;
}
}
qCDebug(TerrainQueryLog) << "Built request: coordinate count" << coords.count();
_requestQueue = _requestQueue.mid(requestQueueAdded);
qCDebug(TerrainQueryLog) << "TerrainAtCoordinateBatchManager::_sendNextBatch - batch count:request queue count" << coords.count() << _requestQueue.count();
_state = State::Downloading;
_terrainQuery.requestCoordinateHeights(coords);
@ -579,6 +581,8 @@ void TerrainAtCoordinateBatchManager::_coordinateHeights(bool success, QList<dou @@ -579,6 +581,8 @@ void TerrainAtCoordinateBatchManager::_coordinateHeights(bool success, QList<dou
{
_state = State::Idle;
qCDebug(TerrainQueryLog) << "_coordinateHeights success:count" << success << heights.count();
if (!success) {
_batchFailed();
return;
@ -587,7 +591,7 @@ void TerrainAtCoordinateBatchManager::_coordinateHeights(bool success, QList<dou @@ -587,7 +591,7 @@ void TerrainAtCoordinateBatchManager::_coordinateHeights(bool success, QList<dou
int currentIndex = 0;
foreach (const SentRequestInfo_t& sentRequestInfo, _sentRequests) {
if (!sentRequestInfo.queryObjectDestroyed) {
qCDebug(TerrainQueryLog) << "TerrainAtCoordinateBatchManager::_coordinateHeights returned TerrainCoordinateQuery:count" << sentRequestInfo.terrainAtCoordinateQuery << sentRequestInfo.cCoord;
qCDebug(TerrainQueryVerboseLog) << "TerrainAtCoordinateBatchManager::_coordinateHeights returned TerrainCoordinateQuery:count" << sentRequestInfo.terrainAtCoordinateQuery << sentRequestInfo.cCoord;
disconnect(sentRequestInfo.terrainAtCoordinateQuery, &TerrainAtCoordinateQuery::destroyed, this, &TerrainAtCoordinateBatchManager::_queryObjectDestroyed);
QList<double> requestAltitudes = heights.mid(currentIndex, sentRequestInfo.cCoord);
sentRequestInfo.terrainAtCoordinateQuery->_signalTerrainData(true, requestAltitudes);
@ -595,6 +599,10 @@ void TerrainAtCoordinateBatchManager::_coordinateHeights(bool success, QList<dou @@ -595,6 +599,10 @@ void TerrainAtCoordinateBatchManager::_coordinateHeights(bool success, QList<dou
}
}
_sentRequests.clear();
if (_requestQueue.count()) {
_batchTimer.start();
}
}
TerrainAtCoordinateQuery::TerrainAtCoordinateQuery(QObject* parent)

1
src/Terrain/TerrainQuery.h

@ -21,6 +21,7 @@ @@ -21,6 +21,7 @@
#include <QtLocation/private/qgeotiledmapreply_p.h>
Q_DECLARE_LOGGING_CATEGORY(TerrainQueryLog)
Q_DECLARE_LOGGING_CATEGORY(TerrainQueryVerboseLog)
class TerrainAtCoordinateQuery;

Loading…
Cancel
Save