Skip to content

Commit

Permalink
Change order of x- and y- coordinates in WMS bbox parameter for 1.3 a…
Browse files Browse the repository at this point in the history
…nd 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@8410 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 7, 2008
1 parent 72cced7 commit a720161
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit a720161

Please sign in to comment.