From 32a35ac910c13e65c1959a3d453a19cecfb08f4e Mon Sep 17 00:00:00 2001 From: Andreas Bircher Date: Fri, 16 Mar 2018 11:46:03 +0100 Subject: [PATCH] remove tile download queue --- src/Terrain.cc | 36 ++++++++++++------------------------ src/Terrain.h | 1 - 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/Terrain.cc b/src/Terrain.cc index 38560f0c7..55dd81556 100644 --- a/src/Terrain.cc +++ b/src/Terrain.cc @@ -54,23 +54,18 @@ bool TerrainBatchManager::_getAltitudesForCoordinates(const QListurlFactory()->getTileURL(UrlFactory::AirmapElevation, QGCMapEngine::long2elevationTileX(coordinate.longitude(), 1), QGCMapEngine::lat2elevationTileY(coordinate.latitude(), 1), 1, &_networkManager); - QGeoTileSpec spec; - spec.setX(QGCMapEngine::long2elevationTileX(coordinate.longitude(), 1)); - spec.setY(QGCMapEngine::lat2elevationTileY(coordinate.latitude(), 1)); - spec.setZoom(1); - spec.setMapId(UrlFactory::AirmapElevation); - QGeoTiledMapReplyQGC* reply = new QGeoTiledMapReplyQGC(&_networkManager, request, spec); - connect(reply, &QGeoTiledMapReplyQGC::finished, this, &TerrainBatchManager::_fetchedTile); - connect(reply, &QGeoTiledMapReplyQGC::aborted, this, &TerrainBatchManager::_fetchedTile); - _state = State::Downloading; - } - - _tileDownloadQueue.append(tileHash); + // Schedule the fetch task + if (_state != State::Downloading) { + QNetworkRequest request = getQGCMapEngine()->urlFactory()->getTileURL(UrlFactory::AirmapElevation, QGCMapEngine::long2elevationTileX(coordinate.longitude(), 1), QGCMapEngine::lat2elevationTileY(coordinate.latitude(), 1), 1, &_networkManager); + QGeoTileSpec spec; + spec.setX(QGCMapEngine::long2elevationTileX(coordinate.longitude(), 1)); + spec.setY(QGCMapEngine::lat2elevationTileY(coordinate.latitude(), 1)); + spec.setZoom(1); + spec.setMapId(UrlFactory::AirmapElevation); + QGeoTiledMapReplyQGC* reply = new QGeoTiledMapReplyQGC(&_networkManager, request, spec); + connect(reply, &QGeoTiledMapReplyQGC::finished, this, &TerrainBatchManager::_fetchedTile); + connect(reply, &QGeoTiledMapReplyQGC::aborted, this, &TerrainBatchManager::_fetchedTile); + _state = State::Downloading; } _tilesMutex.unlock(); @@ -111,13 +106,6 @@ void TerrainBatchManager::_fetchedTile() // remove from download queue QGeoTileSpec spec = reply->tileSpec(); QString hash = QGCMapEngine::getTileHash(UrlFactory::AirmapElevation, spec.x(), spec.y(), spec.zoom()); - _tilesMutex.lock(); - if (_tileDownloadQueue.contains(hash)) { - _tileDownloadQueue.removeOne(hash); - } else { - qCDebug(ElevationProviderLog) << "Loaded elevation tile, but not found in download queue."; - } - _tilesMutex.unlock(); // handle potential errors if (reply->error() != QGeoTiledMapReply::NoError) { diff --git a/src/Terrain.h b/src/Terrain.h index 36f642cb2..18bc55f22 100644 --- a/src/Terrain.h +++ b/src/Terrain.h @@ -57,7 +57,6 @@ private: QMutex _tilesMutex; QHash _tiles; - QStringList _tileDownloadQueue; }; class ElevationProvider : public QObject -- 2.22.0