[QGIS Commit] r8410 - trunk/qgis/src/providers/wms

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed May 7 12:33:23 EDT 2008


Author: mhugent
Date: 2008-05-07 12:33:23 -0400 (Wed, 07 May 2008)
New Revision: 8410

Modified:
   trunk/qgis/src/providers/wms/qgswmsprovider.cpp
Log:
Change order of x- and y- coordinates in WMS bbox parameter for 1.3 and for geographic coordinate systems. This is as described in the WMS1.3 specifications (for WMS1.1.1, there is no such change)

Modified: trunk/qgis/src/providers/wms/qgswmsprovider.cpp
===================================================================
--- trunk/qgis/src/providers/wms/qgswmsprovider.cpp	2008-05-07 08:01:52 UTC (rev 8409)
+++ trunk/qgis/src/providers/wms/qgswmsprovider.cpp	2008-05-07 16:33:23 UTC (rev 8410)
@@ -334,13 +334,44 @@
 
   // Bounding box in WMS format
   QString bbox;
+
+  //according to the WMS spec for 1.3, the order of x - and y - coordinates is inverted for geographical CRS
+  bool changeXY = false;
+  if(mCapabilities.version == "1.3.0" || mCapabilities.version == "1.3")
+    {
+      //create CRS from string
+      bool conversionOk;
+      int epsgNr = imageCrs.section(":", 1, 1).toInt(&conversionOk);
+      if(conversionOk)
+	{
+	  QgsSpatialRefSys theSrs;
+	  theSrs.createFromEpsg(epsgNr);
+	  if(theSrs.geographicFlag())
+	    {
+	      changeXY = true;
+	    }
+	}
+    }
+ 
+
   // Warning: does not work with scientific notation
-  bbox = QString("%1,%2,%3,%4").
-          arg(viewExtent.xMin(),0,'f').
-          arg(viewExtent.yMin(),0,'f').
-          arg(viewExtent.xMax(),0,'f').
-          arg(viewExtent.yMax(),0,'f');
-          
+  if(changeXY)
+    {
+      bbox = QString("%1,%2,%3,%4").
+	arg(viewExtent.yMin(),0,'f').
+	arg(viewExtent.xMin(),0,'f').
+	arg(viewExtent.yMax(),0,'f').
+	arg(viewExtent.xMax(),0,'f');
+    }
+  else
+    {
+      bbox = QString("%1,%2,%3,%4").
+	arg(viewExtent.xMin(),0,'f').
+	arg(viewExtent.yMin(),0,'f').
+	arg(viewExtent.xMax(),0,'f').
+	arg(viewExtent.yMax(),0,'f');
+    }        
+  
   // Width in WMS format
   QString width;
   width = width.setNum(pixelWidth);



More information about the QGIS-commit mailing list