@@ -595,28 +595,29 @@ static QgsLayerTreeModelLegendNode* _findLegendNodeForRule( QgsLayerTreeModel* l
595
595
}
596
596
597
597
598
- static QgsRectangle _parseBBOX ( const QString& bboxStr, bool * ok )
598
+ static QgsRectangle _parseBBOX ( const QString & bboxStr, bool & ok )
599
599
{
600
- *ok = false ;
601
- QgsRectangle bbox;
600
+ ok = false ;
602
601
603
602
QStringList lst = bboxStr.split ( " ," );
604
603
if ( lst.count () != 4 )
605
- return bbox ;
604
+ return QgsRectangle () ;
606
605
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
+ }
616
615
617
- if ( bbox.isEmpty () ) return bbox;
616
+ QgsRectangle bbox ( d[0 ], d[1 ], d[2 ], d[3 ] );
617
+ if ( bbox.isEmpty () )
618
+ return QgsRectangle ();
618
619
619
- * ok = true ;
620
+ ok = true ;
620
621
return bbox;
621
622
}
622
623
@@ -644,7 +645,7 @@ QImage* QgsWMSServer::getLegendGraphics()
644
645
contentBasedLegend = true ;
645
646
646
647
bool bboxOk;
647
- contentBasedLegendExtent = _parseBBOX ( mParameters [" BBOX" ], & bboxOk );
648
+ contentBasedLegendExtent = _parseBBOX ( mParameters [" BBOX" ], bboxOk );
648
649
if ( !bboxOk )
649
650
throw QgsMapServiceException ( " InvalidParameterValue" , " Invalid BBOX parameter" );
650
651
@@ -1771,24 +1772,8 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const
1771
1772
mMapRenderer ->setOutputSize ( QSize ( paintDevice->width (), paintDevice->height () ), paintDevice->logicalDpiX () );
1772
1773
1773
1774
// map extent
1774
- bool conversionSuccess;
1775
- double minx, miny, maxx, maxy;
1776
- QString bbString = mParameters .value ( " BBOX" , " 0,0,0,0" );
1777
-
1778
1775
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 );
1792
1777
if ( !bboxOk )
1793
1778
{
1794
1779
// throw a service exception
@@ -1844,15 +1829,9 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const
1844
1829
QString version = mParameters .value ( " VERSION" , " 1.3.0" );
1845
1830
if ( version != " 1.1.1" && outputCRS.axisInverted () )
1846
1831
{
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 ();
1853
1833
}
1854
1834
1855
- QgsRectangle mapExtent ( minx, miny, maxx, maxy );
1856
1835
mMapRenderer ->setExtent ( mapExtent );
1857
1836
1858
1837
if ( mConfigParser )
0 commit comments