Skip to content
Permalink
Browse files

[WMS provider] Detection of SERVICE=WMTS in url must be case insensitive

As mandated by OGC specs.

Fixes #36659
  • Loading branch information
rouault committed May 27, 2020
1 parent 2a70569 commit 97bac498418c6724e574f16365c3b220a3114502
@@ -2344,8 +2344,7 @@ bool QgsWmsCapabilitiesDownload::downloadCapabilities()
mIsAborted = false;

QString url = mBaseUrl;
if ( !url.contains( QLatin1String( "SERVICE=WMTS" ), Qt::CaseInsensitive ) &&
!url.contains( QLatin1String( "/WMTSCapabilities.xml" ), Qt::CaseInsensitive ) )
if ( !QgsWmsProvider::isUrlForWMTS( url ) )
{
url += QLatin1String( "SERVICE=WMS&REQUEST=GetCapabilities" );
}
@@ -197,7 +197,7 @@ QString QgsWmsProvider::prepareUri( QString uri )
// some services provide a percent/url encoded (legend) uri string, always decode here
uri = QUrl::fromPercentEncoding( uri.toUtf8() );

if ( uri.contains( QLatin1String( "SERVICE=WMTS" ) ) || uri.contains( QLatin1String( "/WMTSCapabilities.xml" ) ) )
if ( isUrlForWMTS( uri ) )
{
return uri;
}
@@ -3652,7 +3652,7 @@ QUrl QgsWmsProvider::getLegendGraphicFullURL( double scale, const QgsRectangle &
QUrl url( lurl );
QUrlQuery query( url );

if ( dataSourceUri().contains( "SERVICE=WMTS" ) || dataSourceUri().contains( "/WMTSCapabilities.xml" ) )
if ( isUrlForWMTS( dataSourceUri() ) )
{
QgsDebugMsg( QString( "getlegendgraphicrequest: %1" ).arg( url.toString() ) );
return url;
@@ -3865,6 +3865,14 @@ void QgsWmsProvider::getLegendGraphicReplyProgress( qint64 bytesReceived, qint64
emit statusChanged( msg );
}

bool QgsWmsProvider::isUrlForWMTS( const QString &url )
{
// Do comparison in case insensitive way to match OGC KVP requirements
return url.contains( QLatin1String( "SERVICE=WMTS" ), Qt::CaseInsensitive ) ||
url.contains( QLatin1String( "/WMTSCapabilities.xml" ), Qt::CaseInsensitive );
}


QgsWmsProvider *QgsWmsProviderMetadata::createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options )
{
return new QgsWmsProvider( uri, options );
@@ -261,6 +261,8 @@ class QgsWmsProvider final: public QgsRasterDataProvider
} TilePosition;
typedef QList<TilePosition> TilePositions;

static bool isUrlForWMTS( const QString &url );

private slots:
void identifyReplyFinished();
void getLegendGraphicReplyFinished( const QImage & );

0 comments on commit 97bac49

Please sign in to comment.
You can’t perform that action at this time.