From fd8c92f3e3ccc9ece8a60bbba4a8328b8598f40d Mon Sep 17 00:00:00 2001 From: Marco Hugentobler Date: Mon, 7 Apr 2014 14:28:28 +0200 Subject: [PATCH] Cleanup config cache --- src/mapserver/qgis_map_serv.cpp | 2 +- src/mapserver/qgsconfigcache.cpp | 4 +++- src/mapserver/qgsconfigcache.h | 3 ++- src/mapserver/qgsserverprojectparser.cpp | 5 +++++ src/mapserver/qgsserverprojectparser.h | 2 ++ src/mapserver/qgswmsserver.cpp | 24 ------------------------ 6 files changed, 13 insertions(+), 27 deletions(-) diff --git a/src/mapserver/qgis_map_serv.cpp b/src/mapserver/qgis_map_serv.cpp index 3332a2d8857..6549d2e4c54 100644 --- a/src/mapserver/qgis_map_serv.cpp +++ b/src/mapserver/qgis_map_serv.cpp @@ -350,7 +350,7 @@ int main( int argc, char * argv[] ) } else //WMS else { - QgsWMSConfigParser* p = QgsConfigCache::instance()->wmsConfiguration( configFilePath ); + QgsWMSConfigParser* p = QgsConfigCache::instance()->wmsConfiguration( configFilePath, parameterMap ); if ( !p ) { //error handling diff --git a/src/mapserver/qgsconfigcache.cpp b/src/mapserver/qgsconfigcache.cpp index c1f1a49b9c5..009ceb6e0c5 100644 --- a/src/mapserver/qgsconfigcache.cpp +++ b/src/mapserver/qgsconfigcache.cpp @@ -19,6 +19,7 @@ #include "qgswcsprojectparser.h" #include "qgswfsprojectparser.h" #include "qgswmsprojectparser.h" +#include "qgssldconfigparser.h" QgsConfigCache* QgsConfigCache::instance() { @@ -74,7 +75,7 @@ QgsWFSProjectParser* QgsConfigCache::wfsConfiguration( const QString& filePath ) return p; } -QgsWMSConfigParser* QgsConfigCache::wmsConfiguration( const QString& filePath ) +QgsWMSConfigParser* QgsConfigCache::wmsConfiguration( const QString& filePath, const QMap& parameterMap ) { QgsWMSConfigParser* p = mWMSConfigCache.object( filePath ); if ( p ) @@ -93,6 +94,7 @@ QgsWMSConfigParser* QgsConfigCache::wmsConfiguration( const QString& filePath ) QDomElement documentElem = doc->documentElement(); if ( documentElem.tagName() == "StyledLayerDescriptor" ) { + p = new QgsSLDConfigParser( doc, parameterMap ); } else { diff --git a/src/mapserver/qgsconfigcache.h b/src/mapserver/qgsconfigcache.h index d112e367fb9..abecacf8906 100644 --- a/src/mapserver/qgsconfigcache.h +++ b/src/mapserver/qgsconfigcache.h @@ -20,6 +20,7 @@ #include #include +#include #include class QgsWCSProjectParser; @@ -37,7 +38,7 @@ class QgsConfigCache: public QObject QgsWCSProjectParser* wcsConfiguration( const QString& filePath ); QgsWFSProjectParser* wfsConfiguration( const QString& filePath ); - QgsWMSConfigParser* wmsConfiguration( const QString& filePath ); + QgsWMSConfigParser* wmsConfiguration( const QString& filePath, const QMap& parameterMap = QMap< QString, QString >() ); private: QgsConfigCache(); diff --git a/src/mapserver/qgsserverprojectparser.cpp b/src/mapserver/qgsserverprojectparser.cpp index fceccb7edf8..39cf5bf52ef 100644 --- a/src/mapserver/qgsserverprojectparser.cpp +++ b/src/mapserver/qgsserverprojectparser.cpp @@ -329,6 +329,11 @@ QgsRectangle QgsServerProjectParser::projectExtent() const return extent; } +int QgsServerProjectParser::numberOfLayers() const +{ + return mProjectLayerElements.size(); +} + QString QgsServerProjectParser::layerName( const QDomElement& layerElem ) const { if ( layerElem.isNull() ) diff --git a/src/mapserver/qgsserverprojectparser.h b/src/mapserver/qgsserverprojectparser.h index 594829252d4..31a8883cd8a 100644 --- a/src/mapserver/qgsserverprojectparser.h +++ b/src/mapserver/qgsserverprojectparser.h @@ -117,6 +117,8 @@ class QgsServerProjectParser QgsRectangle projectExtent() const; + int numberOfLayers() const; + private: /**Content of project file*/ diff --git a/src/mapserver/qgswmsserver.cpp b/src/mapserver/qgswmsserver.cpp index 7692d4d44bb..f26e55e5351 100644 --- a/src/mapserver/qgswmsserver.cpp +++ b/src/mapserver/qgswmsserver.cpp @@ -1591,30 +1591,6 @@ int QgsWMSServer::initializeSLDParser( QStringList& layersList, QStringList& sty layersList << *layersIt; stylesList << *stylesIt; } - -#if 0 //todo: fixme - QgsSLDParser* userSLDParser = new QgsSLDParser( theDocument ); - userSLDParser->setParameterMap( mParameters ); - userSLDParser->setFallbackParser( mConfigParser ); - mConfigParser = userSLDParser; - //now replace the content of layersList and stylesList (if present) - layersList.clear(); - stylesList.clear(); - QStringList layersSTDList; - QStringList stylesSTDList; - if ( mConfigParser->layersAndStyles( layersSTDList, stylesSTDList ) != 0 ) - { - QgsDebugMsg( "Error, no layers and styles found in SLD" ); - return 0; - } - QStringList::const_iterator layersIt; - QStringList::const_iterator stylesIt; - for ( layersIt = layersSTDList.constBegin(), stylesIt = stylesSTDList.constBegin(); layersIt != layersSTDList.constEnd(); ++layersIt, ++stylesIt ) - { - layersList << *layersIt; - stylesList << *stylesIt; - } -#endif //0 //todo: fixme } return 0; }