Skip to content
Permalink
Browse files

server: fix parsing of bbox numbers in scientific notation containing +

(reverts 905561f, cherry picked and merged 6309dbd, 57046c5, 8c8a9e0)
  • Loading branch information
jef-n committed Mar 20, 2015
1 parent 2e0cba5 commit e983efb0e939c502def49951d2bd8594feaacc21
Showing with 25 additions and 49 deletions.
  1. +4 −3 src/server/qgshttprequesthandler.cpp
  2. +21 −46 src/server/qgswmsserver.cpp
@@ -505,7 +505,7 @@ void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request,
parameters.clear();


//insert key and value into the map (parameters are separated by &
//insert key and value into the map (parameters are separated by &)
foreach ( QString element, request.split( "&" ) )
{
int sepidx = element.indexOf( "=", 0, Qt::CaseSensitive );
@@ -515,10 +515,11 @@ void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request,
}

QString key = element.left( sepidx );
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 caracters and utf-8 encodings
key = QUrl::fromPercentEncoding( key.toLocal8Bit() ); //replace encoded special caracters and utf-8 encodings
value = QUrl::fromPercentEncoding( value.toLocal8Bit() ); //replace encoded special characters and utf-8 encodings

if ( key.compare( "SLD_BODY", Qt::CaseInsensitive ) == 0 )
{
@@ -595,29 +595,26 @@ 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;

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;

if ( bbox.isEmpty() ) return bbox;

*ok = true;
return bbox;
return QgsRectangle();

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();
}

ok = true;
return QgsRectangle( d[0], d[1], d[2], d[3] );
}


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

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

if ( mParameters.contains( "RULE" ) )
@@ -1767,24 +1764,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;

bool bboxOk;
QgsRectangle mapExtent = _parseBBOX( mParameters.value( "BBOX", "0,0,0,0" ), bboxOk );
if ( !bboxOk )
{
//throw a service exception
@@ -1840,15 +1821,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 e983efb

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