Skip to content
Permalink
Browse files
Consider number of layers in a project can be higher than 100 for cac…
…hing
  • Loading branch information
mhugent committed Apr 8, 2014
1 parent fd8c92f commit 394a80cf3725e3b5772b1c3fffae3ff84c97ad16
@@ -101,6 +101,12 @@ QgsWMSConfigParser* QgsConfigCache::wmsConfiguration( const QString& filePath, c
p = new QgsWMSProjectParser( doc, filePath );
}

int numberOfLayers = p->nLayers();
if ( numberOfLayers > 100 )
{
mWMSConfigCache.setMaxCost( numberOfLayers );
}

mWMSConfigCache.insert( filePath, p );
mFileSystemWatcher.addPath( filePath );
return p;
@@ -702,6 +702,20 @@ QList< QPair< QString, QgsLayerCoordinateTransform > > QgsSLDConfigParser::layer
return QList< QPair< QString, QgsLayerCoordinateTransform > >();
}

int QgsSLDConfigParser::nLayers() const
{
if ( mXMLDoc )
{
QDomNode sldNode = mXMLDoc->documentElement();
if ( !sldNode.isNull() )
{
QDomNodeList layerNodeList = sldNode.toElement().elementsByTagName( "UserLayer" );
return layerNodeList.size();
}
}
return 0;
}

QList<QDomElement> QgsSLDConfigParser::findNamedLayerElements( const QString& layerName ) const
{
QList<QDomElement> resultList;
@@ -114,6 +114,8 @@ class QgsSLDConfigParser: public QgsWMSConfigParser

QList< QPair< QString, QgsLayerCoordinateTransform > > layerCoordinateTransforms() const;

int nLayers() const;

private:

/**SLD as dom document*/
@@ -105,6 +105,9 @@ class QgsWMSConfigParser
virtual void addExternalGMLData( const QString& layerName, QDomDocument* gmlDoc ) = 0;

virtual QList< QPair< QString, QgsLayerCoordinateTransform > > layerCoordinateTransforms() const = 0;

virtual int nLayers() const = 0;

#if 0
/**List of GML datasets passed outside SLD (e.g. in a SOAP request). Key of the map is the layer name*/
QMap<QString, QDomDocument*> mExternalGMLDatasets;
@@ -1638,6 +1638,11 @@ void QgsWMSProjectParser::drawOverlays( QPainter* p, int dpi, int width, int hei
}
}

int QgsWMSProjectParser::nLayers() const
{
return mProjectParser.numberOfLayers();
}

QDomElement QgsWMSProjectParser::composerByName( const QString& composerName ) const
{
QDomElement composerElem;
@@ -97,6 +97,8 @@ class QgsWMSProjectParser: public QgsWMSConfigParser
/**Draw text annotation items from the QGIS projectfile*/
void drawOverlays( QPainter* p, int dpi, int width, int height ) const;

int nLayers() const;

private:
QgsServerProjectParser mProjectParser;

0 comments on commit 394a80c

Please sign in to comment.