Skip to content

Commit

Permalink
better fix for 8c8a9e0
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Mar 20, 2015
1 parent 12e0f35 commit 57046c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 40 deletions.
1 change: 1 addition & 0 deletions src/server/qgshttprequesthandler.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request,
key = QUrl::fromPercentEncoding( key.toLocal8Bit() ); //replace encoded special characters and utf-8 encodings key = QUrl::fromPercentEncoding( key.toLocal8Bit() ); //replace encoded special characters and utf-8 encodings


QString value = element.mid( sepidx + 1 ); QString value = element.mid( sepidx + 1 );
value.replace( "+", " " );
value = QUrl::fromPercentEncoding( value.toLocal8Bit() ); //replace encoded special characters 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 ) if ( key.compare( "SLD_BODY", Qt::CaseInsensitive ) == 0 )
Expand Down
59 changes: 19 additions & 40 deletions src/server/qgswmsserver.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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; ok = false;
QgsRectangle bbox;


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


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


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; return bbox;
} }


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


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


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


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

bool bboxOk = true; bool bboxOk = true;
minx = bbString.section( ",", 0, 0 ).toDouble( &conversionSuccess ); QgsRectangle mapExtent = _parseBBOX( mParameters.value( "BBOX", "0,0,0,0" ), bboxOk );
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;

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


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


if ( mConfigParser ) if ( mConfigParser )
Expand Down

0 comments on commit 57046c5

Please sign in to comment.