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 4, 2014
1 parent 5c3d0dd commit 99d030d
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

1 comment on commit 99d030d

@palmerj
Copy link
Contributor

@palmerj palmerj commented on 99d030d Mar 4, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This a good patch for our service http://data.linz.govt.nz

Jeremy

Please sign in to comment.