File indexing completed on 2025-01-05 03:59:37
0001 // SPDX-FileCopyrightText: 2010 Jens-Michael Hoffmann <jmho@c-xx.com> 0002 // SPDX-FileCopyrightText: 2010-2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de> 0003 // 0004 // SPDX-License-Identifier: LGPL-2.1-or-later 0005 0006 #ifndef MARBLE_TILELOADER_H 0007 #define MARBLE_TILELOADER_H 0008 0009 #include <QObject> 0010 0011 #include "PluginManager.h" 0012 #include "MarbleGlobal.h" 0013 0014 class QByteArray; 0015 class QImage; 0016 class QUrl; 0017 class QString; 0018 0019 namespace Marble 0020 { 0021 class TileId; 0022 class HttpDownloadManager; 0023 class GeoDataDocument; 0024 class GeoSceneTileDataset; 0025 class GeoSceneTextureTileDataset; 0026 class GeoSceneVectorTileDataset; 0027 0028 class TileLoader: public QObject 0029 { 0030 Q_OBJECT 0031 0032 public: 0033 enum TileStatus { 0034 Missing, 0035 Expired, 0036 Available 0037 }; 0038 0039 explicit TileLoader(HttpDownloadManager * const, const PluginManager * ); 0040 ~TileLoader() override; 0041 0042 QImage loadTileImage( GeoSceneTextureTileDataset const *textureData, TileId const & tileId, DownloadUsage const ); 0043 GeoDataDocument* loadTileVectorData( GeoSceneVectorTileDataset const *vectorData, TileId const & tileId, DownloadUsage const usage ); 0044 void downloadTile( GeoSceneTileDataset const *tileData, TileId const &, DownloadUsage const ); 0045 0046 static int maximumTileLevel( GeoSceneTileDataset const & tileData ); 0047 0048 /** 0049 * Returns whether the mandatory most basic tile level is fully available for 0050 * the given @p layer. 0051 */ 0052 static bool baseTilesAvailable( GeoSceneTileDataset const & tileData ); 0053 0054 /** 0055 * Returns the status of the downloaded tile file: 0056 * - Missing when it has not been downloaded 0057 * - Expired when it has been downloaded, but is too old (as per .dgml expiration time) 0058 * - Available when it has been downloaded and is not expired 0059 */ 0060 static TileStatus tileStatus( GeoSceneTileDataset const *tileData, const TileId &tileId ); 0061 0062 private Q_SLOTS: 0063 void updateTile( QByteArray const & imageData, QString const & tileId ); 0064 void updateTile( QString const & fileName, QString const & idStr ); 0065 0066 Q_SIGNALS: 0067 void downloadTile( QUrl const & sourceUrl, QString const & destinationFileName, 0068 QString const & id, DownloadUsage ); 0069 0070 void tileCompleted( TileId const & tileId, QImage const & tileImage ); 0071 0072 void tileCompleted( TileId const & tileId, GeoDataDocument * document ); 0073 0074 private: 0075 static QString tileFileName( GeoSceneTileDataset const * tileData, TileId const & ); 0076 void triggerDownload( GeoSceneTileDataset const *tileData, TileId const &, DownloadUsage const ); 0077 static QImage scaledLowerLevelTile( GeoSceneTextureTileDataset const * textureData, TileId const & ); 0078 GeoDataDocument* openVectorFile(const QString &filename) const; 0079 0080 // For vectorTile parsing 0081 PluginManager const * m_pluginManager; 0082 }; 0083 0084 } 0085 0086 #endif