Skip to content

Commit

Permalink
Merge pull request #1222 from nyalldawson/wms_layer_speed
Browse files Browse the repository at this point in the history
Cache result of checking whether axis should be inverted for wms layers
  • Loading branch information
jef-n committed Mar 4, 2014
2 parents 2846857 + 99d030d commit 837642b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/providers/wms/qgswmscapabilities.cpp
Expand Up @@ -696,7 +696,7 @@ void QgsWmsCapabilities::parseLegendUrl( QDomElement const & e, QgsWmsLegendUrlP
void QgsWmsCapabilities::parseLayer( QDomElement const & e, QgsWmsLayerProperty& layerProperty,
QgsWmsLayerProperty *parentProperty )
{
QgsDebugMsg( "entering." );
//QgsDebugMsg( "entering." );

// TODO: Delete this stanza completely, depending on success of "Inherit things into the sublayer" below.
// // enforce WMS non-inheritance rules
Expand All @@ -718,15 +718,15 @@ void QgsWmsCapabilities::parseLayer( QDomElement const & e, QgsWmsLayerProperty&
QDomElement e1 = n1.toElement(); // try to convert the node to an element.
if ( !e1.isNull() )
{
QgsDebugMsg( " " + e1.tagName() ); // the node really is an element.
//QgsDebugMsg( " " + e1.tagName() ); // the node really is an element.

QString tagName = e1.tagName();
if ( tagName.startsWith( "wms:" ) )
tagName = tagName.mid( 4 );

if ( tagName == "Layer" )
{
QgsDebugMsg( " Nested layer." );
//QgsDebugMsg( " Nested layer." );

QgsWmsLayerProperty subLayerProperty;

Expand Down Expand Up @@ -944,7 +944,7 @@ void QgsWmsCapabilities::parseLayer( QDomElement const & e, QgsWmsLayerProperty&
layerProperty.crs.clear();
}

QgsDebugMsg( "exiting." );
//QgsDebugMsg( "exiting." );
}


Expand Down Expand Up @@ -1804,12 +1804,22 @@ bool QgsWmsCapabilities::shouldInvertAxisOrientation( const QString& ogcCrs )
bool changeXY = false;
if ( !mParserSettings.ignoreAxisOrientation && ( 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 ( mParserSettings.invertAxisOrientation )
Expand Down
2 changes: 2 additions & 0 deletions src/providers/wms/qgswmscapabilities.h
Expand Up @@ -664,6 +664,8 @@ class QgsWmsCapabilities
*/
QHash<QString, QgsWmtsTileMatrixSet> mTileMatrixSets;

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

friend class QgsWmsProvider;
};
Expand Down

0 comments on commit 837642b

Please sign in to comment.