Skip to content

Commit a720161

Browse files
author
mhugent
committed
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@8410 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 72cced7 commit a720161

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

src/providers/wms/qgswmsprovider.cpp

+37-6
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,44 @@ QImage* QgsWmsProvider::draw(QgsRect const & viewExtent, int pixelWidth, int pi
334334

335335
// Bounding box in WMS format
336336
QString bbox;
337+
338+
//according to the WMS spec for 1.3, the order of x - and y - coordinates is inverted for geographical CRS
339+
bool changeXY = false;
340+
if(mCapabilities.version == "1.3.0" || mCapabilities.version == "1.3")
341+
{
342+
//create CRS from string
343+
bool conversionOk;
344+
int epsgNr = imageCrs.section(":", 1, 1).toInt(&conversionOk);
345+
if(conversionOk)
346+
{
347+
QgsSpatialRefSys theSrs;
348+
theSrs.createFromEpsg(epsgNr);
349+
if(theSrs.geographicFlag())
350+
{
351+
changeXY = true;
352+
}
353+
}
354+
}
355+
356+
337357
// Warning: does not work with scientific notation
338-
bbox = QString("%1,%2,%3,%4").
339-
arg(viewExtent.xMin(),0,'f').
340-
arg(viewExtent.yMin(),0,'f').
341-
arg(viewExtent.xMax(),0,'f').
342-
arg(viewExtent.yMax(),0,'f');
343-
358+
if(changeXY)
359+
{
360+
bbox = QString("%1,%2,%3,%4").
361+
arg(viewExtent.yMin(),0,'f').
362+
arg(viewExtent.xMin(),0,'f').
363+
arg(viewExtent.yMax(),0,'f').
364+
arg(viewExtent.xMax(),0,'f');
365+
}
366+
else
367+
{
368+
bbox = QString("%1,%2,%3,%4").
369+
arg(viewExtent.xMin(),0,'f').
370+
arg(viewExtent.yMin(),0,'f').
371+
arg(viewExtent.xMax(),0,'f').
372+
arg(viewExtent.yMax(),0,'f');
373+
}
374+
344375
// Width in WMS format
345376
QString width;
346377
width = width.setNum(pixelWidth);

0 commit comments

Comments
 (0)