Skip to content

Commit

Permalink
Image proportion when filter geom is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed May 22, 2019
1 parent 0c77b9e commit 4e0a90a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/server/services/wms/qgswmsgetfeatureinfo.cpp
Expand Up @@ -32,12 +32,22 @@ namespace QgsWms
QgsWmsParameters parameters( QUrlQuery( request.url() ) );

// WIDTH and HEIGHT are not mandatory, but we need to set a default size
if ( parameters.widthAsInt() <= 0
&& parameters.heightAsInt() <= 0
if ( ( parameters.widthAsInt() <= 0
|| parameters.heightAsInt() <= 0 )
&& ! parameters.infoFormatIsImage() )
{
parameters.set( QgsWmsParameter::WIDTH, 10 );
parameters.set( QgsWmsParameter::HEIGHT, 10 );
QSize size( 10, 10 );

if ( ! parameters.filterGeom().isEmpty() )
{
const QgsRectangle bbox = QgsGeometry::fromWkt( parameters.filterGeom() ).boundingBox();
const int defaultWidth = 800;
size.setWidth( defaultWidth );
size.setHeight( defaultWidth * bbox.height() / bbox.width() );
}

parameters.set( QgsWmsParameter::WIDTH, size.width() );
parameters.set( QgsWmsParameter::HEIGHT, size.height() );
}

// prepare render context
Expand Down

0 comments on commit 4e0a90a

Please sign in to comment.