Skip to content
Permalink
Browse files

[wms] Fix broken WMS layers from servers using relative OnlineResourc…

…e paths
  • Loading branch information
nirvn authored and nyalldawson committed Jun 28, 2020
1 parent d8b79f3 commit 7d78628bf0e3d90f0eee432f2fa7f2d3ce0c33f6
@@ -161,8 +161,9 @@ bool QgsWmsSettings::parseUri( const QString &uriString )
// ----------------------


QgsWmsCapabilities::QgsWmsCapabilities( const QgsCoordinateTransformContext &coordinateTransformContext ):
mCoordinateTransformContext( coordinateTransformContext )
QgsWmsCapabilities::QgsWmsCapabilities( const QgsCoordinateTransformContext &coordinateTransformContext, const QString &baseUrl ):
mCoordinateTransformContext( coordinateTransformContext ),
mBaseUrl( baseUrl )
{

}
@@ -406,10 +407,13 @@ void QgsWmsCapabilities::parseService( QDomElement const &e, QgsWmsServiceProper

void QgsWmsCapabilities::parseOnlineResource( QDomElement const &e, QgsWmsOnlineResourceAttribute &onlineResourceAttribute )
{

onlineResourceAttribute.xlinkHref = QUrl::fromEncoded( e.attribute( QStringLiteral( "xlink:href" ) ).toUtf8() ).toString();

QgsDebugMsg( QStringLiteral( "exiting." ) );
QUrl url = QUrl::fromEncoded( e.attribute( QStringLiteral( "xlink:href" ) ).toUtf8() );
if ( url.isRelative() )
{
const QUrl baseUrl = QUrl( mBaseUrl );
url = baseUrl.resolved( url );
}
onlineResourceAttribute.xlinkHref = url.toString();
}


@@ -633,7 +633,7 @@ class QgsWmsCapabilities
/**
* Constructs a QgsWmsCapabilities object with the given \a coordinateTransformContext
*/
QgsWmsCapabilities( const QgsCoordinateTransformContext &coordinateTransformContext = QgsCoordinateTransformContext() );
QgsWmsCapabilities( const QgsCoordinateTransformContext &coordinateTransformContext = QgsCoordinateTransformContext(), const QString &baseUrl = QString() );

bool isValid() const { return mValid; }

@@ -769,6 +769,7 @@ class QgsWmsCapabilities
private:

QgsCoordinateTransformContext mCoordinateTransformContext;
QString mBaseUrl;

friend class QgsWmsProvider;
};
@@ -1198,7 +1198,7 @@ bool QgsWmsProvider::retrieveServerCapabilities( bool forceRefresh )
return false;
}

QgsWmsCapabilities caps( transformContext() );
QgsWmsCapabilities caps( transformContext(), mSettings.baseUrl() );
if ( !caps.parseResponse( downloadCaps.response(), mSettings.parserSettings() ) )
{
mErrorFormat = caps.lastErrorFormat();

0 comments on commit 7d78628

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