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

(cherry picked from commit 97bac49)
  • Loading branch information
rouault authored and nyalldawson committed Jun 19, 2020
1 parent b466309 commit eef74d4451d7d2c8dacdc2abeb0ae79b55db0f7a
@@ -1983,8 +1983,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" );
}
@@ -171,7 +171,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;
}
@@ -3359,6 +3359,13 @@ QUrl QgsWmsProvider::getLegendGraphicFullURL( double scale, const QgsRectangle &
QgsDebugMsg( QStringLiteral( "visibleExtent is %1" ).arg( visibleExtent.toString() ) );

QUrl url( lurl );
QUrlQuery query( url );

if ( isUrlForWMTS( dataSourceUri() ) )
{
QgsDebugMsg( QString( "getlegendgraphicrequest: %1" ).arg( url.toString() ) );
return url;
}

// query names are NOT case-sensitive, so make an uppercase list for proper comparison
QStringList qnames = QStringList();
@@ -3566,6 +3573,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 );
@@ -262,6 +262,8 @@ class QgsWmsProvider : 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 eef74d4

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