Skip to content
Permalink
Browse files

decide in qgswmsrenderer if SRCWIDTH (for GetLegendGraphic) or WIDTH …

…(for GetMap) is used
  • Loading branch information
signedav committed Mar 27, 2019
1 parent 6722ad5 commit 61a89af4c115990ee997e757fe1ca327a5d791f4
@@ -716,21 +716,6 @@ namespace QgsWms
return mWmsParameters[ QgsWmsParameter::SRCWIDTH ].toInt();
}

int QgsWmsParameters::getHeightAsInt() const
{
if ( QStringList( { QStringLiteral( "GetLegendGraphic" ), QStringLiteral( "GetLegendGraphics" ) } ).contains( request() ) && srcHeightAsInt() > 0 )
return srcHeightAsInt();
return heightAsInt();
}

int QgsWmsParameters::getWidthAsInt() const
{

if ( QStringList( { QStringLiteral( "GetLegendGraphic" ), QStringLiteral( "GetLegendGraphics" ) } ).contains( request() ) && srcWidthAsInt() > 0 )
return srcWidthAsInt();
return widthAsInt();
}

QString QgsWmsParameters::dpi() const
{
return mWmsParameters[ QgsWmsParameter::DPI ].toString();
@@ -422,20 +422,6 @@ namespace QgsWms
*/
int srcHeightAsInt() const;

/**
* Returns SRCHEIGHT parameter if it's a GetLegendGraphics request and otherwise HEIGHT parameter
*
* \returns getHeightAsInt parameter
*/
int getHeightAsInt() const;

/**
* Returns SRCWIDTH parameter if it's a GetLegendGraphics request and otherwise WIDTH parameter
*
* \returns getWidthAsInt parameter
*/
int getWidthAsInt() const;

/**
* Returns VERSION parameter if defined or its default value.
* \returns version
@@ -187,7 +187,7 @@ namespace QgsWms
if ( !mWmsParameters.bbox().isEmpty() )
{
QgsMapSettings mapSettings;
image.reset( createImage( mWmsParameters.getWidthAsInt(), mWmsParameters.getHeightAsInt(), false ) );
image.reset( createImage( getWidthAsInt(), getHeightAsInt(), false ) );
configureMapSettings( image.get(), mapSettings );
legendSettings.setMapScale( mapSettings.scale() );
legendSettings.setMapUnitsPerPixel( mapSettings.mapUnitsPerPixel() );
@@ -1045,8 +1045,8 @@ namespace QgsWms
}

// create the mapSettings and the output image
int imageWidth = mWmsParameters.getWidthAsInt();
int imageHeight = mWmsParameters.getHeightAsInt();
int imageWidth = getWidthAsInt();
int imageHeight = getHeightAsInt();

// Provide default image width/height values if format is not image
if ( !( imageWidth && imageHeight ) && ! mWmsParameters.infoFormatIsImage() )
@@ -1123,10 +1123,10 @@ namespace QgsWms
QImage *QgsRenderer::createImage( int width, int height, bool useBbox ) const
{
if ( width < 0 )
width = mWmsParameters.getWidthAsInt();
width = getWidthAsInt();

if ( height < 0 )
height = mWmsParameters.getHeightAsInt();
height = getHeightAsInt();

//Adapt width / height if the aspect ratio does not correspond with the BBOX.
//Required by WMS spec. 1.3.
@@ -1315,8 +1315,8 @@ namespace QgsWms
i = mWmsParameters.xAsInt();
j = mWmsParameters.yAsInt();
}
int width = mWmsParameters.getWidthAsInt();
int height = mWmsParameters.getHeightAsInt();
int width = getWidthAsInt();
int height = getHeightAsInt();
if ( ( i != -1 && j != -1 && width != 0 && height != 0 ) && ( width != outputImage->width() || height != outputImage->height() ) )
{
i *= ( outputImage->width() / static_cast<double>( width ) );
@@ -1994,14 +1994,14 @@ namespace QgsWms
{
//test if maxWidth / maxHeight set and WIDTH / HEIGHT parameter is in the range
int wmsMaxWidth = QgsServerProjectUtils::wmsMaxWidth( *mProject );
int width = mWmsParameters.getWidthAsInt();
int width = getWidthAsInt();
if ( wmsMaxWidth != -1 && width > wmsMaxWidth )
{
return false;
}

int wmsMaxHeight = QgsServerProjectUtils::wmsMaxHeight( *mProject );
int height = mWmsParameters.getHeightAsInt();
int height = getHeightAsInt();
if ( wmsMaxHeight != -1 && height > wmsMaxHeight )
{
return false;
@@ -3206,8 +3206,8 @@ namespace QgsWms
// WIDTH / HEIGHT parameters. If not, the image has to be scaled (required
// by WMS spec)
QImage *scaledImage = nullptr;
int width = mWmsParameters.getWidthAsInt();
int height = mWmsParameters.getHeightAsInt();
int width = getWidthAsInt();
int height = getHeightAsInt();
if ( width != image->width() || height != image->height() )
{
scaledImage = new QImage( image->scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
@@ -3418,4 +3418,20 @@ namespace QgsWms
}
}

int QgsRenderer::getHeightAsInt() const
{
if ( mWmsParameters.request().compare( QStringLiteral( "GetLegendGraphic" ), Qt::CaseInsensitive ) == 0 ||
mWmsParameters.request().compare( QStringLiteral( "GetLegendGraphics" ), Qt::CaseInsensitive ) )
return mWmsParameters.srcHeightAsInt();
return mWmsParameters.heightAsInt();
}

int QgsRenderer::getWidthAsInt() const
{
if ( mWmsParameters.request().compare( QStringLiteral( "GetLegendGraphic" ), Qt::CaseInsensitive ) == 0 ||
mWmsParameters.request().compare( QStringLiteral( "GetLegendGraphics" ), Qt::CaseInsensitive ) )
return mWmsParameters.srcWidthAsInt();
return mWmsParameters.heightAsInt();
}

} // namespace QgsWms
@@ -297,6 +297,18 @@ namespace QgsWms

void handlePrintErrors( const QgsLayout *layout ) const;

/**
* Returns QgsWmsParameter SRCWIDTH if it's a GetLegendGraphics request and otherwise HEIGHT parameter
* \returns getHeightAsInt parameter
*/
int getHeightAsInt() const;

/**
* Returns QgsWmsParameter SRCWIDTH parameter if it's a GetLegendGraphics request and otherwise WIDTH parameter
* \returns getWidthAsInt parameter
*/
int getWidthAsInt() const;

const QgsWmsParameters &mWmsParameters;

#ifdef HAVE_SERVER_PYTHON_PLUGINS

0 comments on commit 61a89af

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