Skip to content
Permalink
Browse files

Port bugfix from PR #3906 to service

  • Loading branch information
dmarteau committed Jan 10, 2017
1 parent 3f41db3 commit c793e662ca8ae4e1f1a57c64d600e641cbed3904
Showing with 17 additions and 11 deletions.
  1. +17 −11 src/server/services/wms/qgswmsservertransitional.cpp
@@ -1592,26 +1592,32 @@ namespace QgsWms

//Adapt width / height if the aspect ratio does not correspond with the BBOX.
//Required by WMS spec. 1.3.
if ( useBbox )
QString version = mParameters.value( QStringLiteral( "VERSION" ), QStringLiteral( "1.3.0" ) );
if ( useBbox && version != QLatin1String( "1.1.1" ) )
{
bool bboxOk;
QgsRectangle mapExtent = _parseBBOX( mParameters.value( "BBOX" ), bboxOk );
QString crs = mParameters.value( QStringLiteral( "CRS" ), mParameters.value( QStringLiteral( "SRS" ) ) );
if ( crs.compare( "CRS:84", Qt::CaseInsensitive ) == 0 )
{
crs = QString( "EPSG:4326" );
mapExtent.invert();
}
QgsCoordinateReferenceSystem outputCRS = QgsCoordinateReferenceSystem::fromOgcWmsCrs( crs );
if ( outputCRS.hasAxisInverted() )
{
mapExtent.invert();
}
if ( bboxOk )
{
double mapWidthHeightRatio = mapExtent.width() / mapExtent.height();
double imageWidthHeightRatio = ( double )width / ( double )height;
if ( !qgsDoubleNear( mapWidthHeightRatio, imageWidthHeightRatio, 0.0001 ) )
{
if ( mapWidthHeightRatio >= imageWidthHeightRatio )
{
//increase image height
height = width * mapWidthHeightRatio;
}
else
{
//increase image width
width = height / mapWidthHeightRatio;
}
// inspired by MapServer, mapdraw.c L115
double cellsize = ( mapExtent.width() / ( double )width ) * 0.5 + ( mapExtent.height() / ( double )height ) * 0.5;
width = mapExtent.width() / cellsize;
height = mapExtent.height() / cellsize;
}
}
}

0 comments on commit c793e66

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