Add QgsOWSServer class, move code from qgis_map_serv.cpp into exection() functions

This commit is contained in:
Marco Hugentobler 2014-03-24 22:52:41 +01:00
parent dcda258dd2
commit 0e113e1591
8 changed files with 567 additions and 583 deletions

View File

@ -340,449 +340,22 @@ int main( int argc, char * argv[] )
serviceString = paramIt.value(); serviceString = paramIt.value();
} }
QgsWMSServer* theServer = 0;
if ( serviceString == "WCS" ) if ( serviceString == "WCS" )
{ {
delete theServer; QgsWCSServer wcsServer( configFilePath, parameterMap, adminConfigParser, theRequestHandler );
QgsWCSServer* theServer = 0; wcsServer.executeRequest();
try
{
theServer = new QgsWCSServer( parameterMap );
}
catch ( const QgsMapServiceException &e ) //admin.sld may be invalid
{
theRequestHandler->sendServiceException( e );
continue;
}
theServer->setAdminConfigParser( adminConfigParser );
//request type
QString request = parameterMap.value( "REQUEST" );
if ( request.isEmpty() )
{
//do some error handling
QgsDebugMsg( "unable to find 'REQUEST' parameter, exiting..." );
theRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
delete theRequestHandler;
delete theServer;
continue;
}
if ( request.compare( "GetCapabilities", Qt::CaseInsensitive ) == 0 )
{
QDomDocument capabilitiesDocument;
try
{
capabilitiesDocument = theServer->getCapabilities();
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
delete theRequestHandler;
delete theServer;
continue;
}
QgsDebugMsg( "sending GetCapabilities response" );
theRequestHandler->sendGetCapabilitiesResponse( capabilitiesDocument );
delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "DescribeCoverage", Qt::CaseInsensitive ) == 0 )
{
QDomDocument describeDocument;
try
{
describeDocument = theServer->describeCoverage();
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
delete theRequestHandler;
delete theServer;
continue;
}
QgsDebugMsg( "sending GetCapabilities response" );
theRequestHandler->sendGetCapabilitiesResponse( describeDocument );
delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "GetCoverage", Qt::CaseInsensitive ) == 0 )
{
QByteArray* coverageOutput;
try
{
coverageOutput = theServer->getCoverage();
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
delete theRequestHandler;
delete theServer;
continue;
}
if ( coverageOutput )
{
theRequestHandler->sendGetCoverageResponse( coverageOutput );
}
delete theRequestHandler;
delete theServer;
continue;
}
} }
else if ( serviceString == "WFS" ) else if ( serviceString == "WFS" )
{ {
delete theServer; QgsWFSServer wfsServer( configFilePath, parameterMap, adminConfigParser, theRequestHandler );
QgsWFSServer* theServer = 0; wfsServer.executeRequest();
try }
else //WMS else
{ {
theServer = new QgsWFSServer( parameterMap );
}
catch ( const QgsMapServiceException &e ) //admin.sld may be invalid
{
theRequestHandler->sendServiceException( e );
continue;
}
theServer->setAdminConfigParser( adminConfigParser );
//request type
QString request = parameterMap.value( "REQUEST" );
if ( request.isEmpty() )
{
//do some error handling
QgsDebugMsg( "unable to find 'REQUEST' parameter, exiting..." );
theRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
delete theRequestHandler;
delete theServer;
continue;
}
if ( request.compare( "GetCapabilities", Qt::CaseInsensitive ) == 0 )
{
QDomDocument capabilitiesDocument;
try
{
capabilitiesDocument = theServer->getCapabilities();
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
delete theRequestHandler;
delete theServer;
continue;
}
QgsDebugMsg( "sending GetCapabilities response" );
theRequestHandler->sendGetCapabilitiesResponse( capabilitiesDocument );
delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "DescribeFeatureType", Qt::CaseInsensitive ) == 0 )
{
QDomDocument describeDocument;
try
{
describeDocument = theServer->describeFeatureType();
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
delete theRequestHandler;
delete theServer;
continue;
}
QgsDebugMsg( "sending GetCapabilities response" );
theRequestHandler->sendGetCapabilitiesResponse( describeDocument );
delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "GetFeature", Qt::CaseInsensitive ) == 0 )
{
//output format for GetFeature
QString outputFormat = parameterMap.value( "OUTPUTFORMAT" );
try
{
theServer->getFeature( *theRequestHandler, outputFormat );
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
}
delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "Transaction", Qt::CaseInsensitive ) == 0 )
{
QDomDocument transactionDocument;
try
{
transactionDocument = theServer->transaction( parameterMap.value( "REQUEST_BODY" ) );
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
delete theRequestHandler;
delete theServer;
continue;
}
QgsDebugMsg( "sending Transaction response" );
theRequestHandler->sendGetCapabilitiesResponse( transactionDocument );
delete theRequestHandler;
delete theServer;
continue;
}
return 0;
}
try
{
theServer = new QgsWMSServer( parameterMap, theMapRenderer );
}
catch ( const QgsMapServiceException &e ) //admin.sld may be invalid
{
theRequestHandler->sendServiceException( e );
continue;
}
adminConfigParser->loadLabelSettings( theMapRenderer->labelingEngine() ); adminConfigParser->loadLabelSettings( theMapRenderer->labelingEngine() );
theServer->setAdminConfigParser( adminConfigParser ); QgsWMSServer wmsServer( configFilePath, parameterMap, adminConfigParser, theRequestHandler, theMapRenderer, &capabilitiesCache );
wmsServer.executeRequest();
//request type
QString request = parameterMap.value( "REQUEST" );
if ( request.isEmpty() )
{
//do some error handling
QgsDebugMsg( "unable to find 'REQUEST' parameter, exiting..." );
theRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
delete theRequestHandler;
delete theServer;
continue;
}
QString version = parameterMap.value( "VERSION", "1.3.0" );
bool getProjectSettings = ( request.compare( "GetProjectSettings", Qt::CaseInsensitive ) == 0 );
if ( getProjectSettings )
{
version = "1.3.0"; //getProjectSettings extends WMS 1.3.0 capabilities
}
if ( request.compare( "GetCapabilities", Qt::CaseInsensitive ) == 0 || getProjectSettings )
{
const QDomDocument* capabilitiesDocument = capabilitiesCache.searchCapabilitiesDocument( configFilePath, getProjectSettings ? "projectSettings" : version );
if ( !capabilitiesDocument ) //capabilities xml not in cache. Create a new one
{
QgsDebugMsg( "Capabilities document not found in cache" );
QDomDocument doc;
try
{
doc = theServer->getCapabilities( version, getProjectSettings );
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
delete theRequestHandler;
delete theServer;
continue;
}
capabilitiesCache.insertCapabilitiesDocument( configFilePath, getProjectSettings ? "projectSettings" : version, &doc );
capabilitiesDocument = capabilitiesCache.searchCapabilitiesDocument( configFilePath, getProjectSettings ? "projectSettings" : version );
}
else
{
QgsDebugMsg( "Found capabilities document in cache" );
}
if ( capabilitiesDocument )
{
theRequestHandler->sendGetCapabilitiesResponse( *capabilitiesDocument );
}
delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "GetMap", Qt::CaseInsensitive ) == 0 )
{
QImage* result = 0;
try
{
result = theServer->getMap();
}
catch ( QgsMapServiceException& ex )
{
QgsDebugMsg( "Caught exception during GetMap request" );
theRequestHandler->sendServiceException( ex );
delete theRequestHandler;
delete theServer;
continue;
}
if ( result )
{
QgsDebugMsg( "Sending GetMap response" );
theRequestHandler->sendGetMapResponse( serviceString, result );
QgsDebugMsg( "Response sent" );
}
else
{
//do some error handling
QgsDebugMsg( "result image is 0" );
}
delete result;
delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "GetFeatureInfo", Qt::CaseInsensitive ) == 0 )
{
QDomDocument featureInfoDoc;
try
{
if ( theServer->getFeatureInfo( featureInfoDoc, version ) != 0 )
{
delete theRequestHandler;
delete theServer;
continue;
}
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
delete theRequestHandler;
delete theServer;
continue;
}
QString infoFormat = parameterMap.value( "INFO_FORMAT" );
theRequestHandler->sendGetFeatureInfoResponse( featureInfoDoc, infoFormat );
delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "GetContext", Qt::CaseInsensitive ) == 0 )
{
try
{
QDomDocument doc = theServer->getContext();
theRequestHandler->sendGetStyleResponse( doc );
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
}
delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "GetStyle", Qt::CaseInsensitive ) == 0 ) // GetStyle for compatibility with earlier QGIS versions
{
try
{
QDomDocument doc = theServer->getStyle();
theRequestHandler->sendGetStyleResponse( doc );
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
}
delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "GetStyles", Qt::CaseInsensitive ) == 0 )
{
// GetStyles is only defined for WMS1.1.1/SLD1.0
if ( version != "1.1.1" )
{
theRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "GetStyles method is only available in WMS version 1.1.1" ) );
}
else
{
try
{
QDomDocument doc = theServer->getStyles();
theRequestHandler->sendGetStyleResponse( doc );
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
}
}
delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "GetLegendGraphic", Qt::CaseInsensitive ) == 0 ||
request.compare( "GetLegendGraphics", Qt::CaseInsensitive ) == 0 )
// GetLegendGraphics for compatibility with earlier QGIS versions
{
QImage* result = 0;
try
{
result = theServer->getLegendGraphics();
}
catch ( QgsMapServiceException& ex )
{
QgsDebugMsg( "Caught exception during GetLegendGraphic request" );
theRequestHandler->sendServiceException( ex );
}
if ( result )
{
QgsDebugMsg( "Sending GetLegendGraphic response" );
//sending is the same for GetMap and GetLegendGraphic
theRequestHandler->sendGetMapResponse( serviceString, result );
QgsDebugMsg( "Response sent" );
}
else
{
//do some error handling
QgsDebugMsg( "result image is 0" );
}
delete result;
delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "GetPrint", Qt::CaseInsensitive ) == 0 )
{
QByteArray* printOutput = 0;
try
{
printOutput = theServer->getPrint( theRequestHandler->format() );
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
}
if ( printOutput )
{
theRequestHandler->sendGetPrintResponse( printOutput );
}
delete printOutput;
delete theRequestHandler;
delete theServer;
continue;
}
else//unknown request
{
QgsMapServiceException e( "OperationNotSupported", "Operation " + request + " not supported" );
theRequestHandler->sendServiceException( e );
delete theRequestHandler;
delete theServer;
} }
} }

View File

@ -0,0 +1,43 @@
/***************************************************************************
qgsowsserver.h
--------------
begin : March 24, 2014
copyright : (C) 2006 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSOWSSERVER_H
#define QGSOWSSERVER_H
#include "qgsconfigparser.h"
#include "qgsrequesthandler.h"
class QgsOWSServer
{
public:
QgsOWSServer( const QString& configFilePath, const QMap<QString, QString>& parameters, QgsConfigParser* cp, QgsRequestHandler* rh ):
mParameters( parameters ), mConfigParser( cp ), mRequestHandler( rh ), mConfigFilePath( configFilePath ) {}
virtual ~QgsOWSServer() { delete mRequestHandler; }
virtual void executeRequest() = 0;
private:
QgsOWSServer() {}
protected:
QMap<QString, QString> mParameters;
QgsConfigParser* mConfigParser;
QgsRequestHandler* mRequestHandler;
QString mConfigFilePath;
};
#endif // QGSOWSSERVER_H

View File

@ -36,9 +36,8 @@ static const QString WCS_NAMESPACE = "http://www.opengis.net/wcs";
static const QString GML_NAMESPACE = "http://www.opengis.net/gml"; static const QString GML_NAMESPACE = "http://www.opengis.net/gml";
static const QString OGC_NAMESPACE = "http://www.opengis.net/ogc"; static const QString OGC_NAMESPACE = "http://www.opengis.net/ogc";
QgsWCSServer::QgsWCSServer( QMap<QString, QString> parameters ) QgsWCSServer::QgsWCSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsConfigParser* cp,
: mParameterMap( parameters ) QgsRequestHandler* rh ): QgsOWSServer( configFilePath, parameters, cp, rh )
, mConfigParser( 0 )
{ {
} }
@ -46,10 +45,74 @@ QgsWCSServer::~QgsWCSServer()
{ {
} }
QgsWCSServer::QgsWCSServer() QgsWCSServer::QgsWCSServer(): QgsOWSServer( QString(), QMap<QString, QString>(), 0, 0 )
{ {
} }
void QgsWCSServer::executeRequest()
{
//request type
QString request = mParameters.value( "REQUEST" );
if ( request.isEmpty() )
{
//do some error handling
QgsDebugMsg( "unable to find 'REQUEST' parameter, exiting..." );
mRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
return;
}
if ( request.compare( "GetCapabilities", Qt::CaseInsensitive ) == 0 )
{
QDomDocument capabilitiesDocument;
try
{
capabilitiesDocument = getCapabilities();
}
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
return;
}
QgsDebugMsg( "sending GetCapabilities response" );
mRequestHandler->sendGetCapabilitiesResponse( capabilitiesDocument );
return;
}
else if ( request.compare( "DescribeCoverage", Qt::CaseInsensitive ) == 0 )
{
QDomDocument describeDocument;
try
{
describeDocument = describeCoverage();
}
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
return;
}
QgsDebugMsg( "sending GetCapabilities response" );
mRequestHandler->sendGetCapabilitiesResponse( describeDocument );
return;
}
else if ( request.compare( "GetCoverage", Qt::CaseInsensitive ) == 0 )
{
QByteArray* coverageOutput;
try
{
coverageOutput = getCoverage();
}
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
return;
}
if ( coverageOutput )
{
mRequestHandler->sendGetCoverageResponse( coverageOutput );
}
return;
}
}
QDomDocument QgsWCSServer::getCapabilities() QDomDocument QgsWCSServer::getCapabilities()
{ {
QgsDebugMsg( "Entering." ); QgsDebugMsg( "Entering." );
@ -153,15 +216,15 @@ QDomDocument QgsWCSServer::describeCoverage()
//defining coverage name //defining coverage name
QString coveName = ""; QString coveName = "";
//read COVERAGE //read COVERAGE
QMap<QString, QString>::const_iterator cove_name_it = mParameterMap.find( "COVERAGE" ); QMap<QString, QString>::const_iterator cove_name_it = mParameters.find( "COVERAGE" );
if ( cove_name_it != mParameterMap.end() ) if ( cove_name_it != mParameters.end() )
{ {
coveName = cove_name_it.value(); coveName = cove_name_it.value();
} }
if ( coveName == "" ) if ( coveName == "" )
{ {
QMap<QString, QString>::const_iterator cove_name_it = mParameterMap.find( "IDENTIFIER" ); QMap<QString, QString>::const_iterator cove_name_it = mParameters.find( "IDENTIFIER" );
if ( cove_name_it != mParameterMap.end() ) if ( cove_name_it != mParameters.end() )
{ {
coveName = cove_name_it.value(); coveName = cove_name_it.value();
} }
@ -181,15 +244,15 @@ QByteArray* QgsWCSServer::getCoverage()
//defining coverage name //defining coverage name
QString coveName = ""; QString coveName = "";
//read COVERAGE //read COVERAGE
QMap<QString, QString>::const_iterator cove_name_it = mParameterMap.find( "COVERAGE" ); QMap<QString, QString>::const_iterator cove_name_it = mParameters.find( "COVERAGE" );
if ( cove_name_it != mParameterMap.end() ) if ( cove_name_it != mParameters.end() )
{ {
coveName = cove_name_it.value(); coveName = cove_name_it.value();
} }
if ( coveName == "" ) if ( coveName == "" )
{ {
QMap<QString, QString>::const_iterator cove_name_it = mParameterMap.find( "IDENTIFIER" ); QMap<QString, QString>::const_iterator cove_name_it = mParameters.find( "IDENTIFIER" );
if ( cove_name_it != mParameterMap.end() ) if ( cove_name_it != mParameters.end() )
{ {
coveName = cove_name_it.value(); coveName = cove_name_it.value();
} }
@ -216,8 +279,8 @@ QByteArray* QgsWCSServer::getCoverage()
QString crs = ""; QString crs = "";
// read BBOX // read BBOX
QMap<QString, QString>::const_iterator bbIt = mParameterMap.find( "BBOX" ); QMap<QString, QString>::const_iterator bbIt = mParameters.find( "BBOX" );
if ( bbIt == mParameterMap.end() ) if ( bbIt == mParameters.end() )
{ {
minx = 0; miny = 0; maxx = 0; maxy = 0; minx = 0; miny = 0; maxx = 0; maxy = 0;
} }
@ -240,11 +303,11 @@ QByteArray* QgsWCSServer::getCoverage()
} }
// read WIDTH // read WIDTH
width = mParameterMap.value( "WIDTH", "0" ).toInt( &conversionSuccess ); width = mParameters.value( "WIDTH", "0" ).toInt( &conversionSuccess );
if ( !conversionSuccess ) if ( !conversionSuccess )
width = 0; width = 0;
// read HEIGHT // read HEIGHT
height = mParameterMap.value( "HEIGHT", "0" ).toInt( &conversionSuccess ); height = mParameters.value( "HEIGHT", "0" ).toInt( &conversionSuccess );
if ( !conversionSuccess ) if ( !conversionSuccess )
{ {
height = 0; height = 0;
@ -255,7 +318,7 @@ QByteArray* QgsWCSServer::getCoverage()
mErrors << QString( "The WIDTH and HEIGHT are mandatory and have to be integer" ); mErrors << QString( "The WIDTH and HEIGHT are mandatory and have to be integer" );
} }
crs = mParameterMap.value( "CRS", "" ); crs = mParameters.value( "CRS", "" );
if ( crs == "" ) if ( crs == "" )
{ {
mErrors << QString( "The CRS is mandatory" ); mErrors << QString( "The CRS is mandatory" );
@ -281,7 +344,7 @@ QByteArray* QgsWCSServer::getCoverage()
{ {
// RESPONSE_CRS // RESPONSE_CRS
QgsCoordinateReferenceSystem responseCRS = rLayer->crs(); QgsCoordinateReferenceSystem responseCRS = rLayer->crs();
crs = mParameterMap.value( "RESPONSE_CRS", "" ); crs = mParameters.value( "RESPONSE_CRS", "" );
if ( crs != "" ) if ( crs != "" )
{ {
responseCRS = QgsCRSCache::instance()->crsByAuthId( crs ); responseCRS = QgsCRSCache::instance()->crsByAuthId( crs );

View File

@ -23,6 +23,7 @@
#include <QString> #include <QString>
#include <map> #include <map>
#include "qgis.h" #include "qgis.h"
#include "qgsowsserver.h"
class QgsConfigParser; class QgsConfigParser;
class QgsRequestHandler; class QgsRequestHandler;
@ -31,12 +32,16 @@ class QgsRequestHandler;
a map<QString, QString>. This map is usually generated by a subclass of QgsWMSRequestHandler, which makes QgsWCSServer a map<QString, QString>. This map is usually generated by a subclass of QgsWMSRequestHandler, which makes QgsWCSServer
independent from any server side technology*/ independent from any server side technology*/
class QgsWCSServer class QgsWCSServer: public QgsOWSServer
{ {
public: public:
/**Constructor. Takes parameter map and a pointer to a renderer object (does not take ownership)*/ /**Constructor. Takes parameter map and a pointer to a renderer object (does not take ownership)*/
QgsWCSServer( QMap<QString, QString> parameters ); QgsWCSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsConfigParser* cp,
QgsRequestHandler* rh );
~QgsWCSServer(); ~QgsWCSServer();
void executeRequest();
/**Returns an XML file with the capabilities description (as described in the WFS specs)*/ /**Returns an XML file with the capabilities description (as described in the WFS specs)*/
QDomDocument getCapabilities(); QDomDocument getCapabilities();
@ -55,10 +60,6 @@ class QgsWCSServer
/**Get service address from REQUEST_URI if not specified in the configuration*/ /**Get service address from REQUEST_URI if not specified in the configuration*/
QString serviceUrl() const; QString serviceUrl() const;
/**Map containing the WMS parameters*/
QMap<QString, QString> mParameterMap;
QgsConfigParser* mConfigParser;
}; };
#endif #endif

View File

@ -66,9 +66,8 @@ static const QString GML_NAMESPACE = "http://www.opengis.net/gml";
static const QString OGC_NAMESPACE = "http://www.opengis.net/ogc"; static const QString OGC_NAMESPACE = "http://www.opengis.net/ogc";
static const QString QGS_NAMESPACE = "http://www.qgis.org/gml"; static const QString QGS_NAMESPACE = "http://www.qgis.org/gml";
QgsWFSServer::QgsWFSServer( QMap<QString, QString> parameters ) QgsWFSServer::QgsWFSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsConfigParser* cp,
: mParameterMap( parameters ) QgsRequestHandler* rh ): QgsOWSServer( configFilePath, parameters, cp, rh )
, mConfigParser( 0 )
{ {
} }
@ -76,10 +75,92 @@ QgsWFSServer::~QgsWFSServer()
{ {
} }
QgsWFSServer::QgsWFSServer() QgsWFSServer::QgsWFSServer(): QgsOWSServer( QString(), QMap<QString, QString>(), 0, 0 )
{ {
} }
void QgsWFSServer::executeRequest()
{
if ( !mConfigParser && !mRequestHandler )
{
return;
}
//request type
QString request = mParameters.value( "REQUEST" );
if ( request.isEmpty() )
{
//do some error handling
QgsDebugMsg( "unable to find 'REQUEST' parameter, exiting..." );
mRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
return;
}
if ( request.compare( "GetCapabilities", Qt::CaseInsensitive ) == 0 )
{
QDomDocument capabilitiesDocument;
try
{
capabilitiesDocument = getCapabilities();
}
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
return;
}
QgsDebugMsg( "sending GetCapabilities response" );
mRequestHandler->sendGetCapabilitiesResponse( capabilitiesDocument );
return;
}
else if ( request.compare( "DescribeFeatureType", Qt::CaseInsensitive ) == 0 )
{
QDomDocument describeDocument;
try
{
describeDocument = describeFeatureType();
}
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
return;
}
QgsDebugMsg( "sending GetCapabilities response" );
mRequestHandler->sendGetCapabilitiesResponse( describeDocument );
return;
}
else if ( request.compare( "GetFeature", Qt::CaseInsensitive ) == 0 )
{
//output format for GetFeature
QString outputFormat = mParameters.value( "OUTPUTFORMAT" );
try
{
getFeature( *mRequestHandler, outputFormat );
}
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
}
return;
}
else if ( request.compare( "Transaction", Qt::CaseInsensitive ) == 0 )
{
QDomDocument transactionDocument;
try
{
transactionDocument = transaction( mParameters.value( "REQUEST_BODY" ) );
}
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
return;
}
QgsDebugMsg( "sending Transaction response" );
mRequestHandler->sendGetCapabilitiesResponse( transactionDocument );
return;
}
}
QDomDocument QgsWFSServer::getCapabilities() QDomDocument QgsWFSServer::getCapabilities()
{ {
QgsDebugMsg( "Entering." ); QgsDebugMsg( "Entering." );
@ -246,7 +327,7 @@ QDomDocument QgsWFSServer::describeFeatureType()
QDomDocument queryDoc; QDomDocument queryDoc;
QString errorMsg; QString errorMsg;
if ( queryDoc.setContent( mParameterMap.value( "REQUEST_BODY" ), true, &errorMsg ) ) if ( queryDoc.setContent( mParameters.value( "REQUEST_BODY" ), true, &errorMsg ) )
{ {
//read doc //read doc
QDomElement queryDocElem = queryDoc.documentElement(); QDomElement queryDocElem = queryDoc.documentElement();
@ -270,8 +351,8 @@ QDomDocument QgsWFSServer::describeFeatureType()
else else
{ {
//read TYPENAME //read TYPENAME
QMap<QString, QString>::const_iterator type_name_it = mParameterMap.find( "TYPENAME" ); QMap<QString, QString>::const_iterator type_name_it = mParameters.find( "TYPENAME" );
if ( type_name_it != mParameterMap.end() ) if ( type_name_it != mParameters.end() )
{ {
typeName = type_name_it.value(); typeName = type_name_it.value();
} }
@ -300,7 +381,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
QDomDocument doc; QDomDocument doc;
QString errorMsg; QString errorMsg;
if ( doc.setContent( mParameterMap.value( "REQUEST_BODY" ), true, &errorMsg ) ) if ( doc.setContent( mParameters.value( "REQUEST_BODY" ), true, &errorMsg ) )
{ {
QDomElement docElem = doc.documentElement(); QDomElement docElem = doc.documentElement();
@ -562,8 +643,8 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
//read FEATUREDID //read FEATUREDID
bool featureIdOk = false; bool featureIdOk = false;
QStringList featureIdList; QStringList featureIdList;
QMap<QString, QString>::const_iterator feature_id_it = mParameterMap.find( "FEATUREID" ); QMap<QString, QString>::const_iterator feature_id_it = mParameters.find( "FEATUREID" );
if ( feature_id_it != mParameterMap.end() ) if ( feature_id_it != mParameters.end() )
{ {
featureIdOk = true; featureIdOk = true;
featureIdList = feature_id_it.value().split( "," ); featureIdList = feature_id_it.value().split( "," );
@ -585,8 +666,8 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
if ( !featureIdOk ) if ( !featureIdOk )
{ {
//read TYPENAME //read TYPENAME
QMap<QString, QString>::const_iterator type_name_it = mParameterMap.find( "TYPENAME" ); QMap<QString, QString>::const_iterator type_name_it = mParameters.find( "TYPENAME" );
if ( type_name_it != mParameterMap.end() ) if ( type_name_it != mParameters.end() )
{ {
mTypeName = type_name_it.value(); mTypeName = type_name_it.value();
} }
@ -596,8 +677,8 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
} }
//read FILTER //read FILTER
QMap<QString, QString>::const_iterator filterIt = mParameterMap.find( "FILTER" ); QMap<QString, QString>::const_iterator filterIt = mParameters.find( "FILTER" );
if ( filterIt != mParameterMap.end() ) if ( filterIt != mParameters.end() )
{ {
QString errorMsg; QString errorMsg;
if ( !filter.setContent( filterIt.value(), true, &errorMsg ) ) if ( !filter.setContent( filterIt.value(), true, &errorMsg ) )
@ -613,8 +694,8 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
//read EXP_FILTER //read EXP_FILTER
if ( !filterOk ) if ( !filterOk )
{ {
QMap<QString, QString>::const_iterator expFilterIt = mParameterMap.find( "EXP_FILTER" ); QMap<QString, QString>::const_iterator expFilterIt = mParameters.find( "EXP_FILTER" );
if ( expFilterIt != mParameterMap.end() ) if ( expFilterIt != mParameters.end() )
{ {
expFilterOk = true; expFilterOk = true;
expFilter = expFilterIt.value(); expFilter = expFilterIt.value();
@ -624,8 +705,8 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
//read BBOX //read BBOX
if ( !filterOk ) if ( !filterOk )
{ {
QMap<QString, QString>::const_iterator bbIt = mParameterMap.find( "BBOX" ); QMap<QString, QString>::const_iterator bbIt = mParameters.find( "BBOX" );
if ( bbIt == mParameterMap.end() ) if ( bbIt == mParameters.end() )
{ {
minx = 0; miny = 0; maxx = 0; maxy = 0; minx = 0; miny = 0; maxx = 0; maxy = 0;
} }
@ -647,8 +728,8 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
} }
//read MAXFEATURES //read MAXFEATURES
QMap<QString, QString>::const_iterator mfIt = mParameterMap.find( "MAXFEATURES" ); QMap<QString, QString>::const_iterator mfIt = mParameters.find( "MAXFEATURES" );
if ( mfIt != mParameterMap.end() ) if ( mfIt != mParameters.end() )
{ {
QString mfString = mfIt.value(); QString mfString = mfIt.value();
bool mfOk; bool mfOk;
@ -659,8 +740,8 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
//read PROPERTYNAME //read PROPERTYNAME
mWithGeom = true; mWithGeom = true;
mPropertyName = "*"; mPropertyName = "*";
QMap<QString, QString>::const_iterator pnIt = mParameterMap.find( "PROPERTYNAME" ); QMap<QString, QString>::const_iterator pnIt = mParameters.find( "PROPERTYNAME" );
if ( pnIt != mParameterMap.end() ) if ( pnIt != mParameters.end() )
{ {
mPropertyName = pnIt.value(); mPropertyName = pnIt.value();
} }

View File

@ -23,6 +23,7 @@
#include <QString> #include <QString>
#include <map> #include <map>
#include "qgis.h" #include "qgis.h"
#include "qgsowsserver.h"
#include "qgsvectorlayer.h" #include "qgsvectorlayer.h"
class QgsCoordinateReferenceSystem; class QgsCoordinateReferenceSystem;
@ -54,12 +55,16 @@ class QPainter;
a map<QString, QString>. This map is usually generated by a subclass of QgsWMSRequestHandler, which makes QgsWFSServer a map<QString, QString>. This map is usually generated by a subclass of QgsWMSRequestHandler, which makes QgsWFSServer
independent from any server side technology*/ independent from any server side technology*/
class QgsWFSServer class QgsWFSServer: public QgsOWSServer
{ {
public: public:
/**Constructor. Takes parameter map and a pointer to a renderer object (does not take ownership)*/ /**Constructor. Takes parameter map and a pointer to a renderer object (does not take ownership)*/
QgsWFSServer( QMap<QString, QString> parameters ); QgsWFSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsConfigParser* cp,
QgsRequestHandler* rh );
~QgsWFSServer(); ~QgsWFSServer();
void executeRequest();
/**Returns an XML file with the capabilities description (as described in the WFS specs)*/ /**Returns an XML file with the capabilities description (as described in the WFS specs)*/
QDomDocument getCapabilities(); QDomDocument getCapabilities();
@ -84,9 +89,6 @@ class QgsWFSServer
/**Get service address from REQUEST_URI if not specified in the configuration*/ /**Get service address from REQUEST_URI if not specified in the configuration*/
QString serviceUrl() const; QString serviceUrl() const;
/**Map containing the WMS parameters*/
QMap<QString, QString> mParameterMap;
QgsConfigParser* mConfigParser;
/* The Type of Feature created */ /* The Type of Feature created */
QString mTypeName; QString mTypeName;
/* The list of Feature's Type requested */ /* The list of Feature's Type requested */

View File

@ -16,6 +16,7 @@
***************************************************************************/ ***************************************************************************/
#include "qgswmsserver.h" #include "qgswmsserver.h"
#include "qgscapabilitiescache.h"
#include "qgsconfigparser.h" #include "qgsconfigparser.h"
#include "qgscrscache.h" #include "qgscrscache.h"
#include "qgsfield.h" #include "qgsfield.h"
@ -56,10 +57,10 @@
#include <QUrl> #include <QUrl>
#include <QPaintEngine> #include <QPaintEngine>
QgsWMSServer::QgsWMSServer( QMap<QString, QString> parameters, QgsMapRenderer* renderer ) QgsWMSServer::QgsWMSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsConfigParser* cp,
: mParameterMap( parameters ) QgsRequestHandler* rh, QgsMapRenderer* renderer, QgsCapabilitiesCache* capCache )
, mConfigParser( 0 ) : QgsOWSServer( configFilePath, parameters, cp, rh )
, mMapRenderer( renderer ) , mMapRenderer( renderer ), mCapabilitiesCache( capCache )
{ {
} }
@ -67,10 +68,223 @@ QgsWMSServer::~QgsWMSServer()
{ {
} }
QgsWMSServer::QgsWMSServer() QgsWMSServer::QgsWMSServer(): QgsOWSServer( QString(), QMap<QString, QString>(), 0, 0 )
{ {
} }
void QgsWMSServer::executeRequest()
{
if ( !mMapRenderer || !mConfigParser || !mRequestHandler || !mCapabilitiesCache )
{
return; //todo: error handling
}
//request type
QString request = mParameters.value( "REQUEST" );
if ( request.isEmpty() )
{
QgsDebugMsg( "unable to find 'REQUEST' parameter, exiting..." );
mRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
return;
}
//version
QString version = mParameters.value( "VERSION", "1.3.0" );
bool getProjectSettings = ( request.compare( "GetProjectSettings", Qt::CaseInsensitive ) == 0 );
if ( getProjectSettings )
{
version = "1.3.0"; //getProjectSettings extends WMS 1.3.0 capabilities
}
//GetCapabilities
if ( request.compare( "GetCapabilities", Qt::CaseInsensitive ) == 0 || getProjectSettings )
{
const QDomDocument* capabilitiesDocument = mCapabilitiesCache->searchCapabilitiesDocument( mConfigFilePath, getProjectSettings ? "projectSettings" : version );
if ( !capabilitiesDocument ) //capabilities xml not in cache. Create a new one
{
QgsDebugMsg( "Capabilities document not found in cache" );
QDomDocument doc;
try
{
doc = getCapabilities( version, getProjectSettings );
}
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
return;
}
mCapabilitiesCache->insertCapabilitiesDocument( mConfigFilePath, getProjectSettings ? "projectSettings" : version, &doc );
capabilitiesDocument = mCapabilitiesCache->searchCapabilitiesDocument( mConfigFilePath, getProjectSettings ? "projectSettings" : version );
}
else
{
QgsDebugMsg( "Found capabilities document in cache" );
}
if ( capabilitiesDocument )
{
mRequestHandler->sendGetCapabilitiesResponse( *capabilitiesDocument );
}
return;
}
//GetMap
else if ( request.compare( "GetMap", Qt::CaseInsensitive ) == 0 )
{
QImage* result = 0;
try
{
result = getMap();
}
catch ( QgsMapServiceException& ex )
{
QgsDebugMsg( "Caught exception during GetMap request" );
mRequestHandler->sendServiceException( ex );
return;
}
if ( result )
{
QgsDebugMsg( "Sending GetMap response" );
mRequestHandler->sendGetMapResponse( "WMS", result );
QgsDebugMsg( "Response sent" );
}
else
{
//do some error handling
QgsDebugMsg( "result image is 0" );
}
delete result;
return;
}
//GetFeatureInfo
else if ( request.compare( "GetFeatureInfo", Qt::CaseInsensitive ) == 0 )
{
QDomDocument featureInfoDoc;
try
{
if ( getFeatureInfo( featureInfoDoc, version ) != 0 )
{
return;
}
}
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
return;
}
QString infoFormat = mParameters.value( "INFO_FORMAT" );
mRequestHandler->sendGetFeatureInfoResponse( featureInfoDoc, infoFormat );
return;
}
//GetContext
else if ( request.compare( "GetContext", Qt::CaseInsensitive ) == 0 )
{
try
{
QDomDocument doc = getContext();
mRequestHandler->sendGetStyleResponse( doc );
}
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
}
return;
}
//GetStyle for compatibility with earlier QGIS versions
else if ( request.compare( "GetStyle", Qt::CaseInsensitive ) == 0 )
{
try
{
QDomDocument doc = getStyle();
mRequestHandler->sendGetStyleResponse( doc );
}
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
}
return;
}
//GetStyles
else if ( request.compare( "GetStyles", Qt::CaseInsensitive ) == 0 )
{
// GetStyles is only defined for WMS1.1.1/SLD1.0
if ( version != "1.1.1" )
{
mRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "GetStyles method is only available in WMS version 1.1.1" ) );
}
else
{
try
{
QDomDocument doc = getStyles();
mRequestHandler->sendGetStyleResponse( doc );
}
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
}
}
return;
}
//GetLegendGraphic
else if ( request.compare( "GetLegendGraphic", Qt::CaseInsensitive ) == 0 ||
request.compare( "GetLegendGraphics", Qt::CaseInsensitive ) == 0 )
// GetLegendGraphics for compatibility with earlier QGIS versions
{
QImage* result = 0;
try
{
result = getLegendGraphics();
}
catch ( QgsMapServiceException& ex )
{
QgsDebugMsg( "Caught exception during GetLegendGraphic request" );
mRequestHandler->sendServiceException( ex );
}
if ( result )
{
QgsDebugMsg( "Sending GetLegendGraphic response" );
//sending is the same for GetMap and GetLegendGraphic
mRequestHandler->sendGetMapResponse( "WMS", result );
QgsDebugMsg( "Response sent" );
}
else
{
//do some error handling
QgsDebugMsg( "result image is 0" );
}
return;
}
//GetPrint
else if ( request.compare( "GetPrint", Qt::CaseInsensitive ) == 0 )
{
QByteArray* printOutput = 0;
try
{
printOutput = getPrint( mRequestHandler->format() );
}
catch ( QgsMapServiceException& ex )
{
mRequestHandler->sendServiceException( ex );
}
if ( printOutput )
{
mRequestHandler->sendGetPrintResponse( printOutput );
}
delete printOutput;
return;
}
else//unknown request
{
QgsMapServiceException e( "OperationNotSupported", "Operation " + request + " not supported" );
mRequestHandler->sendServiceException( e );
return;
}
}
void QgsWMSServer::appendFormats( QDomDocument &doc, QDomElement &elem, const QStringList &formats ) void QgsWMSServer::appendFormats( QDomDocument &doc, QDomElement &elem, const QStringList &formats )
{ {
foreach ( QString format, formats ) foreach ( QString format, formats )
@ -138,8 +352,8 @@ QDomDocument QgsWMSServer::getCapabilities( QString version, bool fullProjectInf
// SOAP platform // SOAP platform
//only give this information if it is not a WMS request to be in sync with the WMS capabilities schema //only give this information if it is not a WMS request to be in sync with the WMS capabilities schema
QMap<QString, QString>::const_iterator service_it = mParameterMap.find( "SERVICE" ); QMap<QString, QString>::const_iterator service_it = mParameters.find( "SERVICE" );
if ( service_it != mParameterMap.end() && service_it.value().compare( "WMS", Qt::CaseInsensitive ) != 0 ) if ( service_it != mParameters.end() && service_it.value().compare( "WMS", Qt::CaseInsensitive ) != 0 )
{ {
QDomElement soapElement = doc.createElement( "SOAP"/*wms:SOAP*/ ); QDomElement soapElement = doc.createElement( "SOAP"/*wms:SOAP*/ );
httpElement.appendChild( soapElement ); httpElement.appendChild( soapElement );
@ -291,11 +505,11 @@ QImage* QgsWMSServer::getLegendGraphics()
{ {
return 0; return 0;
} }
if ( !mParameterMap.contains( "LAYER" ) && !mParameterMap.contains( "LAYERS" ) ) if ( !mParameters.contains( "LAYER" ) && !mParameters.contains( "LAYERS" ) )
{ {
throw QgsMapServiceException( "LayerNotSpecified", "LAYER is mandatory for GetLegendGraphic operation" ); throw QgsMapServiceException( "LayerNotSpecified", "LAYER is mandatory for GetLegendGraphic operation" );
} }
if ( !mParameterMap.contains( "FORMAT" ) ) if ( !mParameters.contains( "FORMAT" ) )
{ {
throw QgsMapServiceException( "FormatNotSpecified", "FORMAT is mandatory for GetLegendGraphic operation" ); throw QgsMapServiceException( "FormatNotSpecified", "FORMAT is mandatory for GetLegendGraphic operation" );
} }
@ -315,8 +529,8 @@ QImage* QgsWMSServer::getLegendGraphics()
//scale //scale
double scaleDenominator = -1; double scaleDenominator = -1;
QMap<QString, QString>::const_iterator scaleIt = mParameterMap.find( "SCALE" ); QMap<QString, QString>::const_iterator scaleIt = mParameters.find( "SCALE" );
if ( scaleIt != mParameterMap.constEnd() ) if ( scaleIt != mParameters.constEnd() )
{ {
bool conversionSuccess; bool conversionSuccess;
double scaleValue = scaleIt.value().toDouble( &conversionSuccess ); double scaleValue = scaleIt.value().toDouble( &conversionSuccess );
@ -352,13 +566,13 @@ QImage* QgsWMSServer::getLegendGraphics()
iconLabelSpace, symbolWidth, symbolHeight, layerFont, itemFont, layerFontColor, itemFontColor ); iconLabelSpace, symbolWidth, symbolHeight, layerFont, itemFont, layerFontColor, itemFontColor );
QString rule; QString rule;
QMap<QString, QString>::const_iterator ruleIt = mParameterMap.find( "RULE" ); QMap<QString, QString>::const_iterator ruleIt = mParameters.find( "RULE" );
if ( ruleIt != mParameterMap.constEnd() ) if ( ruleIt != mParameters.constEnd() )
{ {
rule = ruleIt.value(); rule = ruleIt.value();
QMap<QString, QString>::const_iterator widthIt = mParameterMap.find( "WIDTH" ); QMap<QString, QString>::const_iterator widthIt = mParameters.find( "WIDTH" );
if ( widthIt != mParameterMap.constEnd() ) if ( widthIt != mParameters.constEnd() )
{ {
bool conversionSuccess; bool conversionSuccess;
double width = widthIt.value().toDouble( &conversionSuccess ); double width = widthIt.value().toDouble( &conversionSuccess );
@ -368,8 +582,8 @@ QImage* QgsWMSServer::getLegendGraphics()
} }
} }
QMap<QString, QString>::const_iterator heightIt = mParameterMap.find( "HEIGHT" ); QMap<QString, QString>::const_iterator heightIt = mParameters.find( "HEIGHT" );
if ( heightIt != mParameterMap.constEnd() ) if ( heightIt != mParameters.constEnd() )
{ {
bool conversionSuccess; bool conversionSuccess;
double width = heightIt.value().toDouble( &conversionSuccess ); double width = heightIt.value().toDouble( &conversionSuccess );
@ -487,47 +701,47 @@ void QgsWMSServer::legendParameters( double mmToPixelFactor, double fontOversamp
QFont& layerFont, QFont& itemFont, QColor& layerFontColor, QColor& itemFontColor ) QFont& layerFont, QFont& itemFont, QColor& layerFontColor, QColor& itemFontColor )
{ {
//spaces between legend elements //spaces between legend elements
QMap<QString, QString>::const_iterator boxSpaceIt = mParameterMap.find( "BOXSPACE" ); QMap<QString, QString>::const_iterator boxSpaceIt = mParameters.find( "BOXSPACE" );
boxSpace = ( boxSpaceIt == mParameterMap.constEnd() ) ? mConfigParser->legendBoxSpace() * mmToPixelFactor : boxSpace = ( boxSpaceIt == mParameters.constEnd() ) ? mConfigParser->legendBoxSpace() * mmToPixelFactor :
boxSpaceIt.value().toDouble() * mmToPixelFactor; boxSpaceIt.value().toDouble() * mmToPixelFactor;
QMap<QString, QString>::const_iterator layerSpaceIt = mParameterMap.find( "LAYERSPACE" ); QMap<QString, QString>::const_iterator layerSpaceIt = mParameters.find( "LAYERSPACE" );
layerSpace = ( layerSpaceIt == mParameterMap.constEnd() ) ? mConfigParser->legendLayerSpace() * mmToPixelFactor : layerSpace = ( layerSpaceIt == mParameters.constEnd() ) ? mConfigParser->legendLayerSpace() * mmToPixelFactor :
layerSpaceIt.value().toDouble() * mmToPixelFactor; layerSpaceIt.value().toDouble() * mmToPixelFactor;
QMap<QString, QString>::const_iterator layerTitleSpaceIt = mParameterMap.find( "LAYERTITLESPACE" ); QMap<QString, QString>::const_iterator layerTitleSpaceIt = mParameters.find( "LAYERTITLESPACE" );
layerTitleSpace = ( layerTitleSpaceIt == mParameterMap.constEnd() ) ? mConfigParser->legendLayerTitleSpace() * mmToPixelFactor : layerTitleSpace = ( layerTitleSpaceIt == mParameters.constEnd() ) ? mConfigParser->legendLayerTitleSpace() * mmToPixelFactor :
layerTitleSpaceIt.value().toDouble() * mmToPixelFactor; layerTitleSpaceIt.value().toDouble() * mmToPixelFactor;
QMap<QString, QString>::const_iterator symbolSpaceIt = mParameterMap.find( "SYMBOLSPACE" ); QMap<QString, QString>::const_iterator symbolSpaceIt = mParameters.find( "SYMBOLSPACE" );
symbolSpace = ( symbolSpaceIt == mParameterMap.constEnd() ) ? mConfigParser->legendSymbolSpace() * mmToPixelFactor : symbolSpace = ( symbolSpaceIt == mParameters.constEnd() ) ? mConfigParser->legendSymbolSpace() * mmToPixelFactor :
symbolSpaceIt.value().toDouble() * mmToPixelFactor; symbolSpaceIt.value().toDouble() * mmToPixelFactor;
QMap<QString, QString>::const_iterator iconLabelSpaceIt = mParameterMap.find( "ICONLABELSPACE" ); QMap<QString, QString>::const_iterator iconLabelSpaceIt = mParameters.find( "ICONLABELSPACE" );
iconLabelSpace = ( iconLabelSpaceIt == mParameterMap.constEnd() ) ? mConfigParser->legendIconLabelSpace() * mmToPixelFactor : iconLabelSpace = ( iconLabelSpaceIt == mParameters.constEnd() ) ? mConfigParser->legendIconLabelSpace() * mmToPixelFactor :
iconLabelSpaceIt.value().toDouble() * mmToPixelFactor; iconLabelSpaceIt.value().toDouble() * mmToPixelFactor;
QMap<QString, QString>::const_iterator symbolWidthIt = mParameterMap.find( "SYMBOLWIDTH" ); QMap<QString, QString>::const_iterator symbolWidthIt = mParameters.find( "SYMBOLWIDTH" );
symbolWidth = ( symbolWidthIt == mParameterMap.constEnd() ) ? mConfigParser->legendSymbolWidth() * mmToPixelFactor : symbolWidth = ( symbolWidthIt == mParameters.constEnd() ) ? mConfigParser->legendSymbolWidth() * mmToPixelFactor :
symbolWidthIt.value().toDouble() * mmToPixelFactor; symbolWidthIt.value().toDouble() * mmToPixelFactor;
QMap<QString, QString>::const_iterator symbolHeightIt = mParameterMap.find( "SYMBOLHEIGHT" ); QMap<QString, QString>::const_iterator symbolHeightIt = mParameters.find( "SYMBOLHEIGHT" );
symbolHeight = ( symbolHeightIt == mParameterMap.constEnd() ) ? mConfigParser->legendSymbolHeight() * mmToPixelFactor : symbolHeight = ( symbolHeightIt == mParameters.constEnd() ) ? mConfigParser->legendSymbolHeight() * mmToPixelFactor :
symbolHeightIt.value().toDouble() * mmToPixelFactor; symbolHeightIt.value().toDouble() * mmToPixelFactor;
//font properties //font properties
layerFont = mConfigParser->legendLayerFont(); layerFont = mConfigParser->legendLayerFont();
QMap<QString, QString>::const_iterator layerFontFamilyIt = mParameterMap.find( "LAYERFONTFAMILY" ); QMap<QString, QString>::const_iterator layerFontFamilyIt = mParameters.find( "LAYERFONTFAMILY" );
if ( layerFontFamilyIt != mParameterMap.constEnd() ) if ( layerFontFamilyIt != mParameters.constEnd() )
{ {
layerFont.setFamily( layerFontFamilyIt.value() ); layerFont.setFamily( layerFontFamilyIt.value() );
} }
QMap<QString, QString>::const_iterator layerFontBoldIt = mParameterMap.find( "LAYERFONTBOLD" ); QMap<QString, QString>::const_iterator layerFontBoldIt = mParameters.find( "LAYERFONTBOLD" );
if ( layerFontBoldIt != mParameterMap.constEnd() ) if ( layerFontBoldIt != mParameters.constEnd() )
{ {
layerFont.setBold( layerFontBoldIt.value().compare( "TRUE" , Qt::CaseInsensitive ) == 0 ); layerFont.setBold( layerFontBoldIt.value().compare( "TRUE" , Qt::CaseInsensitive ) == 0 );
} }
QMap<QString, QString>::const_iterator layerFontItalicIt = mParameterMap.find( "LAYERFONTITALIC" ); QMap<QString, QString>::const_iterator layerFontItalicIt = mParameters.find( "LAYERFONTITALIC" );
if ( layerFontItalicIt != mParameterMap.constEnd() ) if ( layerFontItalicIt != mParameters.constEnd() )
{ {
layerFont.setItalic( layerFontItalicIt.value().compare( "TRUE", Qt::CaseInsensitive ) == 0 ); layerFont.setItalic( layerFontItalicIt.value().compare( "TRUE", Qt::CaseInsensitive ) == 0 );
} }
QMap<QString, QString>::const_iterator layerFontSizeIt = mParameterMap.find( "LAYERFONTSIZE" ); QMap<QString, QString>::const_iterator layerFontSizeIt = mParameters.find( "LAYERFONTSIZE" );
if ( layerFontSizeIt != mParameterMap.constEnd() ) if ( layerFontSizeIt != mParameters.constEnd() )
{ {
layerFont.setPixelSize( layerFontSizeIt.value().toDouble() * 0.3528 * mmToPixelFactor * fontOversamplingFactor ); layerFont.setPixelSize( layerFontSizeIt.value().toDouble() * 0.3528 * mmToPixelFactor * fontOversamplingFactor );
} }
@ -535,8 +749,8 @@ void QgsWMSServer::legendParameters( double mmToPixelFactor, double fontOversamp
{ {
layerFont.setPixelSize( layerFont.pointSizeF() * 0.3528 * mmToPixelFactor * fontOversamplingFactor ); layerFont.setPixelSize( layerFont.pointSizeF() * 0.3528 * mmToPixelFactor * fontOversamplingFactor );
} }
QMap<QString, QString>::const_iterator layerFontColorIt = mParameterMap.find( "LAYERFONTCOLOR" ); QMap<QString, QString>::const_iterator layerFontColorIt = mParameters.find( "LAYERFONTCOLOR" );
if ( layerFontColorIt != mParameterMap.constEnd() ) if ( layerFontColorIt != mParameters.constEnd() )
{ {
layerFontColor.setNamedColor( layerFontColorIt.value() ); layerFontColor.setNamedColor( layerFontColorIt.value() );
} }
@ -547,23 +761,23 @@ void QgsWMSServer::legendParameters( double mmToPixelFactor, double fontOversamp
itemFont = mConfigParser->legendItemFont(); itemFont = mConfigParser->legendItemFont();
QMap<QString, QString>::const_iterator itemFontFamilyIt = mParameterMap.find( "ITEMFONTFAMILY" ); QMap<QString, QString>::const_iterator itemFontFamilyIt = mParameters.find( "ITEMFONTFAMILY" );
if ( itemFontFamilyIt != mParameterMap.constEnd() ) if ( itemFontFamilyIt != mParameters.constEnd() )
{ {
itemFont.setFamily( itemFontFamilyIt.value() ); itemFont.setFamily( itemFontFamilyIt.value() );
} }
QMap<QString, QString>::const_iterator itemFontBoldIt = mParameterMap.find( "ITEMFONTBOLD" ); QMap<QString, QString>::const_iterator itemFontBoldIt = mParameters.find( "ITEMFONTBOLD" );
if ( itemFontBoldIt != mParameterMap.constEnd() ) if ( itemFontBoldIt != mParameters.constEnd() )
{ {
itemFont.setBold( itemFontBoldIt.value().compare( "TRUE" , Qt::CaseInsensitive ) == 0 ); itemFont.setBold( itemFontBoldIt.value().compare( "TRUE" , Qt::CaseInsensitive ) == 0 );
} }
QMap<QString, QString>::const_iterator itemFontItalicIt = mParameterMap.find( "ITEMFONTITALIC" ); QMap<QString, QString>::const_iterator itemFontItalicIt = mParameters.find( "ITEMFONTITALIC" );
if ( itemFontItalicIt != mParameterMap.constEnd() ) if ( itemFontItalicIt != mParameters.constEnd() )
{ {
itemFont.setItalic( itemFontItalicIt.value().compare( "TRUE", Qt::CaseInsensitive ) == 0 ); itemFont.setItalic( itemFontItalicIt.value().compare( "TRUE", Qt::CaseInsensitive ) == 0 );
} }
QMap<QString, QString>::const_iterator itemFontSizeIt = mParameterMap.find( "ITEMFONTSIZE" ); QMap<QString, QString>::const_iterator itemFontSizeIt = mParameters.find( "ITEMFONTSIZE" );
if ( itemFontSizeIt != mParameterMap.constEnd() ) if ( itemFontSizeIt != mParameters.constEnd() )
{ {
itemFont.setPixelSize( itemFontSizeIt.value().toDouble() * 0.3528 * mmToPixelFactor * fontOversamplingFactor ); itemFont.setPixelSize( itemFontSizeIt.value().toDouble() * 0.3528 * mmToPixelFactor * fontOversamplingFactor );
} }
@ -571,8 +785,8 @@ void QgsWMSServer::legendParameters( double mmToPixelFactor, double fontOversamp
{ {
itemFont.setPixelSize( itemFont.pointSizeF() * 0.3528 * mmToPixelFactor * fontOversamplingFactor ); itemFont.setPixelSize( itemFont.pointSizeF() * 0.3528 * mmToPixelFactor * fontOversamplingFactor );
} }
QMap<QString, QString>::const_iterator itemFontColorIt = mParameterMap.find( "ITEMFONTCOLOR" ); QMap<QString, QString>::const_iterator itemFontColorIt = mParameters.find( "ITEMFONTCOLOR" );
if ( itemFontColorIt != mParameterMap.constEnd() ) if ( itemFontColorIt != mParameters.constEnd() )
{ {
itemFontColor.setNamedColor( itemFontColorIt.value() ); itemFontColor.setNamedColor( itemFontColorIt.value() );
} }
@ -585,18 +799,18 @@ void QgsWMSServer::legendParameters( double mmToPixelFactor, double fontOversamp
QDomDocument QgsWMSServer::getStyle() QDomDocument QgsWMSServer::getStyle()
{ {
QDomDocument doc; QDomDocument doc;
if ( !mParameterMap.contains( "STYLE" ) ) if ( !mParameters.contains( "STYLE" ) )
{ {
throw QgsMapServiceException( "StyleNotSpecified", "Style is mandatory for GetStyle operation" ); throw QgsMapServiceException( "StyleNotSpecified", "Style is mandatory for GetStyle operation" );
} }
if ( !mParameterMap.contains( "LAYER" ) ) if ( !mParameters.contains( "LAYER" ) )
{ {
throw QgsMapServiceException( "LayerNotSpecified", "Layer is mandatory for GetStyle operation" ); throw QgsMapServiceException( "LayerNotSpecified", "Layer is mandatory for GetStyle operation" );
} }
QString styleName = mParameterMap[ "STYLE" ]; QString styleName = mParameters[ "STYLE" ];
QString layerName = mParameterMap[ "LAYER" ]; QString layerName = mParameters[ "LAYER" ];
return mConfigParser->getStyle( styleName, layerName ); return mConfigParser->getStyle( styleName, layerName );
} }
@ -605,12 +819,12 @@ QDomDocument QgsWMSServer::getStyle()
QDomDocument QgsWMSServer::getStyles() QDomDocument QgsWMSServer::getStyles()
{ {
QDomDocument doc; QDomDocument doc;
if ( !mParameterMap.contains( "LAYERS" ) ) if ( !mParameters.contains( "LAYERS" ) )
{ {
throw QgsMapServiceException( "LayerNotSpecified", "Layers is mandatory for GetStyles operation" ); throw QgsMapServiceException( "LayerNotSpecified", "Layers is mandatory for GetStyles operation" );
} }
QStringList layersList = mParameterMap[ "LAYERS" ].split( ",", QString::SkipEmptyParts ); QStringList layersList = mParameters[ "LAYERS" ].split( ",", QString::SkipEmptyParts );
if ( layersList.size() < 1 ) if ( layersList.size() < 1 )
{ {
throw QgsMapServiceException( "LayerNotSpecified", "Layers is mandatory for GetStyles operation" ); throw QgsMapServiceException( "LayerNotSpecified", "Layers is mandatory for GetStyles operation" );
@ -634,7 +848,7 @@ QByteArray* QgsWMSServer::getPrint( const QString& formatString )
QStringList selectedLayerIdList = applyFeatureSelections( layersList ); QStringList selectedLayerIdList = applyFeatureSelections( layersList );
//GetPrint request needs a template parameter //GetPrint request needs a template parameter
if ( !mParameterMap.contains( "TEMPLATE" ) ) if ( !mParameters.contains( "TEMPLATE" ) )
{ {
throw QgsMapServiceException( "ParameterMissing", "The TEMPLATE parameter is required for the GetPrint request" ); throw QgsMapServiceException( "ParameterMissing", "The TEMPLATE parameter is required for the GetPrint request" );
} }
@ -647,7 +861,7 @@ QByteArray* QgsWMSServer::getPrint( const QString& formatString )
applyOpacities( layersList, bkVectorRenderers, bkRasterRenderers, labelTransparencies, labelBufferTransparencies ); applyOpacities( layersList, bkVectorRenderers, bkRasterRenderers, labelTransparencies, labelBufferTransparencies );
QgsComposition* c = mConfigParser->createPrintComposition( mParameterMap[ "TEMPLATE" ], mMapRenderer, QMap<QString, QString>( mParameterMap ) ); QgsComposition* c = mConfigParser->createPrintComposition( mParameters[ "TEMPLATE" ], mMapRenderer, QMap<QString, QString>( mParameters ) );
if ( !c ) if ( !c )
{ {
restoreLayerFilters( originalLayerFilters ); restoreLayerFilters( originalLayerFilters );
@ -792,7 +1006,7 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
QStringList layersList, stylesList; QStringList layersList, stylesList;
bool conversionSuccess; bool conversionSuccess;
for ( QMap<QString, QString>::iterator it = mParameterMap.begin(); it != mParameterMap.end(); ++it ) for ( QMap<QString, QString>::iterator it = mParameters.begin(); it != mParameters.end(); ++it )
{ {
QgsDebugMsg( QString( "%1 // %2" ).arg( it.key() ).arg( it.value() ) ); QgsDebugMsg( QString( "%1 // %2" ).arg( it.key() ).arg( it.value() ) );
} }
@ -831,9 +1045,9 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
//read FEATURE_COUNT //read FEATURE_COUNT
int featureCount = 1; int featureCount = 1;
if ( mParameterMap.contains( "FEATURE_COUNT" ) ) if ( mParameters.contains( "FEATURE_COUNT" ) )
{ {
featureCount = mParameterMap[ "FEATURE_COUNT" ].toInt( &conversionSuccess ); featureCount = mParameters[ "FEATURE_COUNT" ].toInt( &conversionSuccess );
if ( !conversionSuccess ) if ( !conversionSuccess )
{ {
featureCount = 1; featureCount = 1;
@ -841,26 +1055,26 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
} }
//read QUERY_LAYERS //read QUERY_LAYERS
if ( !mParameterMap.contains( "QUERY_LAYERS" ) ) if ( !mParameters.contains( "QUERY_LAYERS" ) )
{ {
return 3; return 3;
} }
QStringList queryLayerList = mParameterMap[ "QUERY_LAYERS" ].split( ",", QString::SkipEmptyParts ); QStringList queryLayerList = mParameters[ "QUERY_LAYERS" ].split( ",", QString::SkipEmptyParts );
if ( queryLayerList.size() < 1 ) if ( queryLayerList.size() < 1 )
{ {
return 4; return 4;
} }
//read I,J resp. X,Y //read I,J resp. X,Y
QString iString = mParameterMap.value( "I", mParameterMap.value( "X" ) ); QString iString = mParameters.value( "I", mParameters.value( "X" ) );
int i = iString.toInt( &conversionSuccess ); int i = iString.toInt( &conversionSuccess );
if ( !conversionSuccess ) if ( !conversionSuccess )
{ {
i = -1; i = -1;
} }
QString jString = mParameterMap.value( "J", mParameterMap.value( "Y" ) ); QString jString = mParameters.value( "J", mParameters.value( "Y" ) );
int j = jString.toInt( &conversionSuccess ); int j = jString.toInt( &conversionSuccess );
if ( !conversionSuccess ) if ( !conversionSuccess )
{ {
@ -874,7 +1088,7 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
QgsPoint* infoPoint = 0; QgsPoint* infoPoint = 0;
if ( i == -1 || j == -1 ) if ( i == -1 || j == -1 )
{ {
if ( mParameterMap.contains( "FILTER" ) ) if ( mParameters.contains( "FILTER" ) )
{ {
featuresRect = new QgsRectangle(); featuresRect = new QgsRectangle();
} }
@ -893,7 +1107,7 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
QMap<QString, QString> originalLayerFilters = applyRequestedLayerFilters( layersList ); QMap<QString, QString> originalLayerFilters = applyRequestedLayerFilters( layersList );
QDomElement getFeatureInfoElement; QDomElement getFeatureInfoElement;
QString infoFormat = mParameterMap.value( "INFO_FORMAT" ); QString infoFormat = mParameters.value( "INFO_FORMAT" );
if ( infoFormat.startsWith( "application/vnd.ogc.gml" ) ) if ( infoFormat.startsWith( "application/vnd.ogc.gml" ) )
{ {
getFeatureInfoElement = result.createElement( "wfs:FeatureCollection" ); getFeatureInfoElement = result.createElement( "wfs:FeatureCollection" );
@ -1106,7 +1320,7 @@ QImage* QgsWMSServer::initializeRendering( QStringList& layersList, QStringList&
return 0; return 0;
} }
//pass external GML to the SLD parser. //pass external GML to the SLD parser.
QString gml = mParameterMap.value( "GML" ); QString gml = mParameters.value( "GML" );
if ( !gml.isEmpty() ) if ( !gml.isEmpty() )
{ {
QDomDocument* gmlDoc = new QDomDocument(); QDomDocument* gmlDoc = new QDomDocument();
@ -1155,14 +1369,14 @@ QImage* QgsWMSServer::createImage( int width, int height ) const
if ( width < 0 ) if ( width < 0 )
{ {
width = mParameterMap.value( "WIDTH", "0" ).toInt( &conversionSuccess ); width = mParameters.value( "WIDTH", "0" ).toInt( &conversionSuccess );
if ( !conversionSuccess ) if ( !conversionSuccess )
width = 0; width = 0;
} }
if ( height < 0 ) if ( height < 0 )
{ {
height = mParameterMap.value( "HEIGHT", "0" ).toInt( &conversionSuccess ); height = mParameters.value( "HEIGHT", "0" ).toInt( &conversionSuccess );
if ( !conversionSuccess ) if ( !conversionSuccess )
{ {
height = 0; height = 0;
@ -1177,13 +1391,13 @@ QImage* QgsWMSServer::createImage( int width, int height ) const
QImage* theImage = 0; QImage* theImage = 0;
//is format jpeg? //is format jpeg?
QString format = mParameterMap.value( "FORMAT" ); QString format = mParameters.value( "FORMAT" );
bool jpeg = format.compare( "jpg", Qt::CaseInsensitive ) == 0 bool jpeg = format.compare( "jpg", Qt::CaseInsensitive ) == 0
|| format.compare( "jpeg", Qt::CaseInsensitive ) == 0 || format.compare( "jpeg", Qt::CaseInsensitive ) == 0
|| format.compare( "image/jpeg", Qt::CaseInsensitive ) == 0; || format.compare( "image/jpeg", Qt::CaseInsensitive ) == 0;
//transparent parameter //transparent parameter
bool transparent = mParameterMap.value( "TRANSPARENT" ).compare( "true", Qt::CaseInsensitive ) == 0; bool transparent = mParameters.value( "TRANSPARENT" ).compare( "true", Qt::CaseInsensitive ) == 0;
//use alpha channel only if necessary because it slows down performance //use alpha channel only if necessary because it slows down performance
if ( transparent && !jpeg ) if ( transparent && !jpeg )
@ -1206,9 +1420,9 @@ QImage* QgsWMSServer::createImage( int width, int height ) const
//Because of backwards compatibility, this parameter is optional //Because of backwards compatibility, this parameter is optional
double OGC_PX_M = 0.00028; // OGC reference pixel size in meter, also used by qgis double OGC_PX_M = 0.00028; // OGC reference pixel size in meter, also used by qgis
int dpm = 1 / OGC_PX_M; int dpm = 1 / OGC_PX_M;
if ( mParameterMap.contains( "DPI" ) ) if ( mParameters.contains( "DPI" ) )
{ {
int dpi = mParameterMap[ "DPI" ].toInt( &conversionSuccess ); int dpi = mParameters[ "DPI" ].toInt( &conversionSuccess );
if ( conversionSuccess ) if ( conversionSuccess )
{ {
dpm = dpi / 0.0254; dpm = dpi / 0.0254;
@ -1232,7 +1446,7 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const
//map extent //map extent
bool conversionSuccess; bool conversionSuccess;
double minx, miny, maxx, maxy; double minx, miny, maxx, maxy;
QString bbString = mParameterMap.value( "BBOX", "0,0,0,0" ); QString bbString = mParameters.value( "BBOX", "0,0,0,0" );
bool bboxOk = true; bool bboxOk = true;
minx = bbString.section( ",", 0, 0 ).toDouble( &conversionSuccess ); minx = bbString.section( ",", 0, 0 ).toDouble( &conversionSuccess );
@ -1256,7 +1470,7 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const
QGis::UnitType mapUnits = QGis::Degrees; QGis::UnitType mapUnits = QGis::Degrees;
QString crs = mParameterMap.value( "CRS", mParameterMap.value( "SRS" ) ); QString crs = mParameters.value( "CRS", mParameters.value( "SRS" ) );
QgsCoordinateReferenceSystem outputCRS; QgsCoordinateReferenceSystem outputCRS;
@ -1300,7 +1514,7 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const
mMapRenderer->setMapUnits( mapUnits ); mMapRenderer->setMapUnits( mapUnits );
// Change x- and y- of BBOX for WMS 1.3.0 if axis inverted // Change x- and y- of BBOX for WMS 1.3.0 if axis inverted
QString version = mParameterMap.value( "VERSION", "1.3.0" ); QString version = mParameters.value( "VERSION", "1.3.0" );
if ( version != "1.1.1" && outputCRS.axisInverted() ) if ( version != "1.1.1" && outputCRS.axisInverted() )
{ {
//switch coordinates of extent //switch coordinates of extent
@ -1329,17 +1543,17 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const
int QgsWMSServer::readLayersAndStyles( QStringList& layersList, QStringList& stylesList ) const int QgsWMSServer::readLayersAndStyles( QStringList& layersList, QStringList& stylesList ) const
{ {
//get layer and style lists from the parameters trying LAYERS and LAYER as well as STYLE and STYLES for GetLegendGraphic compatibility //get layer and style lists from the parameters trying LAYERS and LAYER as well as STYLE and STYLES for GetLegendGraphic compatibility
layersList = mParameterMap.value( "LAYER" ).split( ",", QString::SkipEmptyParts ); layersList = mParameters.value( "LAYER" ).split( ",", QString::SkipEmptyParts );
layersList = layersList + mParameterMap.value( "LAYERS" ).split( ",", QString::SkipEmptyParts ); layersList = layersList + mParameters.value( "LAYERS" ).split( ",", QString::SkipEmptyParts );
stylesList = mParameterMap.value( "STYLE" ).split( ",", QString::SkipEmptyParts ); stylesList = mParameters.value( "STYLE" ).split( ",", QString::SkipEmptyParts );
stylesList = stylesList + mParameterMap.value( "STYLES" ).split( ",", QString::SkipEmptyParts ); stylesList = stylesList + mParameters.value( "STYLES" ).split( ",", QString::SkipEmptyParts );
return 0; return 0;
} }
int QgsWMSServer::initializeSLDParser( QStringList& layersList, QStringList& stylesList ) int QgsWMSServer::initializeSLDParser( QStringList& layersList, QStringList& stylesList )
{ {
QString xml = mParameterMap.value( "SLD" ); QString xml = mParameters.value( "SLD" );
if ( !xml.isEmpty() ) if ( !xml.isEmpty() )
{ {
//ignore LAYERS and STYLES and take those information from the SLD //ignore LAYERS and STYLES and take those information from the SLD
@ -1356,7 +1570,7 @@ int QgsWMSServer::initializeSLDParser( QStringList& layersList, QStringList& sty
return 0; return 0;
} }
QgsSLDParser* userSLDParser = new QgsSLDParser( theDocument ); QgsSLDParser* userSLDParser = new QgsSLDParser( theDocument );
userSLDParser->setParameterMap( mParameterMap ); userSLDParser->setParameterMap( mParameters );
userSLDParser->setFallbackParser( mConfigParser ); userSLDParser->setFallbackParser( mConfigParser );
mConfigParser = userSLDParser; mConfigParser = userSLDParser;
//now replace the content of layersList and stylesList (if present) //now replace the content of layersList and stylesList (if present)
@ -1887,7 +2101,7 @@ QMap<QString, QString> QgsWMSServer::applyRequestedLayerFilters( const QStringLi
return filterMap; return filterMap;
} }
QString filterParameter = mParameterMap.value( "FILTER" ); QString filterParameter = mParameters.value( "FILTER" );
if ( !filterParameter.isEmpty() ) if ( !filterParameter.isEmpty() )
{ {
QStringList layerSplit = filterParameter.split( ";" ); QStringList layerSplit = filterParameter.split( ";" );
@ -2120,7 +2334,7 @@ QStringList QgsWMSServer::applyFeatureSelections( const QStringList& layerList )
return layersWithSelections; return layersWithSelections;
} }
QString selectionString = mParameterMap.value( "SELECTION" ); QString selectionString = mParameters.value( "SELECTION" );
if ( selectionString.isEmpty() ) if ( selectionString.isEmpty() )
{ {
return layersWithSelections; return layersWithSelections;
@ -2191,8 +2405,8 @@ void QgsWMSServer::applyOpacities( const QStringList& layerList, QList< QPair< Q
QList< QPair< QgsVectorLayer*, double > >& labelBufferTransparencies ) QList< QPair< QgsVectorLayer*, double > >& labelBufferTransparencies )
{ {
//get opacity list //get opacity list
QMap<QString, QString>::const_iterator opIt = mParameterMap.find( "OPACITIES" ); QMap<QString, QString>::const_iterator opIt = mParameters.find( "OPACITIES" );
if ( opIt == mParameterMap.constEnd() ) if ( opIt == mParameters.constEnd() )
{ {
return; return;
} }
@ -2313,8 +2527,8 @@ bool QgsWMSServer::checkMaximumWidthHeight() const
//test if maxWidth / maxHeight set and WIDTH / HEIGHT parameter is in the range //test if maxWidth / maxHeight set and WIDTH / HEIGHT parameter is in the range
if ( mConfigParser->maxWidth() != -1 ) if ( mConfigParser->maxWidth() != -1 )
{ {
QMap<QString, QString>::const_iterator widthIt = mParameterMap.find( "WIDTH" ); QMap<QString, QString>::const_iterator widthIt = mParameters.find( "WIDTH" );
if ( widthIt != mParameterMap.constEnd() ) if ( widthIt != mParameters.constEnd() )
{ {
if ( widthIt->toInt() > mConfigParser->maxWidth() ) if ( widthIt->toInt() > mConfigParser->maxWidth() )
{ {
@ -2324,8 +2538,8 @@ bool QgsWMSServer::checkMaximumWidthHeight() const
} }
if ( mConfigParser->maxHeight() != -1 ) if ( mConfigParser->maxHeight() != -1 )
{ {
QMap<QString, QString>::const_iterator heightIt = mParameterMap.find( "HEIGHT" ); QMap<QString, QString>::const_iterator heightIt = mParameters.find( "HEIGHT" );
if ( heightIt != mParameterMap.constEnd() ) if ( heightIt != mParameters.constEnd() )
{ {
if ( heightIt->toInt() > mConfigParser->maxHeight() ) if ( heightIt->toInt() > mConfigParser->maxHeight() )
{ {

View File

@ -18,12 +18,14 @@
#ifndef QGSWMSSERVER_H #ifndef QGSWMSSERVER_H
#define QGSWMSSERVER_H #define QGSWMSSERVER_H
#include "qgsowsserver.h"
#include <QDomDocument> #include <QDomDocument>
#include <QMap> #include <QMap>
#include <QPair> #include <QPair>
#include <QString> #include <QString>
#include <map> #include <map>
class QgsCapabilitiesCache;
class QgsCoordinateReferenceSystem; class QgsCoordinateReferenceSystem;
class QgsComposerLayerItem; class QgsComposerLayerItem;
class QgsComposerLegendItem; class QgsComposerLegendItem;
@ -52,12 +54,17 @@ class QStandardItem;
a map<QString, QString>. This map is usually generated by a subclass of QgsWMSRequestHandler, which makes QgsWMSServer a map<QString, QString>. This map is usually generated by a subclass of QgsWMSRequestHandler, which makes QgsWMSServer
independent from any server side technology*/ independent from any server side technology*/
class QgsWMSServer class QgsWMSServer: public QgsOWSServer
{ {
public: public:
/**Constructor. Takes parameter map and a pointer to a renderer object (does not take ownership)*/ /**Constructor. Takes ownership of QgsRequestHandler. Does _NOT_ take ownership of
QgsWMSServer( QMap<QString, QString> parameters, QgsMapRenderer* renderer ); QgsConfigParser, QgsCapabilitiesCache and QgsMapRenderer*/
QgsWMSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsConfigParser* cp, QgsRequestHandler* rh,
QgsMapRenderer* renderer, QgsCapabilitiesCache* capCache );
~QgsWMSServer(); ~QgsWMSServer();
void executeRequest();
/**Returns an XML file with the capabilities description (as described in the WMS specs) /**Returns an XML file with the capabilities description (as described in the WMS specs)
@param version WMS version (1.1.1 or 1.3.0) @param version WMS version (1.1.1 or 1.3.0)
@param fullProjectInformation If true: add extended project information (does not validate against WMS schema)*/ @param fullProjectInformation If true: add extended project information (does not validate against WMS schema)*/
@ -220,10 +227,10 @@ class QgsWMSServer
void convertFeatureInfoToSIA2045( QDomDocument& doc ); void convertFeatureInfoToSIA2045( QDomDocument& doc );
/**Map containing the WMS parameters*/ /**Map containing the WMS parameters*/
QMap<QString, QString> mParameterMap;
QgsConfigParser* mConfigParser;
QgsMapRenderer* mMapRenderer; QgsMapRenderer* mMapRenderer;
QgsCapabilitiesCache* mCapabilitiesCache;
QDomElement createFeatureGML( QDomElement createFeatureGML(
QgsFeature* feat, QgsFeature* feat,
QgsVectorLayer* layer, QgsVectorLayer* layer,