Skip to content
Permalink
Browse files

Merge pull request #39070 from ianturton/issue-39002

1st fix for broken GetFeatureInfo URLs in REST WMTS layers
  • Loading branch information
elpaso committed Oct 10, 2020
2 parents 8eb52c8 + 1bce971 commit 0824effd7851c42e6a755c94ab339206a2de8198
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/providers/wms/qgswmsprovider.cpp
@@ -3018,8 +3018,23 @@ 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
// strip every thing after the ? from the base url
const QStringList parts = mSettings.mBaseUrl.split( QRegularExpression( "\\?" ) );
const QString base = parts.isEmpty() ? mSettings.mBaseUrl : parts.first();
// and strip everything before the `rest` element (at least for GeoServer)
const int index = url.length() - url.lastIndexOf( QStringLiteral( "rest" ) ) + 1; // +1 for the /
url = base + url.right( index );
}

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 );

0 comments on commit 0824eff

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