File indexing completed on 2024-05-19 03:51:51

0001 /*
0002     SPDX-FileCopyrightText: 2008 Torsten Rahn <rahn@kde.org>
0003     SPDX-FileCopyrightText: 2008 Jens-Michael Hoffmann <jensmh@gmx.de>
0004     SPDX-FileCopyrightText: 2012 Ander Pijoan <ander.pijoan@deusto.es>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-or-later
0007 */
0008 
0009 #ifndef MARBLE_GEOSCENETILEDATASET_H
0010 #define MARBLE_GEOSCENETILEDATASET_H
0011 
0012 #include <QList>
0013 #include <QVector>
0014 #include <QSize>
0015 
0016 #include "GeoSceneAbstractDataset.h"
0017 #include "GeoSceneAbstractTileProjection.h"
0018 #include "MarbleGlobal.h"
0019 #include "GeoDataLatLonBox.h"
0020 
0021 class QStringList;
0022 class QUrl;
0023 
0024 /**
0025  * @short Tiled dataset stored in a layer. TextureTile and VectorTile layes inherit from this class.
0026  */
0027 
0028 /* In order to make Marble able to manage vector tiles,
0029  * now there is GeoSceneTileDataset and then GeoSceneTextureTileDataset
0030  * (for the tag <texture> in dgml) or GeoSceneVectorTileDataset
0031  * (for <vectortile>) are created, which inherit from this class */
0032 
0033 namespace Marble
0034 {
0035 class DownloadPolicy;
0036 class ServerLayout;
0037 class TileId;
0038 
0039 class GEODATA_EXPORT GeoSceneTileDataset : public GeoSceneAbstractDataset
0040 {
0041  public:
0042     enum StorageLayout { Marble, OpenStreetMap, TileMapService };
0043 
0044     explicit GeoSceneTileDataset( const QString& name );
0045     ~GeoSceneTileDataset() override;
0046     const char* nodeType() const override;
0047 
0048     QString sourceDir() const;
0049     void setSourceDir( const QString& sourceDir );
0050 
0051     QString installMap() const;
0052     void setInstallMap( const QString& installMap );
0053 
0054     StorageLayout storageLayout() const;
0055     void setStorageLayout( const StorageLayout );
0056 
0057     void setServerLayout( const ServerLayout * );
0058     const ServerLayout *serverLayout() const;
0059 
0060     int levelZeroColumns() const;
0061     void setLevelZeroColumns( const int );
0062 
0063     int levelZeroRows() const;
0064     void setLevelZeroRows( const int );
0065 
0066     bool hasMaximumTileLevel() const;
0067     int maximumTileLevel() const;
0068     void setMaximumTileLevel( const int );
0069 
0070     int minimumTileLevel() const;
0071     void setMinimumTileLevel(int level);
0072     
0073     void setTileLevels(const QString &tileLevels);
0074     QVector<int> tileLevels() const;
0075 
0076     QVector<QUrl> downloadUrls() const;
0077 
0078     const QSize tileSize() const;
0079     void setTileSize( const QSize &tileSize );
0080 
0081     /**
0082      * @brief set bounds for the texture. Tiles outside of these bounds won't be searched in this texture.
0083      * Null box means no bounds.
0084      */
0085     void setLatLonBox( const GeoDataLatLonBox &box );
0086     GeoDataLatLonBox latLonBox() const;
0087 
0088     void setTileProjection(GeoSceneAbstractTileProjection::Type projectionType);
0089 
0090     const GeoSceneAbstractTileProjection * tileProjection() const;
0091     GeoSceneAbstractTileProjection::Type tileProjectionType() const;
0092 
0093     QString blending() const;
0094     void setBlending( const QString &name );
0095 
0096     /**
0097      * Creates a download URL for the given tile id.
0098      *
0099      * It implements the round robin for the tile servers.
0100      * On each invocation the next url is returned.
0101      */
0102     QUrl downloadUrl( const TileId & ) const;
0103     void addDownloadUrl( const QUrl & );
0104 
0105     QString relativeTileFileName( const TileId & ) const;
0106 
0107     QString themeStr() const;
0108 
0109     QList<const DownloadPolicy *> downloadPolicies() const;
0110     void addDownloadPolicy( const DownloadUsage usage, const int maximumConnections );
0111 
0112  private:
0113     Q_DISABLE_COPY( GeoSceneTileDataset )
0114     QStringList hostNames() const;
0115 
0116     QString m_sourceDir;
0117     QString m_installMap;
0118     StorageLayout m_storageLayoutMode;
0119     const ServerLayout *m_serverLayout;
0120     int m_levelZeroColumns;
0121     int m_levelZeroRows;
0122     int m_minimumTileLevel;
0123     int m_maximumTileLevel;
0124     QVector<int> m_tileLevels;
0125     mutable QSize m_tileSize;
0126     GeoDataLatLonBox m_latLonBox;
0127     GeoSceneAbstractTileProjection *m_tileProjection;
0128     QString m_blending;
0129 
0130     /// List of Urls which are used in a round robin fashion
0131     QVector<QUrl> m_downloadUrls;
0132 
0133     /// Points to next Url for the round robin algorithm
0134     mutable QVector<QUrl>::const_iterator m_nextUrl;
0135     QList<const DownloadPolicy *> m_downloadPolicies;
0136 };
0137 
0138 inline bool GeoSceneTileDataset::hasMaximumTileLevel() const
0139 {
0140     return m_maximumTileLevel != -1;
0141 }
0142 
0143 inline QString GeoSceneTileDataset::blending() const
0144 {
0145     return m_blending;
0146 }
0147 
0148 inline void GeoSceneTileDataset::setBlending( const QString &name )
0149 {
0150     m_blending = name;
0151 }
0152 
0153 }
0154 
0155 #endif