From 7855c6972914d39f91db366faa373abea0561078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 16 Sep 2018 12:05:11 +0200 Subject: [PATCH] Fixed WMS/WMTS URLs composing --- src/map/wms.cpp | 4 ++-- src/map/wmsmap.cpp | 10 +++++----- src/map/wmts.cpp | 11 ++++++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/map/wms.cpp b/src/map/wms.cpp index 9baca427..b52cc71e 100644 --- a/src/map/wms.cpp +++ b/src/map/wms.cpp @@ -274,8 +274,8 @@ bool WMS::getCapabilities(const QString &url, const QString &file, WMS::WMS(const QString &file, const WMS::Setup &setup) : _valid(false) { - QString capaUrl = QString("%1?service=WMS&request=GetCapabilities") - .arg(setup.url()); + QString capaUrl = QString("%1%2service=WMS&request=GetCapabilities") + .arg(setup.url(), setup.url().contains('?') ? "&" : "?"); if (!QFileInfo(file).exists()) if (!getCapabilities(capaUrl, file, setup.authorization())) diff --git a/src/map/wmsmap.cpp b/src/map/wmsmap.cpp index 4a3dcd4d..3eef9bfd 100644 --- a/src/map/wmsmap.cpp +++ b/src/map/wmsmap.cpp @@ -20,11 +20,11 @@ QString WMSMap::tileUrl(const QString &version) const { QString url; - url = QString("%1?version=%2&request=GetMap&bbox=$bbox" - "&width=%3&height=%4&layers=%5&styles=%6&format=%7&transparent=true") - .arg(_setup.url(), version, QString::number(TILE_SIZE), - QString::number(TILE_SIZE), _setup.layer(), _setup.style(), - _setup.format()); + url = QString("%1%2version=%3&request=GetMap&bbox=$bbox" + "&width=%4&height=%5&layers=%6&styles=%7&format=%8&transparent=true") + .arg(_setup.url(), _setup.url().contains('?') ? "&" : "?", version, + QString::number(TILE_SIZE), QString::number(TILE_SIZE), _setup.layer(), + _setup.style(), _setup.format()); if (version >= "1.3.0") url.append(QString("&CRS=%1").arg(_setup.crs())); diff --git a/src/map/wmts.cpp b/src/map/wmts.cpp index 076e0942..4056de65 100644 --- a/src/map/wmts.cpp +++ b/src/map/wmts.cpp @@ -301,8 +301,8 @@ bool WMTS::getCapabilities(const QString &url, const QString &file, WMTS::WMTS(const QString &file, const WMTS::Setup &setup) : _valid(false) { QString capaUrl = setup.rest() ? setup.url() : - QString("%1?service=WMTS&Version=1.0.0&request=GetCapabilities") - .arg(setup.url()); + QString("%1%2service=WMTS&Version=1.0.0&request=GetCapabilities") + .arg(setup.url(), setup.url().contains('?') ? "&" : "?"); if (!QFileInfo(file).exists()) if (!getCapabilities(capaUrl, file, setup.authorization())) @@ -312,9 +312,10 @@ WMTS::WMTS(const QString &file, const WMTS::Setup &setup) : _valid(false) QString style = setup.style().isEmpty() ? "default" : setup.style(); if (!setup.rest()) { - _tileUrl = QString("%1?service=WMTS&Version=1.0.0&request=GetTile" - "&Format=%2&Layer=%3&Style=%4&TileMatrixSet=%5&TileMatrix=$z" - "&TileRow=$y&TileCol=$x").arg(setup.url(), setup.format(), + _tileUrl = QString("%1%2service=WMTS&Version=1.0.0&request=GetTile" + "&Format=%3&Layer=%4&Style=%5&TileMatrixSet=%6&TileMatrix=$z" + "&TileRow=$y&TileCol=$x").arg(setup.url(), + setup.url().contains('?') ? "&" : "?" , setup.format(), setup.layer(), style, setup.set()); for (int i = 0; i < setup.dimensions().size(); i++) { const QPair &dim = setup.dimensions().at(i);