Warning, file /education/marble/tools/vectorosm-tilecreator/TileDirectory.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2016 Dennis Nienhüser <nienhueser@kde.org> 0004 // 0005 0006 #ifndef MARBLE_TILEDIRECTORY_H 0007 #define MARBLE_TILEDIRECTORY_H 0008 0009 #include "VectorClipper.h" 0010 #include "TagsFilter.h" 0011 #include <TileId.h> 0012 #include <GeoDataLinearRing.h> 0013 #include <ParsingRunnerManager.h> 0014 #include <GeoSceneMercatorTileProjection.h> 0015 0016 #include <QNetworkAccessManager> 0017 #include <QSharedPointer> 0018 #include <QObject> 0019 #include <QFile> 0020 0021 class QNetworkReply; 0022 0023 namespace Marble { 0024 0025 class Download : public QObject 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 QString target; 0031 QNetworkReply* reply; 0032 qint64 received; 0033 qint64 total; 0034 0035 public Q_SLOTS: 0036 void updateProgress(qint64 received, qint64 total); 0037 0038 private: 0039 QFile m_file; 0040 }; 0041 0042 class TileDirectory : public QObject 0043 { 0044 Q_OBJECT 0045 0046 public: 0047 0048 enum TileType 0049 { 0050 Landmass, 0051 OpenStreetMap 0052 }; 0053 0054 TileDirectory(TileType tileType, const QString &cacheDir, ParsingRunnerManager &manager, int maxZoomLevel); 0055 /** Create a tile directory for loading data from an OSMX file. 0056 * @param maxZoomLevel The output zoom level. 0057 * @param loadZoomLevel The zoom level at which the input data should be loaded. 0058 * This must be smaller or equal to maxZoomLevel. Using a smaller value can be more efficient when 0059 * generating a larger batch of tiles that fall within a lower zoom level tile, but comes at a greater 0060 * cost for memory and clipping operations. 0061 */ 0062 TileDirectory(const QString &cacheDir, const QString &osmxFile, ParsingRunnerManager &manager, int maxZoomLevel, int loadZoomLevel); 0063 0064 QSharedPointer<GeoDataDocument> load(int zoomLevel, int tileX, int tileY); 0065 void setInputFile(const QString &filename); 0066 0067 TileId tileFor(int zoomLevel, int tileX, int tileY) const; 0068 GeoDataDocument *clip(int zoomLevel, int tileX, int tileY); 0069 QString name() const; 0070 0071 static QSharedPointer<GeoDataDocument> open(const QString &filename, ParsingRunnerManager &manager); 0072 GeoDataLatLonBox boundingBox(const QString &filename) const; 0073 GeoDataLatLonBox boundingBox() const; 0074 void setBoundingBox(const GeoDataLatLonBox &boundingBox); 0075 void setBoundingPolygon(const QString &filename); 0076 void createTiles() const; 0077 void createOsmTiles() const; 0078 int innerNodes(const TileId &tile) const; 0079 0080 static void printProgress(double progress, int barWidth=40); 0081 0082 private Q_SLOTS: 0083 void updateProgress(); 0084 void handleFinishedDownload(const QString &filename, const QString &id); 0085 0086 private: 0087 TagsFilter::Tags tagsFilteredIn(int zoomLevel) const; 0088 void setTagZoomLevel(int zoomLevel); 0089 void download(const QString &url, const QString &target); 0090 QString osmFileFor(const TileId &tileId) const; 0091 0092 QString m_cacheDir; 0093 QString m_baseDir; 0094 QString m_osmxFile; 0095 ParsingRunnerManager &m_manager; 0096 QSharedPointer<GeoDataDocument> m_landmass; 0097 int m_zoomLevel = -1; 0098 int m_tileX = -1; 0099 int m_tileY = -1; 0100 int m_tagZoomLevel = -1; 0101 QSharedPointer<VectorClipper> m_clipper; 0102 QSharedPointer<TagsFilter> m_tagsFilter; 0103 TileType m_tileType; 0104 QString m_inputFile; 0105 GeoDataLatLonBox m_boundingBox; 0106 QVector<GeoDataLinearRing> m_boundingPolygon; 0107 QNetworkAccessManager m_downloadManager; 0108 GeoSceneMercatorTileProjection m_tileProjection; 0109 QString m_landmassFile; 0110 QSharedPointer<Download> m_download; 0111 int m_maxZoomLevel; 0112 static QMap<int, TagsFilter::Tags> m_tags; 0113 }; 0114 0115 } 0116 0117 #endif