Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 25, 2015
1 parent 2e0cba5 commit e983efb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 49 deletions.
7 changes: 4 additions & 3 deletions src/server/qgshttprequesthandler.cpp
Expand Up @@ -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 );
Expand All @@ -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 )
{
Expand Down
67 changes: 21 additions & 46 deletions src/server/qgswmsserver.cpp
Expand Up @@ -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] );
}


Expand All @@ -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" ) )
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 )
Expand Down

0 comments on commit e983efb

Please sign in to comment.