Skip to content

Commit

Permalink
Cache result of checking whether axis should be inverted for wms laye…
Browse files Browse the repository at this point in the history
…rs. Greatly improves speed of connecting to wms layers when a wms server has many available layers.
  • Loading branch information
nyalldawson committed Mar 21, 2014
1 parent baa6cbd commit ca26231
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/providers/wms/qgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4951,12 +4951,23 @@ bool QgsWmsProvider::shouldInvertAxisOrientation( const QString& ogcCrs )
bool changeXY = false;
if ( !mIgnoreAxisOrientation && ( mCapabilities.version == "1.3.0" || mCapabilities.version == "1.3" ) )
{

//have we already checked this crs?
if ( mCrsInvertAxis.contains( ogcCrs ) )
{
//if so, return previous result to save time
return mCrsInvertAxis[ ogcCrs ];
}

//create CRS from string
QgsCoordinateReferenceSystem theSrs;
if ( theSrs.createFromOgcWmsCrs( ogcCrs ) && theSrs.axisInverted() )
{
changeXY = true;
}

//cache result to speed up future checks
mCrsInvertAxis[ ogcCrs ] = changeXY;
}

if ( mInvertAxisOrientation )
Expand Down
3 changes: 3 additions & 0 deletions src/providers/wms/qgswmsprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,9 @@ class QgsWmsProvider : public QgsRasterDataProvider

QgsCoordinateReferenceSystem mCrs;

//temporarily caches invert axis setting for each crs
QHash<QString, bool> mCrsInvertAxis;

};


Expand Down

0 comments on commit ca26231

Please sign in to comment.