Skip to content
Permalink
Browse files

wms client: handle + encoding (image/svg+xml) in format parameter als…

…o for

other requests (followup b118213, refs #10060)
  • Loading branch information
jef-n committed Apr 17, 2014
1 parent 2a2e05a commit ad1eaf7ae00c6e74a93d637bcb132ff12d880937
Showing with 21 additions and 11 deletions.
  1. +18 −11 src/providers/wms/qgswmsprovider.cpp
  2. +3 −0 src/providers/wms/qgswmsprovider.h
@@ -426,6 +426,19 @@ void QgsWmsProvider::setQueryItem( QUrl &url, QString item, QString value )
url.addQueryItem( item, value );
}

void QgsWmsProvider::setFormatQueryItem( QUrl &url )
{
url.removeQueryItem( "FORMAT" );
if ( mSettings.mImageMimeType.contains( "+" ) )
{
QString format( mSettings.mImageMimeType );
format.replace( "+", "%2b" );
url.addEncodedQueryItem( "FORMAT", format.toUtf8() );
}
else
setQueryItem( url, "FORMAT", mSettings.mImageMimeType );
}

QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, int pixelHeight )
{
QgsDebugMsg( "Entering." );
@@ -509,14 +522,7 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
setQueryItem( url, "HEIGHT", QString::number( pixelHeight ) );
setQueryItem( url, "LAYERS", layers );
setQueryItem( url, "STYLES", styles );
if( mSettings.mImageMimeType.contains( "+" ) )
{
QString format( mSettings.mImageMimeType );
format.replace( "+", "%2b" );
url.addEncodedQueryItem( "FORMAT", format.toUtf8() );
}
else
setQueryItem( url, "FORMAT", mSettings.mImageMimeType );
setFormatQueryItem( url );

if ( mDpi != -1 )
{
@@ -680,7 +686,8 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
setQueryItem( url, "HEIGHT", QString::number( tm->tileHeight ) );
setQueryItem( url, "LAYERS", mSettings.mActiveSubLayers.join( "," ) );
setQueryItem( url, "STYLES", mSettings.mActiveSubStyles.join( "," ) );
setQueryItem( url, "FORMAT", mSettings.mImageMimeType );
setFormatQueryItem( url );

setQueryItem( url, crsKey, mImageCrs );

if ( mSettings.mTiled )
@@ -2199,7 +2206,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint & thePoint, Qgs
setQueryItem( requestUrl, "HEIGHT", QString::number( theHeight ) );
setQueryItem( requestUrl, "LAYERS", *layers );
setQueryItem( requestUrl, "STYLES", *styles );
setQueryItem( requestUrl, "FORMAT", mSettings.mImageMimeType );
setFormatQueryItem( requestUrl );
setQueryItem( requestUrl, "QUERY_LAYERS", *layers );
setQueryItem( requestUrl, "INFO_FORMAT", format );

@@ -2969,7 +2976,7 @@ QImage QgsWmsProvider::getLegendGraphic( double scale, bool forceRefresh )
if ( !url.hasQueryItem( "REQUEST" ) )
setQueryItem( url, "REQUEST", "GetLegendGraphic" );
if ( !url.hasQueryItem( "FORMAT" ) )
setQueryItem( url, "FORMAT", mSettings.mImageMimeType );
setFormatQueryItem( url );
if ( !url.hasQueryItem( "LAYER" ) )
setQueryItem( url, "LAYER", mSettings.mActiveSubLayers[0] );
if ( !url.hasQueryItem( "STYLE" ) )
@@ -364,6 +364,9 @@ class QgsWmsProvider : public QgsRasterDataProvider
//! remove query item and replace it with a new value
void setQueryItem( QUrl &url, QString key, QString value );

//! add image FORMAT parameter to url
void setFormatQueryItem( QUrl &url );

//! Name of the stored connection
QString mConnectionName;

0 comments on commit ad1eaf7

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