Skip to content
Permalink
Browse files

better fix for 8c8a9e0

  • Loading branch information
jef-n committed Mar 20, 2015
1 parent 12e0f35 commit 57046c53ee9880c109bea6ea1be6ea98aa350b48
Showing with 20 additions and 40 deletions.
  1. +1 −0 src/server/qgshttprequesthandler.cpp
  2. +19 −40 src/server/qgswmsserver.cpp
@@ -518,6 +518,7 @@ void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request,
key = QUrl::fromPercentEncoding( key.toLocal8Bit() ); //replace encoded special characters and utf-8 encodings

QString value = element.mid( sepidx + 1 );
value.replace( "+", " " );
value = QUrl::fromPercentEncoding( value.toLocal8Bit() ); //replace encoded special characters and utf-8 encodings

if ( key.compare( "SLD_BODY", Qt::CaseInsensitive ) == 0 )
@@ -595,28 +595,29 @@ static QgsLayerTreeModelLegendNode* _findLegendNodeForRule( QgsLayerTreeModel* l
}


static QgsRectangle _parseBBOX( const QString& bboxStr, bool* ok )
static QgsRectangle _parseBBOX( const QString &bboxStr, bool &ok )
{
*ok = false;
QgsRectangle bbox;
ok = false;

QStringList lst = bboxStr.split( "," );
if ( lst.count() != 4 )
return bbox;
return QgsRectangle();

bool convOk;
bbox.setXMinimum( lst[0].toDouble( &convOk ) );
if ( !convOk ) return bbox;
bbox.setYMinimum( lst[1].toDouble( &convOk ) );
if ( !convOk ) return bbox;
bbox.setXMaximum( lst[2].toDouble( &convOk ) );
if ( !convOk ) return bbox;
bbox.setYMaximum( lst[3].toDouble( &convOk ) );
if ( !convOk ) return bbox;
double d[4];
for ( int i = 0; i < 4; i++ )
{
bool ok;
lst[i].replace( " ", "+" );
d[i] = lst[i].toDouble( &ok );
if ( !ok )
return QgsRectangle();
}

if ( bbox.isEmpty() ) return bbox;
QgsRectangle bbox( d[0], d[1], d[2], d[3] );
if ( bbox.isEmpty() )
return QgsRectangle();

*ok = true;
ok = true;
return bbox;
}

@@ -644,7 +645,7 @@ QImage* QgsWMSServer::getLegendGraphics()
contentBasedLegend = true;

bool bboxOk;
contentBasedLegendExtent = _parseBBOX( mParameters["BBOX"], &bboxOk );
contentBasedLegendExtent = _parseBBOX( mParameters["BBOX"], bboxOk );
if ( !bboxOk )
throw QgsMapServiceException( "InvalidParameterValue", "Invalid BBOX parameter" );

@@ -1771,24 +1772,8 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const
mMapRenderer->setOutputSize( QSize( paintDevice->width(), paintDevice->height() ), paintDevice->logicalDpiX() );

//map extent
bool conversionSuccess;
double minx, miny, maxx, maxy;
QString bbString = mParameters.value( "BBOX", "0,0,0,0" );

bool bboxOk = true;
minx = bbString.section( ",", 0, 0 ).toDouble( &conversionSuccess );
if ( !conversionSuccess )
bboxOk = false;
miny = bbString.section( ",", 1, 1 ).toDouble( &conversionSuccess );
if ( !conversionSuccess )
bboxOk = false;
maxx = bbString.section( ",", 2, 2 ).toDouble( &conversionSuccess );
if ( !conversionSuccess )
bboxOk = false;
maxy = bbString.section( ",", 3, 3 ).toDouble( &conversionSuccess );
if ( !conversionSuccess )
bboxOk = false;

QgsRectangle mapExtent = _parseBBOX( mParameters.value( "BBOX", "0,0,0,0" ), bboxOk );
if ( !bboxOk )
{
//throw a service exception
@@ -1844,15 +1829,9 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const
QString version = mParameters.value( "VERSION", "1.3.0" );
if ( version != "1.1.1" && outputCRS.axisInverted() )
{
//switch coordinates of extent
double tmp;
tmp = minx;
minx = miny; miny = tmp;
tmp = maxx;
maxx = maxy; maxy = tmp;
mapExtent.invert();
}

QgsRectangle mapExtent( minx, miny, maxx, maxy );
mMapRenderer->setExtent( mapExtent );

if ( mConfigParser )

0 comments on commit 57046c5

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