Skip to content

Commit 57046c5

Browse files
committed
better fix for 8c8a9e0
1 parent 12e0f35 commit 57046c5

File tree

2 files changed

+20
-40
lines changed

2 files changed

+20
-40
lines changed

src/server/qgshttprequesthandler.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request,
518518
key = QUrl::fromPercentEncoding( key.toLocal8Bit() ); //replace encoded special characters and utf-8 encodings
519519

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

523524
if ( key.compare( "SLD_BODY", Qt::CaseInsensitive ) == 0 )

src/server/qgswmsserver.cpp

+19-40
Original file line numberDiff line numberDiff line change
@@ -595,28 +595,29 @@ static QgsLayerTreeModelLegendNode* _findLegendNodeForRule( QgsLayerTreeModel* l
595595
}
596596

597597

598-
static QgsRectangle _parseBBOX( const QString& bboxStr, bool* ok )
598+
static QgsRectangle _parseBBOX( const QString &bboxStr, bool &ok )
599599
{
600-
*ok = false;
601-
QgsRectangle bbox;
600+
ok = false;
602601

603602
QStringList lst = bboxStr.split( "," );
604603
if ( lst.count() != 4 )
605-
return bbox;
604+
return QgsRectangle();
606605

607-
bool convOk;
608-
bbox.setXMinimum( lst[0].toDouble( &convOk ) );
609-
if ( !convOk ) return bbox;
610-
bbox.setYMinimum( lst[1].toDouble( &convOk ) );
611-
if ( !convOk ) return bbox;
612-
bbox.setXMaximum( lst[2].toDouble( &convOk ) );
613-
if ( !convOk ) return bbox;
614-
bbox.setYMaximum( lst[3].toDouble( &convOk ) );
615-
if ( !convOk ) return bbox;
606+
double d[4];
607+
for ( int i = 0; i < 4; i++ )
608+
{
609+
bool ok;
610+
lst[i].replace( " ", "+" );
611+
d[i] = lst[i].toDouble( &ok );
612+
if ( !ok )
613+
return QgsRectangle();
614+
}
616615

617-
if ( bbox.isEmpty() ) return bbox;
616+
QgsRectangle bbox( d[0], d[1], d[2], d[3] );
617+
if ( bbox.isEmpty() )
618+
return QgsRectangle();
618619

619-
*ok = true;
620+
ok = true;
620621
return bbox;
621622
}
622623

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

646647
bool bboxOk;
647-
contentBasedLegendExtent = _parseBBOX( mParameters["BBOX"], &bboxOk );
648+
contentBasedLegendExtent = _parseBBOX( mParameters["BBOX"], bboxOk );
648649
if ( !bboxOk )
649650
throw QgsMapServiceException( "InvalidParameterValue", "Invalid BBOX parameter" );
650651

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

17731774
//map extent
1774-
bool conversionSuccess;
1775-
double minx, miny, maxx, maxy;
1776-
QString bbString = mParameters.value( "BBOX", "0,0,0,0" );
1777-
17781775
bool bboxOk = true;
1779-
minx = bbString.section( ",", 0, 0 ).toDouble( &conversionSuccess );
1780-
if ( !conversionSuccess )
1781-
bboxOk = false;
1782-
miny = bbString.section( ",", 1, 1 ).toDouble( &conversionSuccess );
1783-
if ( !conversionSuccess )
1784-
bboxOk = false;
1785-
maxx = bbString.section( ",", 2, 2 ).toDouble( &conversionSuccess );
1786-
if ( !conversionSuccess )
1787-
bboxOk = false;
1788-
maxy = bbString.section( ",", 3, 3 ).toDouble( &conversionSuccess );
1789-
if ( !conversionSuccess )
1790-
bboxOk = false;
1791-
1776+
QgsRectangle mapExtent = _parseBBOX( mParameters.value( "BBOX", "0,0,0,0" ), bboxOk );
17921777
if ( !bboxOk )
17931778
{
17941779
//throw a service exception
@@ -1844,15 +1829,9 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const
18441829
QString version = mParameters.value( "VERSION", "1.3.0" );
18451830
if ( version != "1.1.1" && outputCRS.axisInverted() )
18461831
{
1847-
//switch coordinates of extent
1848-
double tmp;
1849-
tmp = minx;
1850-
minx = miny; miny = tmp;
1851-
tmp = maxx;
1852-
maxx = maxy; maxy = tmp;
1832+
mapExtent.invert();
18531833
}
18541834

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

18581837
if ( mConfigParser )

0 commit comments

Comments
 (0)