1 /*
2     SPDX-FileCopyrightText: 2008 Torsten Rahn <rahn@kde.org>
3     SPDX-FileCopyrightText: 2008 Jens-Michael Hoffmann <jensmh@gmx.de>
4     SPDX-FileCopyrightText: 2012 Ander Pijoan <ander.pijoan@deusto.es>
5 
6     SPDX-License-Identifier: LGPL-2.1-or-later
7 */
8 
9 #ifndef MARBLE_GEOSCENETILEDATASET_H
10 #define MARBLE_GEOSCENETILEDATASET_H
11 
12 #include <QList>
13 #include <QVector>
14 #include <QSize>
15 
16 #include "GeoSceneAbstractDataset.h"
17 #include "GeoSceneAbstractTileProjection.h"
18 #include "MarbleGlobal.h"
19 
20 class QStringList;
21 class QUrl;
22 
23 /**
24  * @short Tiled dataset stored in a layer. TextureTile and VectorTile layes inherit from this class.
25  */
26 
27 /* In order to make Marble able to manage vector tiles,
28  * now there is GeoSceneTileDataset and then GeoSceneTextureTileDataset
29  * (for the tag <texture> in dgml) or GeoSceneVectorTileDataset
30  * (for <vectortile>) are created, which inherit from this class */
31 
32 namespace Marble
33 {
34 class DownloadPolicy;
35 class ServerLayout;
36 class TileId;
37 
38 class GEODATA_EXPORT GeoSceneTileDataset : public GeoSceneAbstractDataset
39 {
40  public:
41     enum StorageLayout { Marble, OpenStreetMap, TileMapService };
42 
43     explicit GeoSceneTileDataset( const QString& name );
44     ~GeoSceneTileDataset() override;
45     const char* nodeType() const override;
46 
47     QString sourceDir() const;
48     void setSourceDir( const QString& sourceDir );
49 
50     QString installMap() const;
51     void setInstallMap( const QString& installMap );
52 
53     StorageLayout storageLayout() const;
54     void setStorageLayout( const StorageLayout );
55 
56     void setServerLayout( const ServerLayout * );
57     const ServerLayout *serverLayout() const;
58 
59     int levelZeroColumns() const;
60     void setLevelZeroColumns( const int );
61 
62     int levelZeroRows() const;
63     void setLevelZeroRows( const int );
64 
65     bool hasMaximumTileLevel() const;
66     int maximumTileLevel() const;
67     void setMaximumTileLevel( const int );
68 
69     int minimumTileLevel() const;
70     void setMinimumTileLevel(int level);
71 
72     void setTileLevels(const QString &tileLevels);
73     QVector<int> tileLevels() const;
74 
75     QVector<QUrl> downloadUrls() const;
76 
77     const QSize tileSize() const;
78     void setTileSize( const QSize &tileSize );
79 
80     void setTileProjection(GeoSceneAbstractTileProjection::Type projectionType);
81 
82     const GeoSceneAbstractTileProjection * tileProjection() const;
83     GeoSceneAbstractTileProjection::Type tileProjectionType() const;
84 
85     QString blending() const;
86     void setBlending( const QString &name );
87 
88     /**
89      * Creates a download URL for the given tile id.
90      *
91      * It implements the round robin for the tile servers.
92      * On each invocation the next url is returned.
93      */
94     QUrl downloadUrl( const TileId & ) const;
95     void addDownloadUrl( const QUrl & );
96 
97     QString relativeTileFileName( const TileId & ) const;
98 
99     QString themeStr() const;
100 
101     QList<const DownloadPolicy *> downloadPolicies() const;
102     void addDownloadPolicy( const DownloadUsage usage, const int maximumConnections );
103 
104  private:
105     Q_DISABLE_COPY( GeoSceneTileDataset )
106     QStringList hostNames() const;
107 
108     QString m_sourceDir;
109     QString m_installMap;
110     StorageLayout m_storageLayoutMode;
111     const ServerLayout *m_serverLayout;
112     int m_levelZeroColumns;
113     int m_levelZeroRows;
114     int m_minimumTileLevel;
115     int m_maximumTileLevel;
116     QVector<int> m_tileLevels;
117     mutable QSize m_tileSize;
118     GeoSceneAbstractTileProjection *m_tileProjection;
119     QString m_blending;
120 
121     /// List of Urls which are used in a round robin fashion
122     QVector<QUrl> m_downloadUrls;
123 
124     /// Points to next Url for the round robin algorithm
125     mutable QVector<QUrl>::const_iterator m_nextUrl;
126     QList<const DownloadPolicy *> m_downloadPolicies;
127 };
128 
hasMaximumTileLevel()129 inline bool GeoSceneTileDataset::hasMaximumTileLevel() const
130 {
131     return m_maximumTileLevel != -1;
132 }
133 
blending()134 inline QString GeoSceneTileDataset::blending() const
135 {
136     return m_blending;
137 }
138 
setBlending(const QString & name)139 inline void GeoSceneTileDataset::setBlending( const QString &name )
140 {
141     m_blending = name;
142 }
143 
144 }
145 
146 #endif
147