Skip to content
Permalink
Browse files
Delete sld parser for sent sld after request
  • Loading branch information
mhugent committed Apr 1, 2014
1 parent 59aaf90 commit e7d0433509cfed8f3a538bd31d25df398c358860
Showing with 22 additions and 11 deletions.
  1. +17 −11 src/mapserver/qgswmsserver.cpp
  2. +5 −0 src/mapserver/qgswmsserver.h
@@ -60,7 +60,7 @@
QgsWMSServer::QgsWMSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsWMSConfigParser* cp,
QgsRequestHandler* rh, QgsMapRenderer* renderer, QgsCapabilitiesCache* capCache )
: QgsOWSServer( configFilePath, parameters, rh )
, mMapRenderer( renderer ), mCapabilitiesCache( capCache ), mConfigParser( cp )
, mMapRenderer( renderer ), mCapabilitiesCache( capCache ), mConfigParser( cp ), mOwnsConfigParser( false )
{
}

@@ -72,6 +72,16 @@ QgsWMSServer::QgsWMSServer(): QgsOWSServer( QString(), QMap<QString, QString>(),
{
}

void QgsWMSServer::cleanupAfterRequest()
{
if ( mOwnsConfigParser )
{
delete mConfigParser;
mConfigParser = 0;
mOwnsConfigParser = false;
}
}

void QgsWMSServer::executeRequest()
{
if ( !mMapRenderer || !mConfigParser || !mRequestHandler || !mCapabilitiesCache )
@@ -85,7 +95,6 @@ void QgsWMSServer::executeRequest()
{
QgsDebugMsg( "unable to find 'REQUEST' parameter, exiting..." );
mRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
return;
}

//version
@@ -111,6 +120,7 @@ void QgsWMSServer::executeRequest()
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
cleanupAfterRequest();
return;
}
mCapabilitiesCache->insertCapabilitiesDocument( mConfigFilePath, getProjectSettings ? "projectSettings" : version, &doc );
@@ -125,7 +135,6 @@ void QgsWMSServer::executeRequest()
{
mRequestHandler->sendGetCapabilitiesResponse( *capabilitiesDocument );
}
return;
}
//GetMap
else if ( request.compare( "GetMap", Qt::CaseInsensitive ) == 0 )
@@ -139,6 +148,7 @@ void QgsWMSServer::executeRequest()
{
QgsDebugMsg( "Caught exception during GetMap request" );
mRequestHandler->sendServiceException( ex );
cleanupAfterRequest();
return;
}

@@ -154,7 +164,6 @@ void QgsWMSServer::executeRequest()
QgsDebugMsg( "result image is 0" );
}
delete result;
return;
}
//GetFeatureInfo
else if ( request.compare( "GetFeatureInfo", Qt::CaseInsensitive ) == 0 )
@@ -164,18 +173,19 @@ void QgsWMSServer::executeRequest()
{
if ( getFeatureInfo( featureInfoDoc, version ) != 0 )
{
cleanupAfterRequest();
return;
}
}
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
cleanupAfterRequest();
return;
}

QString infoFormat = mParameters.value( "INFO_FORMAT" );
mRequestHandler->sendGetFeatureInfoResponse( featureInfoDoc, infoFormat );
return;
}
//GetContext
else if ( request.compare( "GetContext", Qt::CaseInsensitive ) == 0 )
@@ -189,7 +199,6 @@ void QgsWMSServer::executeRequest()
{
mRequestHandler->sendServiceException( ex );
}
return;
}
//GetStyle for compatibility with earlier QGIS versions
else if ( request.compare( "GetStyle", Qt::CaseInsensitive ) == 0 )
@@ -203,7 +212,6 @@ void QgsWMSServer::executeRequest()
{
mRequestHandler->sendServiceException( ex );
}
return;
}
//GetStyles
else if ( request.compare( "GetStyles", Qt::CaseInsensitive ) == 0 )
@@ -225,7 +233,6 @@ void QgsWMSServer::executeRequest()
mRequestHandler->sendServiceException( ex );
}
}
return;
}
//GetLegendGraphic
else if ( request.compare( "GetLegendGraphic", Qt::CaseInsensitive ) == 0 ||
@@ -255,7 +262,6 @@ void QgsWMSServer::executeRequest()
//do some error handling
QgsDebugMsg( "result image is 0" );
}
return;
}
//GetPrint
else if ( request.compare( "GetPrint", Qt::CaseInsensitive ) == 0 )
@@ -275,14 +281,13 @@ void QgsWMSServer::executeRequest()
mRequestHandler->sendGetPrintResponse( printOutput );
}
delete printOutput;
return;
}
else//unknown request
{
QgsMapServiceException e( "OperationNotSupported", "Operation " + request + " not supported" );
mRequestHandler->sendServiceException( e );
return;
}
cleanupAfterRequest();
}

void QgsWMSServer::appendFormats( QDomDocument &doc, QDomElement &elem, const QStringList &formats )
@@ -1568,6 +1573,7 @@ int QgsWMSServer::initializeSLDParser( QStringList& layersList, QStringList& sty
QgsSLDConfigParser* userSLDParser = new QgsSLDConfigParser( theDocument, mParameters );
userSLDParser->setFallbackParser( mConfigParser );
mConfigParser = userSLDParser;
mOwnsConfigParser = true;
//now replace the content of layersList and stylesList (if present)
layersList.clear();
stylesList.clear();
@@ -227,13 +227,18 @@ class QgsWMSServer: public QgsOWSServer
/**Converts a feature info xml document to SIA2045 norm*/
void convertFeatureInfoToSIA2045( QDomDocument& doc );

/**Cleanup temporary objects (e.g. SLD parser objects or temporary files) after request*/
void cleanupAfterRequest();

/**Map containing the WMS parameters*/
QgsMapRenderer* mMapRenderer;

QgsCapabilitiesCache* mCapabilitiesCache;

QgsWMSConfigParser* mConfigParser;

bool mOwnsConfigParser; //delete config parser after request (e.g. sent SLD)

QDomElement createFeatureGML(
QgsFeature* feat,
QgsVectorLayer* layer,

0 comments on commit e7d0433

Please sign in to comment.