Skip to content
Permalink
Browse files

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

…e paths
  • Loading branch information
nirvn committed Jun 19, 2020
1 parent 21c6573 commit 714b2ef9f2b28e4fcf2cd7fd624b65332d1bd46c
@@ -452,8 +452,9 @@ QDateTime QgsWmsSettings::parseWmstDateTimes( QString item )
// ----------------------


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

}
@@ -691,8 +692,13 @@ void QgsWmsCapabilities::parseService( const QDomElement &element, QgsWmsService

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

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


@@ -933,7 +933,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; }

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

QgsCoordinateTransformContext mCoordinateTransformContext;
QString mBaseUrl;

friend class QgsWmsProvider;
friend class TestQgsWmsCapabilities;
@@ -1373,7 +1373,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 714b2ef

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