7#include "ServerLayout.h"
9#include "GeoSceneTileDataset.h"
10#include "GeoDataLatLonBox.h"
11#include "MarbleGlobal.h"
21ServerLayout::ServerLayout( GeoSceneTileDataset *textureLayer )
22 : m_textureLayer( textureLayer )
26ServerLayout::~ServerLayout()
30MarbleServerLayout::MarbleServerLayout( GeoSceneTileDataset *textureLayer )
31 : ServerLayout( textureLayer )
35QUrl MarbleServerLayout::downloadUrl(
const QUrl &prototypeUrl,
const TileId &
id )
const
39 .
arg(
id.zoomLevel() )
42 .
arg( m_textureLayer->fileFormat().toLower() );
44 QUrl url = prototypeUrl;
50QString MarbleServerLayout::name()
const
55QString ServerLayout::sourceDir()
const
57 return m_textureLayer ? m_textureLayer->sourceDir() :
QString();
61OsmServerLayout::OsmServerLayout( GeoSceneTileDataset *textureLayer )
62 : ServerLayout( textureLayer )
66QUrl OsmServerLayout::downloadUrl(
const QUrl &prototypeUrl,
const TileId &
id )
const
74 QUrl url = prototypeUrl;
80QString OsmServerLayout::name()
const
82 return "OpenStreetMap";
86CustomServerLayout::CustomServerLayout( GeoSceneTileDataset *texture )
87 : ServerLayout( texture )
91QUrl CustomServerLayout::downloadUrl(
const QUrl &prototypeUrl,
const TileId &
id )
const
93 const GeoDataLatLonBox bbox = m_textureLayer->tileProjection()->geoCoordinates(
id);
106 return QUrl( urlStr );
109QString CustomServerLayout::name()
const
115WmsServerLayout::WmsServerLayout( GeoSceneTileDataset *texture )
116 : ServerLayout( texture )
120QUrl WmsServerLayout::downloadUrl(
const QUrl &prototypeUrl,
const Marble::TileId &tileId )
const
122 const GeoDataLatLonBox box = m_textureLayer->tileProjection()->geoCoordinates(tileId);
125 url.addQueryItem(
"service",
"WMS" );
126 url.addQueryItem(
"request",
"GetMap" );
127 url.addQueryItem(
"version",
"1.1.1" );
128 if ( !url.hasQueryItem(
"styles" ) )
129 url.addQueryItem(
"styles",
"" );
130 if ( !url.hasQueryItem(
"format" ) ) {
131 url.addQueryItem(
"format",
QLatin1String(
"image/") + m_textureLayer->fileFormat().toLower());
133 if ( !url.hasQueryItem(
"srs" ) ) {
134 url.addQueryItem(
"srs", epsgCode() );
136 if ( !url.hasQueryItem(
"layers" ) )
137 url.addQueryItem(
"layers", m_textureLayer->name() );
138 url.addQueryItem(
"width",
QString::number( m_textureLayer->tileSize().width() ) );
139 url.addQueryItem(
"height",
QString::number( m_textureLayer->tileSize().height() ) );
140 double west, south, east, north;
141 if (m_textureLayer->tileProjectionType() == GeoSceneAbstractTileProjection::Mercator) {
143 west = (box.west( GeoDataCoordinates::Degree ) * 20037508.34) / 180;
144 south = 20037508.34 / M_PI * log(tan(((90 + box.south( GeoDataCoordinates::Degree )) * M_PI) / 360));
145 east = (box.east( GeoDataCoordinates::Degree ) * 20037508.34) / 180;
146 north = 20037508.34 / M_PI * log(tan(((90 + box.north( GeoDataCoordinates::Degree )) * M_PI) / 360));
149 west = box.west( GeoDataCoordinates::Degree );
150 south = box.south( GeoDataCoordinates::Degree );
151 east = box.east( GeoDataCoordinates::Degree );
152 north = box.north( GeoDataCoordinates::Degree );
159 QUrl finalUrl = prototypeUrl;
164QString WmsServerLayout::name()
const
166 return "WebMapService";
169QString WmsServerLayout::epsgCode()
const
171 switch (m_textureLayer->tileProjectionType()) {
172 case GeoSceneAbstractTileProjection::Equirectangular:
174 case GeoSceneAbstractTileProjection::Mercator:
182WmtsServerLayout::WmtsServerLayout( GeoSceneTileDataset *texture )
183 : ServerLayout( texture )
187QUrl WmtsServerLayout::downloadUrl(
const QUrl &prototypeUrl,
const Marble::TileId &
id )
const
196 return QUrl( urlStr );
199QString WmtsServerLayout::name()
const
201 return "WebMapTileService";
204QString WmtsServerLayout::epsgCode()
const
206 switch (m_textureLayer->tileProjectionType()) {
207 case GeoSceneAbstractTileProjection::Equirectangular:
209 case GeoSceneAbstractTileProjection::Mercator:
218QuadTreeServerLayout::QuadTreeServerLayout( GeoSceneTileDataset *textureLayer )
219 : ServerLayout( textureLayer )
223QUrl QuadTreeServerLayout::downloadUrl(
const QUrl &prototypeUrl,
const Marble::TileId &
id )
const
227 urlStr.
replace(
"{quadIndex}", encodeQuadTree(
id ) );
229 return QUrl( urlStr );
232QString QuadTreeServerLayout::name()
const
237QString QuadTreeServerLayout::encodeQuadTree(
const Marble::TileId &
id )
241 for (
int i =
id.zoomLevel(); i >= 0; i-- ) {
242 const int tileX = (
id.x() >> i) % 2;
243 const int tileY = (
id.y() >> i) % 2;
244 const int num = ( 2 * tileY ) + tileX;
252TmsServerLayout::TmsServerLayout(GeoSceneTileDataset *textureLayer )
253 : ServerLayout( textureLayer )
257QUrl TmsServerLayout::downloadUrl(
const QUrl &prototypeUrl,
const TileId &
id )
const
264 int y_frombottom = ( 1<<
id.zoomLevel() ) -
id.y() - 1 ;
270 QUrl url = prototypeUrl;
276QString TmsServerLayout::name()
const
278 return "TileMapService";
QString path(const QString &relativePath)
Binds a QML item to a specific geodetic location in screen coordinates.
QString arg(Args &&... args) const const
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
QString number(double n, char format, int precision)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QString toLower() const const
QString path(ComponentFormattingOptions options) const const
QString query(ComponentFormattingOptions options) const const
void setPath(const QString &path, ParsingMode mode)
void setQuery(const QString &query, ParsingMode mode)
QString toString(FormattingOptions options) const const