Skip to content
Permalink
Browse files

1st fix for broken GetFeatureInfo URLs in REST WMTS layers

  • Loading branch information
ianturton committed Sep 28, 2020
1 parent 8d2a0d1 commit 878d2290091e881d2386678c571d91db8e77abda
Showing with 24 additions and 0 deletions.
  1. +24 −0 src/providers/wms/qgswmsprovider.cpp
@@ -3018,8 +3018,31 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPointXY &point, QgsRa
if ( mTileLayer->getFeatureInfoURLs.contains( formatStr ) )
{
// REST


QString url = mTileLayer->getFeatureInfoURLs[ formatStr ];

if (mSettings.mIgnoreGetFeatureInfoUrl)
{
// rewrite the URL if the one in the capabilities document is incorrect
QString base = mSettings.mBaseUrl;
QgsDebugMsgLevel( QStringLiteral( "1 base=%1" ).arg( base ), 2 );
// strip every thing after the ? from the base url
base = base.split(QRegExp("\\?"))[0];
QgsDebugMsgLevel( QStringLiteral( "2 base=%1" ).arg( base ), 2 );
// and strip everything before the `rest` element (at least for GeoServer)
QgsDebugMsgLevel( QStringLiteral( "url=%1" ).arg( url ), 2 );
int index = url.length() - url.lastIndexOf("rest") + 1; // +1 for the /
QgsDebugMsgLevel( QStringLiteral( "url=%1" ).arg( url.right(index) ), 2 );


url = base + url.right(index);
QgsDebugMsgLevel( QStringLiteral( "new url=%1" ).arg( url ), 2 );

}

QgsDebugMsgLevel( QStringLiteral( "getfeatureinfo: %1" ).arg( url), 2 );

url.replace( QLatin1String( "{layer}" ), mSettings.mActiveSubLayers[0], Qt::CaseInsensitive );
url.replace( QLatin1String( "{style}" ), mSettings.mActiveSubStyles[0], Qt::CaseInsensitive );
url.replace( QLatin1String( "{tilematrixset}" ), mTileMatrixSet->identifier, Qt::CaseInsensitive );
@@ -3040,6 +3063,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPointXY &point, QgsRa
else if ( !getFeatureInfoUrl().isNull() )
{
// KVP
QgsDebugMsg( QStringLiteral( "KVP ignore GetFeatureURL %1" ).arg( mSettings.mIgnoreGetFeatureInfoUrl ) );
QUrl url( mSettings.mIgnoreGetFeatureInfoUrl ? mSettings.mBaseUrl : getFeatureInfoUrl() );
QUrlQuery query( url );

0 comments on commit 878d229

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