Skip to content
Permalink
Browse files

Cache result of checking whether axis should be inverted for wms laye…

…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 99d030d67594766c5acb452adb84cc0f803f201d
Showing with 16 additions and 4 deletions.
  1. +14 −4 src/providers/wms/qgswmscapabilities.cpp
  2. +2 −0 src/providers/wms/qgswmscapabilities.h
@@ -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
@@ -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;

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

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


@@ -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 )
@@ -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;
};

1 comment on commit 99d030d

@palmerj

This comment has been minimized.

Copy link
Contributor

@palmerj palmerj commented on 99d030d Mar 4, 2014

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

Jeremy

Please sign in to comment.
You can’t perform that action at this time.