Skip to content

Commit

Permalink
Consider number of layers in a project can be higher than 100 for cac…
Browse files Browse the repository at this point in the history
…hing
  • Loading branch information
mhugent committed Apr 8, 2014
1 parent fd8c92f commit 394a80c
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/mapserver/qgsconfigcache.cpp
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions src/mapserver/qgssldconfigparser.cpp
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/mapserver/qgssldconfigparser.h
Expand Up @@ -114,6 +114,8 @@ class QgsSLDConfigParser: public QgsWMSConfigParser

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

int nLayers() const;

private:

/**SLD as dom document*/
Expand Down
3 changes: 3 additions & 0 deletions src/mapserver/qgswmsconfigparser.h
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/mapserver/qgswmsprojectparser.cpp
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/mapserver/qgswmsprojectparser.h
Expand Up @@ -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;

Expand Down

0 comments on commit 394a80c

Please sign in to comment.