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)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8410 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2008-05-07 16:33:23 +00:00
parent be36ee5832
commit 106796560e

View File

@ -334,13 +334,44 @@ QImage* QgsWmsProvider::draw(QgsRect const & viewExtent, int pixelWidth, int pi
// 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);