Skip to content

Commit b5897c7

Browse files
committedFeb 15, 2014
Fix switched axes problem in WMS 1.3 with non-projected CRS
1 parent 51afb50 commit b5897c7

File tree

2 files changed

+34
-27
lines changed

2 files changed

+34
-27
lines changed
 

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -639,20 +639,7 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
639639
mCacheReply = 0;
640640
}
641641

642-
//according to the WMS spec for 1.3, some CRS have inverted axis
643-
bool changeXY = false;
644-
if ( !mIgnoreAxisOrientation && ( mCapabilities.version == "1.3.0" || mCapabilities.version == "1.3" ) )
645-
{
646-
//create CRS from string
647-
QgsCoordinateReferenceSystem theSrs;
648-
if ( theSrs.createFromOgcWmsCrs( mImageCrs ) && theSrs.axisInverted() )
649-
{
650-
changeXY = true;
651-
}
652-
}
653-
654-
if ( mInvertAxisOrientation )
655-
changeXY = !changeXY;
642+
bool changeXY = shouldInvertAxisOrientation( mImageCrs );
656643

657644
// compose the URL query string for the WMS server.
658645
QString crsKey = "SRS"; //SRS in 1.1.1 and CRS in 1.3.0
@@ -2493,6 +2480,13 @@ void QgsWmsProvider::parseLayer( QDomElement const & e, QgsWmsLayerProperty& lay
24932480
else if ( e1.hasAttribute( "SRS" ) )
24942481
bbox.crs = e1.attribute( "SRS" );
24952482

2483+
if ( shouldInvertAxisOrientation( bbox.crs ) )
2484+
{
2485+
QgsRectangle invAxisBbox( bbox.box.yMinimum(), bbox.box.xMinimum(),
2486+
bbox.box.yMaximum(), bbox.box.xMaximum() );
2487+
bbox.box = invAxisBbox;
2488+
}
2489+
24962490
layerProperty.boundingBox.push_back( bbox );
24972491
}
24982492
else
@@ -4240,19 +4234,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint & thePoint, Qgs
42404234

42414235
// Collect which layers to query on
42424236
//according to the WMS spec for 1.3, the order of x - and y - coordinates is inverted for geographical CRS
4243-
bool changeXY = false;
4244-
if ( !mIgnoreAxisOrientation && ( mCapabilities.version == "1.3.0" || mCapabilities.version == "1.3" ) )
4245-
{
4246-
//create CRS from string
4247-
QgsCoordinateReferenceSystem theSrs;
4248-
if ( theSrs.createFromOgcWmsCrs( mImageCrs ) && theSrs.axisInverted() )
4249-
{
4250-
changeXY = true;
4251-
}
4252-
}
4253-
4254-
if ( mInvertAxisOrientation )
4255-
changeXY = !changeXY;
4237+
bool changeXY = shouldInvertAxisOrientation( mImageCrs );
42564238

42574239
// compose the URL query string for the WMS server.
42584240
QString crsKey = "SRS"; //SRS in 1.1.1 and CRS in 1.3.0
@@ -4962,6 +4944,28 @@ void QgsWmsProvider::getLegendGraphicReplyProgress( qint64 bytesReceived, qint64
49624944
emit statusChanged( msg );
49634945
}
49644946

4947+
bool QgsWmsProvider::shouldInvertAxisOrientation( const QString& ogcCrs )
4948+
{
4949+
//according to the WMS spec for 1.3, some CRS have inverted axis
4950+
bool changeXY = false;
4951+
if ( !mIgnoreAxisOrientation && ( mCapabilities.version == "1.3.0" || mCapabilities.version == "1.3" ) )
4952+
{
4953+
//create CRS from string
4954+
QgsCoordinateReferenceSystem theSrs;
4955+
if ( theSrs.createFromOgcWmsCrs( ogcCrs ) && theSrs.axisInverted() )
4956+
{
4957+
changeXY = true;
4958+
}
4959+
}
4960+
4961+
if ( mInvertAxisOrientation )
4962+
changeXY = !changeXY;
4963+
4964+
return changeXY;
4965+
}
4966+
4967+
4968+
49654969
/**
49664970
* Class factory to return a pointer to a newly created
49674971
* QgsWmsProvider object

‎src/providers/wms/qgswmsprovider.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,9 @@ class QgsWmsProvider : public QgsRasterDataProvider
778778
private:
779779
void showMessageBox( const QString& title, const QString& text );
780780

781+
/** Find out whether to invert axis orientation when parsing/writing coordinates */
782+
bool shouldInvertAxisOrientation( const QString& ogcCrs );
783+
781784
/**
782785
* Try to get best extent for the layer in given CRS. Returns true on success, false otherwise (layer not found, invalid CRS, transform failed)
783786
*/

0 commit comments

Comments
 (0)
Please sign in to comment.