File indexing completed on 2025-01-05 03:59:11

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