File indexing completed on 2025-01-05 03:59:03
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2010, 2011 Bernhard Beschow <bbeschow@cs.tu-berlin.de> 0004 // 0005 0006 #ifndef MARBLE_SERVERLAYOUT_H 0007 #define MARBLE_SERVERLAYOUT_H 0008 0009 class QUrl; 0010 class QString; 0011 0012 namespace Marble 0013 { 0014 class GeoSceneTileDataset; 0015 class TileId; 0016 0017 class ServerLayout 0018 { 0019 public: 0020 explicit ServerLayout( GeoSceneTileDataset *textureLayer ); 0021 virtual ~ServerLayout(); 0022 0023 /** 0024 * Translates given tile @p id using a @p prototypeUrl into an URL 0025 * that can be used for downloading. 0026 * 0027 * @param prototypeUrl prototype URL, to be completed by this method 0028 * @param id Marble-specific ID of requested tile 0029 * @return completed URL for requested tile id 0030 */ 0031 virtual QUrl downloadUrl( const QUrl &prototypeUrl, const TileId &id ) const = 0; 0032 0033 /** 0034 * Returns the name of the server layout to be used as the value in the 0035 * mode attribute in the DGML file. 0036 */ 0037 virtual QString name() const = 0; 0038 0039 /** 0040 * Returns the sourceDir of the texture layer, or an empty string if the texture layer is 0 0041 */ 0042 QString sourceDir() const; 0043 0044 protected: 0045 GeoSceneTileDataset *const m_textureLayer; 0046 }; 0047 0048 class MarbleServerLayout : public ServerLayout 0049 { 0050 public: 0051 explicit MarbleServerLayout( GeoSceneTileDataset *textureLayer ); 0052 0053 /** 0054 * Completes the path of the @p prototypeUrl and returns it. 0055 */ 0056 QUrl downloadUrl( const QUrl &prototypeUrl, const TileId & ) const override; 0057 0058 QString name() const override; 0059 }; 0060 0061 class OsmServerLayout : public ServerLayout 0062 { 0063 public: 0064 explicit OsmServerLayout( GeoSceneTileDataset *textureLayer ); 0065 0066 /** 0067 * Appends %zoomLevel/%x/%y.%suffix to the path of the @p prototypeUrl and returns 0068 * the result. 0069 */ 0070 QUrl downloadUrl( const QUrl &prototypeUrl, const TileId & ) const override; 0071 0072 QString name() const override; 0073 }; 0074 0075 class CustomServerLayout : public ServerLayout 0076 { 0077 public: 0078 explicit CustomServerLayout( GeoSceneTileDataset *texture ); 0079 0080 /** 0081 * Replaces escape sequences in the @p prototypeUrl by the values in @p id 0082 * and returns the result. 0083 * 0084 * Escape sequences are: {zoomLevel}, {x}, and {y}. 0085 */ 0086 QUrl downloadUrl( const QUrl &prototypeUrl, const TileId &id ) const override; 0087 0088 QString name() const override; 0089 }; 0090 0091 class WmsServerLayout : public ServerLayout 0092 { 0093 public: 0094 explicit WmsServerLayout( GeoSceneTileDataset *texture ); 0095 0096 /** 0097 * Adds WMS query items to the @p prototypeUrl and returns the result. 0098 * 0099 * The following items are added: service, request, version, width, height, bbox. 0100 * 0101 * The following items are only added if they are not already specified in the dgml file: 0102 * styles, format, srs, layers. 0103 */ 0104 QUrl downloadUrl( const QUrl &prototypeUrl, const Marble::TileId &tileId ) const override; 0105 0106 QString name() const override; 0107 0108 QString epsgCode() const; 0109 }; 0110 0111 class WmtsServerLayout : public ServerLayout 0112 { 0113 public: 0114 explicit WmtsServerLayout( GeoSceneTileDataset *texture ); 0115 0116 /** 0117 * Adds WMTS query items to the @p prototypeUrl and returns the result. 0118 */ 0119 QUrl downloadUrl( const QUrl &prototypeUrl, const Marble::TileId &tileId ) const override; 0120 0121 QString name() const override; 0122 0123 QString epsgCode() const; 0124 }; 0125 0126 class QuadTreeServerLayout : public ServerLayout 0127 { 0128 public: 0129 explicit QuadTreeServerLayout( GeoSceneTileDataset* textureLayer ); 0130 QUrl downloadUrl( const QUrl &, const Marble::TileId & ) const override; 0131 0132 QString name() const override; 0133 0134 private: 0135 static QString encodeQuadTree( const Marble::TileId & ); 0136 }; 0137 0138 class TmsServerLayout : public ServerLayout 0139 { 0140 public: 0141 explicit TmsServerLayout( GeoSceneTileDataset *textureLayer ); 0142 0143 /** 0144 * Appends %zoomLevel/%x/2^%zoomLevel-%y-1.%suffix to the path of the @p prototypeUrl and returns 0145 * the result. 0146 * TMS (TileMapService) maps take the origin for y coordinate at the bottom of the map, 0147 * as opposed to what Marble and OpenStreepMap (SlippyTiles) do. 0148 */ 0149 QUrl downloadUrl( const QUrl &prototypeUrl, const TileId & ) const override; 0150 0151 QString name() const override; 0152 }; 0153 0154 } 0155 0156 #endif