Commit 32a35ac9 authored by Andreas Bircher's avatar Andreas Bircher

remove tile download queue

parent 96fc6a8c
...@@ -54,23 +54,18 @@ bool TerrainBatchManager::_getAltitudesForCoordinates(const QList<QGeoCoordinate ...@@ -54,23 +54,18 @@ bool TerrainBatchManager::_getAltitudesForCoordinates(const QList<QGeoCoordinate
if (!_tiles.contains(tileHash)) { if (!_tiles.contains(tileHash)) {
qCDebug(ElevationProviderLog) << "Need to download tile " << tileHash; qCDebug(ElevationProviderLog) << "Need to download tile " << tileHash;
if (!_tileDownloadQueue.contains(tileHash)) { // Schedule the fetch task
// 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);
if (_state != State::Downloading) { QGeoTileSpec spec;
QNetworkRequest request = getQGCMapEngine()->urlFactory()->getTileURL(UrlFactory::AirmapElevation, QGCMapEngine::long2elevationTileX(coordinate.longitude(), 1), QGCMapEngine::lat2elevationTileY(coordinate.latitude(), 1), 1, &_networkManager); spec.setX(QGCMapEngine::long2elevationTileX(coordinate.longitude(), 1));
QGeoTileSpec spec; spec.setY(QGCMapEngine::lat2elevationTileY(coordinate.latitude(), 1));
spec.setX(QGCMapEngine::long2elevationTileX(coordinate.longitude(), 1)); spec.setZoom(1);
spec.setY(QGCMapEngine::lat2elevationTileY(coordinate.latitude(), 1)); spec.setMapId(UrlFactory::AirmapElevation);
spec.setZoom(1); QGeoTiledMapReplyQGC* reply = new QGeoTiledMapReplyQGC(&_networkManager, request, spec);
spec.setMapId(UrlFactory::AirmapElevation); connect(reply, &QGeoTiledMapReplyQGC::finished, this, &TerrainBatchManager::_fetchedTile);
QGeoTiledMapReplyQGC* reply = new QGeoTiledMapReplyQGC(&_networkManager, request, spec); connect(reply, &QGeoTiledMapReplyQGC::aborted, this, &TerrainBatchManager::_fetchedTile);
connect(reply, &QGeoTiledMapReplyQGC::finished, this, &TerrainBatchManager::_fetchedTile); _state = State::Downloading;
connect(reply, &QGeoTiledMapReplyQGC::aborted, this, &TerrainBatchManager::_fetchedTile);
_state = State::Downloading;
}
_tileDownloadQueue.append(tileHash);
} }
_tilesMutex.unlock(); _tilesMutex.unlock();
...@@ -111,13 +106,6 @@ void TerrainBatchManager::_fetchedTile() ...@@ -111,13 +106,6 @@ void TerrainBatchManager::_fetchedTile()
// remove from download queue // remove from download queue
QGeoTileSpec spec = reply->tileSpec(); QGeoTileSpec spec = reply->tileSpec();
QString hash = QGCMapEngine::getTileHash(UrlFactory::AirmapElevation, spec.x(), spec.y(), spec.zoom()); 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 // handle potential errors
if (reply->error() != QGeoTiledMapReply::NoError) { if (reply->error() != QGeoTiledMapReply::NoError) {
......
...@@ -57,7 +57,6 @@ private: ...@@ -57,7 +57,6 @@ private:
QMutex _tilesMutex; QMutex _tilesMutex;
QHash<QString, TerrainTile> _tiles; QHash<QString, TerrainTile> _tiles;
QStringList _tileDownloadQueue;
}; };
class ElevationProvider : public QObject class ElevationProvider : public QObject
......
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