Skip to content

Commit 837642b

Browse files
committed
Merge pull request #1222 from nyalldawson/wms_layer_speed
Cache result of checking whether axis should be inverted for wms layers
2 parents 2846857 + 99d030d commit 837642b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/providers/wms/qgswmscapabilities.cpp

+14-4
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ void QgsWmsCapabilities::parseLegendUrl( QDomElement const & e, QgsWmsLegendUrlP
696696
void QgsWmsCapabilities::parseLayer( QDomElement const & e, QgsWmsLayerProperty& layerProperty,
697697
QgsWmsLayerProperty *parentProperty )
698698
{
699-
QgsDebugMsg( "entering." );
699+
//QgsDebugMsg( "entering." );
700700

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

723723
QString tagName = e1.tagName();
724724
if ( tagName.startsWith( "wms:" ) )
725725
tagName = tagName.mid( 4 );
726726

727727
if ( tagName == "Layer" )
728728
{
729-
QgsDebugMsg( " Nested layer." );
729+
//QgsDebugMsg( " Nested layer." );
730730

731731
QgsWmsLayerProperty subLayerProperty;
732732

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

947-
QgsDebugMsg( "exiting." );
947+
//QgsDebugMsg( "exiting." );
948948
}
949949

950950

@@ -1804,12 +1804,22 @@ bool QgsWmsCapabilities::shouldInvertAxisOrientation( const QString& ogcCrs )
18041804
bool changeXY = false;
18051805
if ( !mParserSettings.ignoreAxisOrientation && ( mCapabilities.version == "1.3.0" || mCapabilities.version == "1.3" ) )
18061806
{
1807+
//have we already checked this crs?
1808+
if ( mCrsInvertAxis.contains( ogcCrs ) )
1809+
{
1810+
//if so, return previous result to save time
1811+
return mCrsInvertAxis[ ogcCrs ];
1812+
}
1813+
18071814
//create CRS from string
18081815
QgsCoordinateReferenceSystem theSrs;
18091816
if ( theSrs.createFromOgcWmsCrs( ogcCrs ) && theSrs.axisInverted() )
18101817
{
18111818
changeXY = true;
18121819
}
1820+
1821+
//cache result to speed up future checks
1822+
mCrsInvertAxis[ ogcCrs ] = changeXY;
18131823
}
18141824

18151825
if ( mParserSettings.invertAxisOrientation )

src/providers/wms/qgswmscapabilities.h

+2
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,8 @@ class QgsWmsCapabilities
664664
*/
665665
QHash<QString, QgsWmtsTileMatrixSet> mTileMatrixSets;
666666

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

668670
friend class QgsWmsProvider;
669671
};

0 commit comments

Comments
 (0)