Skip to content

Commit e490991

Browse files
committedMar 27, 2014
Refactor configuration parsing and configuration cache
1 parent 99a8612 commit e490991

21 files changed

+3520
-45
lines changed
 

‎src/mapserver/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@ SET ( qgis_mapserv_SRCS
1717
qgis_map_serv.cpp
1818
qgscapabilitiescache.cpp
1919
qgsconfigcache.cpp
20-
qgsconfigparser.cpp
21-
qgsprojectparser.cpp
2220
qgshttprequesthandler.cpp
2321
qgsgetrequesthandler.cpp
2422
qgspostrequesthandler.cpp
2523
qgssoaprequesthandler.cpp
26-
qgssldparser.cpp
2724
qgswmsserver.cpp
2825
qgswfsserver.cpp
2926
qgswcsserver.cpp
@@ -43,6 +40,10 @@ SET ( qgis_mapserv_SRCS
4340
qgsremotedatasourcebuilder.cpp
4441
qgssentdatasourcebuilder.cpp
4542
qgsmsutils.cpp
43+
qgswcsprojectparser.cpp
44+
qgswfsprojectparser.cpp
45+
qgswmsprojectparser.cpp
46+
qgsserverprojectparser.cpp
4647
)
4748

4849
# SET (qgis_mapserv_UIS

‎src/mapserver/qgis_map_serv.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -312,16 +312,6 @@ int main( int argc, char * argv[] )
312312
//Config file path
313313
QString configFilePath = configPath( defaultConfigFilePath, parameterMap );
314314

315-
//Admin config parser
316-
QgsConfigParser* adminConfigParser = QgsConfigCache::instance()->searchConfiguration( configFilePath );
317-
if ( !adminConfigParser )
318-
{
319-
QgsDebugMsg( "parse error on config file " + configFilePath );
320-
theRequestHandler->sendServiceException( QgsMapServiceException( "", "Configuration file problem : perhaps you left off the .qgs extension?" ) );
321-
continue;
322-
}
323-
adminConfigParser->setParameterMap( parameterMap );
324-
325315
//Service parameter
326316
QString serviceString;
327317
paramIt = parameterMap.find( "SERVICE" );
@@ -338,18 +328,33 @@ int main( int argc, char * argv[] )
338328

339329
if ( serviceString == "WCS" )
340330
{
341-
QgsWCSServer wcsServer( configFilePath, parameterMap, adminConfigParser, theRequestHandler );
331+
QgsWCSProjectParser* p = QgsConfigCache::instance()->wcsConfiguration( configFilePath );
332+
if ( !p )
333+
{
334+
//error handling
335+
}
336+
QgsWCSServer wcsServer( configFilePath, parameterMap, p, theRequestHandler );
342337
wcsServer.executeRequest();
343338
}
344339
else if ( serviceString == "WFS" )
345340
{
346-
QgsWFSServer wfsServer( configFilePath, parameterMap, adminConfigParser, theRequestHandler );
341+
QgsWFSProjectParser* p = QgsConfigCache::instance()->wfsConfiguration( configFilePath );
342+
if ( !p )
343+
{
344+
//error handling
345+
}
346+
QgsWFSServer wfsServer( configFilePath, parameterMap, p, theRequestHandler );
347347
wfsServer.executeRequest();
348348
}
349349
else //WMS else
350350
{
351-
adminConfigParser->loadLabelSettings( theMapRenderer->labelingEngine() );
352-
QgsWMSServer wmsServer( configFilePath, parameterMap, adminConfigParser, theRequestHandler, theMapRenderer, &capabilitiesCache );
351+
QgsWMSConfigParser* p = QgsConfigCache::instance()->wmsConfiguration( configFilePath );
352+
if ( !p )
353+
{
354+
//error handling
355+
}
356+
//adminConfigParser->loadLabelSettings( theMapRenderer->labelingEngine() );
357+
QgsWMSServer wmsServer( configFilePath, parameterMap, p, theRequestHandler, theMapRenderer, &capabilitiesCache );
353358
wmsServer.executeRequest();
354359
}
355360
}

‎src/mapserver/qgsconfigcache.cpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,94 @@
1616
***************************************************************************/
1717

1818
#include "qgsconfigcache.h"
19+
#include "qgswcsprojectparser.h"
20+
#include "qgswfsprojectparser.h"
21+
#include "qgswmsprojectparser.h"
22+
23+
QgsConfigCache* QgsConfigCache::instance()
24+
{
25+
static QgsConfigCache mInstance;
26+
return &mInstance;
27+
}
28+
29+
QgsConfigCache::~QgsConfigCache()
30+
{
31+
}
32+
33+
QgsWCSProjectParser* QgsConfigCache::wcsConfiguration( const QString& filePath )
34+
{
35+
QgsWCSProjectParser* p = mWCSConfigCache.object( filePath );
36+
if ( p )
37+
{
38+
return p;
39+
}
40+
41+
QDomDocument* doc = xmlDocument( filePath );
42+
if ( !doc )
43+
{
44+
return 0;
45+
}
46+
p = new QgsWCSProjectParser( doc, filePath );
47+
mWCSConfigCache.insert( filePath, p );
48+
return p;
49+
}
50+
51+
QgsWFSProjectParser* QgsConfigCache::wfsConfiguration( const QString& filePath )
52+
{
53+
return 0; //todo...
54+
}
55+
56+
QgsWMSConfigParser* QgsConfigCache::wmsConfiguration( const QString& filePath )
57+
{
58+
QgsWMSConfigParser* p = mWMSConfigCache.object( filePath );
59+
60+
QDomDocument* doc = xmlDocument( filePath );
61+
if ( !doc )
62+
{
63+
return 0;
64+
}
65+
66+
//sld or QGIS project file?
67+
//is it an sld document or a qgis project file?
68+
QDomElement documentElem = doc->documentElement();
69+
if ( documentElem.tagName() == "StyledLayerDescriptor" )
70+
{
71+
}
72+
else
73+
{
74+
p = new QgsWMSProjectParser( doc, filePath );
75+
}
76+
77+
mWMSConfigCache.insert( filePath, p );
78+
return p;
79+
}
80+
81+
QDomDocument* QgsConfigCache::xmlDocument( const QString& filePath )
82+
{
83+
//first open file
84+
QFile configFile( filePath );
85+
if ( !configFile.exists() || !configFile.open( QIODevice::ReadOnly ) )
86+
{
87+
QgsDebugMsg( "File unreadable: " + filePath );
88+
return 0;
89+
}
90+
91+
//then create xml document
92+
QDomDocument* xmlDoc = new QDomDocument();
93+
QString errorMsg;
94+
int line, column;
95+
if ( !xmlDoc->setContent( &configFile, true, &errorMsg, &line, &column ) )
96+
{
97+
QgsDebugMsg( QString( "Parse error %1 at row %2, column %3 in %4 " )
98+
.arg( errorMsg ).arg( line ).arg( column ).arg( filePath ) );
99+
delete xmlDoc;
100+
return 0;
101+
}
102+
return xmlDoc;
103+
}
104+
105+
#if 0
106+
19107
#include "qgslogger.h"
20108
#include "qgsmslayercache.h"
21109
#include "qgsprojectfiletransform.h"
@@ -141,3 +229,5 @@ void QgsConfigCache::removeChangedEntry( const QString& path )
141229
}
142230
mFileSystemWatcher.removePath( path );
143231
}
232+
233+
#endif //0

‎src/mapserver/qgsconfigcache.h

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,40 @@
1818
#ifndef QGSCONFIGCACHE_H
1919
#define QGSCONFIGCACHE_H
2020

21+
#include <QCache>
22+
#include <QObject>
23+
24+
class QgsWCSProjectParser;
25+
class QgsWFSProjectParser;
26+
class QgsWMSConfigParser;
27+
28+
class QDomDocument;
29+
30+
class QgsConfigCache: public QObject
31+
{
32+
Q_OBJECT
33+
public:
34+
static QgsConfigCache* instance();
35+
~QgsConfigCache();
36+
37+
QgsWCSProjectParser* wcsConfiguration( const QString& filePath );
38+
QgsWFSProjectParser* wfsConfiguration( const QString& filePath );
39+
QgsWMSConfigParser* wmsConfiguration( const QString& filePath );
40+
41+
private:
42+
static QgsConfigCache* mInstance;
43+
44+
/**Returns xml document for project file / sld or 0 in case of errors*/
45+
QDomDocument* xmlDocument( const QString& filePath );
46+
47+
QCache<QString, QgsWMSConfigParser> mWMSConfigCache;
48+
QCache<QString, QgsWFSProjectParser> mWFSConfigCache;
49+
QCache<QString, QgsWCSProjectParser> mWCSConfigCache;
50+
};
51+
52+
53+
#if 0
54+
2155
#include <QFileSystemWatcher>
2256
#include <QHash>
2357
#include <QObject>
@@ -55,5 +89,5 @@ class QgsConfigCache: public QObject
5589
/**Removes changed entry from this cache*/
5690
void removeChangedEntry( const QString& path );
5791
};
58-
92+
#endif //0
5993
#endif // QGSCONFIGCACHE_H

‎src/mapserver/qgsowsserver.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
class QgsOWSServer
2525
{
2626
public:
27-
QgsOWSServer( const QString& configFilePath, const QMap<QString, QString>& parameters, QgsConfigParser* cp, QgsRequestHandler* rh ):
28-
mParameters( parameters ), mConfigParser( cp ), mRequestHandler( rh ), mConfigFilePath( configFilePath ) {}
27+
QgsOWSServer( const QString& configFilePath, const QMap<QString, QString>& parameters, QgsRequestHandler* rh ):
28+
mParameters( parameters ), mRequestHandler( rh ), mConfigFilePath( configFilePath ) {}
2929
virtual ~QgsOWSServer() { delete mRequestHandler; }
3030

3131
virtual void executeRequest() = 0;
@@ -35,7 +35,6 @@ class QgsOWSServer
3535

3636
protected:
3737
QMap<QString, QString> mParameters;
38-
QgsConfigParser* mConfigParser;
3938
QgsRequestHandler* mRequestHandler;
4039
QString mConfigFilePath;
4140
};

‎src/mapserver/qgsprojectparser.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class QgsProjectParser: public QgsConfigParser
3939
QgsProjectParser( QDomDocument* xmlDoc, const QString& filePath );
4040
virtual ~QgsProjectParser();
4141

42+
//WMS
4243
/**Adds layer and style specific capabilities elements to the parent node. This includes the individual layers and styles, their description, native CRS, bounding boxes, etc.
4344
@param fullProjectInformation If true: add extended project information (does not validate against WMS schema)*/
4445
virtual void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings = false ) const;
@@ -60,21 +61,25 @@ class QgsProjectParser: public QgsConfigParser
6061

6162
int numberOfLayers() const;
6263

64+
//WMS
6365
/**Returns one or possibly several maplayers for a given layer name and style. If no layers/style are found, an empty list is returned*/
6466
virtual QList<QgsMapLayer*> mapLayerFromStyle( const QString& lName, const QString& styleName, bool useCache = true ) const;
6567

6668
/**Returns maplayers for a layer Id.*/
6769
virtual QgsMapLayer* mapLayerFromLayerId( const QString& lId, bool useCache = true ) const;
6870

71+
//WMS
6972
/**Fills a layer and a style list. The two list have the same number of entries and the style and the layer at a position belong together (similar to the HTTP parameters 'Layers' and 'Styles'. Returns 0 in case of success*/
7073
virtual int layersAndStyles( QStringList& layers, QStringList& styles ) const;
7174

75+
//WMS
7276
/**Returns the xml fragment of a style*/
7377
virtual QDomDocument getStyle( const QString& styleName, const QString& layerName ) const;
78+
//WMS
7479
/**Returns the xml fragment of layers styles*/
7580
virtual QDomDocument getStyles( QStringList& layerList ) const;
7681

77-
82+
//WMS
7883
/**Returns if output are MM or PIXEL*/
7984
virtual QgsMapRenderer::OutputUnits outputUnits() const;
8085

@@ -106,6 +111,7 @@ class QgsProjectParser: public QgsConfigParser
106111
*/
107112
virtual QStringList supportedOutputCrsList() const;
108113

114+
//WMS
109115
/**True if the feature info response should contain the wkt geometry for vector features*/
110116
virtual bool featureInfoWithWktGeometry() const;
111117

@@ -120,9 +126,11 @@ class QgsProjectParser: public QgsConfigParser
120126

121127
const QDomDocument* xmlDoc() const { return mXMLDoc; }
122128

129+
//WMS
123130
/**Creates a composition from the project file (probably delegated to the fallback parser)*/
124131
QgsComposition* initComposition( const QString& composerTemplate, QgsMapRenderer* mapRenderer, QList< QgsComposerMap*>& mapList, QList< QgsComposerLabel* >& labelList, QList<const QgsComposerHtml *>& htmlList ) const;
125132

133+
//WMS
126134
/**Adds print capabilities to xml document. ParentElem usually is the <Capabilities> element*/
127135
void printCapabilities( QDomElement& parentElement, QDomDocument& doc ) const;
128136

@@ -141,21 +149,28 @@ class QgsProjectParser: public QgsConfigParser
141149
/**Returns the names of the published wcs layers (not the ids as in wcsLayers() )*/
142150
QStringList wcsLayerNames() const;
143151

152+
//WMS
144153
/**Returns map with layer aliases for GetFeatureInfo (or 0 pointer if not supported). Key: layer name, Value: layer alias*/
145154
virtual QHash<QString, QString> featureInfoLayerAliasMap() const;
146155

156+
//WMS
147157
virtual QString featureInfoDocumentElement( const QString& defaultValue ) const;
148158

159+
//WMS
149160
virtual QString featureInfoDocumentElementNS() const;
150161

162+
//WMS
151163
virtual QString featureInfoSchema() const;
152164

165+
//WMS
153166
/**Return feature info in format SIA2045?*/
154167
bool featureInfoFormatSIA2045() const;
155168

169+
//WMS
156170
/**Draw text annotation items from the QGIS projectfile*/
157171
void drawOverlays( QPainter* p, int dpi, int width, int height ) const;
158172

173+
//WMS
159174
void loadLabelSettings( QgsLabelingEngineInterface* lbl );
160175

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

‎src/mapserver/qgsserverprojectparser.cpp

Lines changed: 1192 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/***************************************************************************
2+
qgsserverprojectparser.h
3+
------------------------
4+
begin : March 25, 2014
5+
copyright : (C) 2014 by Marco Hugentobler
6+
email : marco dot hugentobler at sourcepole dot ch
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#ifndef QGSSERVERPROJECTPARSER_H
19+
#define QGSSERVERPROJECTPARSER_H
20+
21+
#include "qgsvectorlayer.h"
22+
#include <QDomElement>
23+
#include <QHash>
24+
#include <QMap>
25+
#include <QString>
26+
27+
class QgsCoordinateReferenceSystem;
28+
class QgsMapLayer;
29+
class QgsRectangle;
30+
class QDomDocument;
31+
32+
class QgsServerProjectParser
33+
{
34+
public:
35+
/**Takes ownership of the document*/
36+
QgsServerProjectParser( QDomDocument* xmlDoc, const QString& filePath );
37+
~QgsServerProjectParser();
38+
39+
QString projectPath() const { return mProjectPath; }
40+
41+
const QDomDocument* xmlDocument() const { return mXMLDoc; }
42+
43+
/**Returns project layers by id*/
44+
void projectLayerMap( QMap<QString, QgsMapLayer*>& layerMap ) const;
45+
46+
/**Converts a (possibly relative) path to absolute*/
47+
QString convertToAbsolutePath( const QString& file ) const;
48+
49+
/**Creates a maplayer object from <maplayer> element. The layer cash owns the maplayer, so don't delete it
50+
@return the maplayer or 0 in case of error*/
51+
QgsMapLayer* createLayerFromElement( const QDomElement& elem, bool useCache = true ) const;
52+
53+
QStringList createCRSListForLayer( QgsMapLayer* theMapLayer ) const;
54+
55+
/**Returns the layer id under a <legendlayer> tag in the QGIS projectfile*/
56+
QString layerIdFromLegendLayer( const QDomElement& legendLayer ) const;
57+
58+
/**@param considerMapExtent Take user-defined map extent instead of data-calculated extent if present in project file*/
59+
void combineExtentAndCrsOfGroupChildren( QDomElement& groupElement, QDomDocument& doc, bool considerMapExtent = false ) const;
60+
61+
void appendCRSElementsToLayer( QDomElement& layerElement, QDomDocument& doc, const QStringList &crsList ) const;
62+
63+
void appendCRSElementToLayer( QDomElement& layerElement, const QDomElement& precedingElement, const QString& crsText, QDomDocument& doc ) const;
64+
65+
void appendLayerBoundingBoxes( QDomElement& layerElem, QDomDocument& doc, const QgsRectangle& layerExtent,
66+
const QgsCoordinateReferenceSystem& layerCRS ) const;
67+
68+
void addLayerProjectSettings( QDomElement& layerElem, QDomDocument& doc, QgsMapLayer* currentLayer ) const;
69+
70+
QgsRectangle layerBoundingBoxInProjectCRS( const QDomElement& layerElem, const QDomDocument &doc ) const;
71+
72+
bool crsSetForLayer( const QDomElement& layerElement, QSet<QString> &crsSet ) const;
73+
74+
const QgsCoordinateReferenceSystem& projectCRS() const;
75+
76+
QgsRectangle mapRectangle() const;
77+
78+
QStringList supportedOutputCrsList() const;
79+
80+
static QString editTypeString( QgsVectorLayer::EditType type );
81+
82+
const QList<QDomElement>& projectLayerElements() const { return mProjectLayerElements; }
83+
84+
const QList<QDomElement>& legendGroupElements() const { return mLegendGroupElements; }
85+
86+
QString projectTitle() const;
87+
88+
QDomElement legendElem() const;
89+
90+
QDomElement propertiesElem() const;
91+
92+
const QSet<QString>& restrictedLayers() const { return mRestrictedLayers; }
93+
94+
const QHash< QString, QDomElement >& projectLayerElementsByName() const { return mProjectLayerElementsByName; }
95+
96+
/**Adds layers from a legend group to list (could be embedded or a normal group)*/
97+
void addLayersFromGroup( const QDomElement& legendGroupElem, QList<QgsMapLayer*>& layerList, bool useCache = true ) const;
98+
99+
void addLayerFromLegendLayer( const QDomElement& legendLayerElem, QList<QgsMapLayer*>& layerList, bool useCache = true ) const;
100+
101+
QStringList wfsLayerNames() const;
102+
103+
QDomElement firstComposerLegendElement() const;
104+
105+
QList<QDomElement> publishedComposerElements() const;
106+
107+
QList< QPair< QString, QgsLayerCoordinateTransform > > layerCoordinateTransforms() const;
108+
109+
/**Returns the text of the <layername> element for a layer element
110+
@return id or a null string in case of error*/
111+
QString layerName( const QDomElement& layerElem ) const;
112+
113+
private:
114+
115+
/**Content of project file*/
116+
QDomDocument* mXMLDoc;
117+
118+
/**Absolute project file path (including file name)*/
119+
QString mProjectPath;
120+
121+
/**List of project layer (ordered same as in the project file)*/
122+
QList<QDomElement> mProjectLayerElements;
123+
124+
/**Project layer elements, accessible by layer id*/
125+
QHash< QString, QDomElement > mProjectLayerElementsById;
126+
127+
/**Project layer elements, accessible by layer name*/
128+
QHash< QString, QDomElement > mProjectLayerElementsByName;
129+
130+
/**List of all legend group elements*/
131+
QList<QDomElement> mLegendGroupElements;
132+
133+
/**Names of layers and groups which should not be published*/
134+
QSet<QString> mRestrictedLayers;
135+
136+
QgsServerProjectParser(); //forbidden
137+
138+
/**Returns the text of the <id> element for a layer element
139+
@return id or a null string in case of error*/
140+
QString layerId( const QDomElement& layerElem ) const;
141+
142+
/**Returns a complete string set with all the restricted layer names (layers/groups that are not to be published)*/
143+
QSet<QString> findRestrictedLayers() const;
144+
145+
/**Adds sublayers of an embedded group to layer set*/
146+
static void sublayersOfEmbeddedGroup( const QString& projectFilePath, const QString& groupName, QSet<QString>& layerSet );
147+
148+
QStringList wfsLayers() const;
149+
};
150+
151+
#endif // QGSSERVERPROJECTPARSER_H

‎src/mapserver/qgswcsprojectparser.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/***************************************************************************
2+
qgswcsprojectparser.cpp
3+
-----------------------
4+
begin : March 25, 2014
5+
copyright : (C) 2014 by Marco Hugentobler
6+
email : marco dot hugentobler at sourcepole dot ch
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#include "qgswcsprojectparser.h"
19+
20+
QgsWCSProjectParser::QgsWCSProjectParser( QDomDocument* xmlDoc, const QString& filePath ): mProjectParser( xmlDoc, filePath )
21+
{
22+
}
23+
24+
QgsWCSProjectParser::~QgsWCSProjectParser()
25+
{
26+
}

‎src/mapserver/qgswcsprojectparser.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/***************************************************************************
2+
qgswcsprojectparser.h
3+
---------------------
4+
begin : March 25, 2014
5+
copyright : (C) 2014 by Marco Hugentobler
6+
email : marco dot hugentobler at sourcepole dot ch
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#ifndef QGSWCSPROJECTPARSER_H
19+
#define QGSWCSPROJECTPARSER_H
20+
21+
#include "qgsserverprojectparser.h"
22+
23+
class QgsWCSProjectParser
24+
{
25+
public:
26+
QgsWCSProjectParser( QDomDocument* xmlDoc, const QString& filePath );
27+
~QgsWCSProjectParser();
28+
29+
private:
30+
QgsServerProjectParser mProjectParser;
31+
};
32+
33+
#endif // QGSWCSPROJECTPARSER_H

‎src/mapserver/qgswcsserver.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* *
1616
***************************************************************************/
1717
#include "qgswcsserver.h"
18-
#include "qgsconfigparser.h"
18+
#include "qgswcsprojectparser.h"
1919
#include "qgscrscache.h"
2020
#include "qgsrasterlayer.h"
2121
#include "qgsrasterpipe.h"
@@ -36,16 +36,16 @@ static const QString WCS_NAMESPACE = "http://www.opengis.net/wcs";
3636
static const QString GML_NAMESPACE = "http://www.opengis.net/gml";
3737
static const QString OGC_NAMESPACE = "http://www.opengis.net/ogc";
3838

39-
QgsWCSServer::QgsWCSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsConfigParser* cp,
40-
QgsRequestHandler* rh ): QgsOWSServer( configFilePath, parameters, cp, rh )
39+
QgsWCSServer::QgsWCSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsWCSProjectParser* pp,
40+
QgsRequestHandler* rh ): QgsOWSServer( configFilePath, parameters, rh ), mConfigParser( pp )
4141
{
4242
}
4343

4444
QgsWCSServer::~QgsWCSServer()
4545
{
4646
}
4747

48-
QgsWCSServer::QgsWCSServer(): QgsOWSServer( QString(), QMap<QString, QString>(), 0, 0 )
48+
QgsWCSServer::QgsWCSServer(): QgsOWSServer( QString(), QMap<QString, QString>(), 0 )
4949
{
5050
}
5151

@@ -117,6 +117,9 @@ QDomDocument QgsWCSServer::getCapabilities()
117117
{
118118
QgsDebugMsg( "Entering." );
119119
QDomDocument doc;
120+
121+
#if 0 //todo: fixme
122+
120123
//wcs:WCS_Capabilities element
121124
QDomElement wcsCapabilitiesElement = doc.createElement( "WCS_Capabilities"/*wcs:WCS_Capabilities*/ );
122125
wcsCapabilitiesElement.setAttribute( "xmlns", WCS_NAMESPACE );
@@ -195,13 +198,18 @@ QDomDocument QgsWCSServer::getCapabilities()
195198
mConfigParser->wcsContentMetadata( contentMetadataElement, doc );
196199
}
197200

201+
#endif //0 //todo: fixme
202+
198203
return doc;
199204
}
200205

201206
QDomDocument QgsWCSServer::describeCoverage()
202207
{
203208
QgsDebugMsg( "Entering." );
204209
QDomDocument doc;
210+
211+
#if 0 //todo: fixme
212+
205213
//wcs:WCS_Capabilities element
206214
QDomElement coveDescElement = doc.createElement( "CoverageDescription"/*wcs:CoverageDescription*/ );
207215
coveDescElement.setAttribute( "xmlns", WCS_NAMESPACE );
@@ -230,11 +238,16 @@ QDomDocument QgsWCSServer::describeCoverage()
230238
}
231239
}
232240
mConfigParser->describeCoverage( coveName, coveDescElement, doc );
241+
242+
#endif //0 //todo: fixme
243+
233244
return doc;
234245
}
235246

236247
QByteArray* QgsWCSServer::getCoverage()
237248
{
249+
#if 0 //todo: fixme
250+
238251
QStringList wcsLayersId = mConfigParser->wcsLayers();
239252

240253
QList<QgsMapLayer*> layerList;
@@ -398,6 +411,7 @@ QByteArray* QgsWCSServer::getCoverage()
398411

399412
return ba;
400413
}
414+
#endif //0 //todo: fixme
401415
return 0;
402416
}
403417

‎src/mapserver/qgswcsserver.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "qgis.h"
2626
#include "qgsowsserver.h"
2727

28-
class QgsConfigParser;
28+
class QgsWCSProjectParser;
2929
class QgsRequestHandler;
3030

3131
/**This class handles all the wcs server requests. The parameters and values have to be passed in the form of
@@ -36,7 +36,7 @@ class QgsWCSServer: public QgsOWSServer
3636
{
3737
public:
3838
/**Constructor. Takes parameter map and a pointer to a renderer object (does not take ownership)*/
39-
QgsWCSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsConfigParser* cp,
39+
QgsWCSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsWCSProjectParser* pp,
4040
QgsRequestHandler* rh );
4141
~QgsWCSServer();
4242

@@ -52,14 +52,16 @@ class QgsWCSServer: public QgsOWSServer
5252
QByteArray* getCoverage();
5353

5454
/**Sets configuration parser for administration settings. Does not take ownership*/
55-
void setAdminConfigParser( QgsConfigParser* parser ) { mConfigParser = parser; }
55+
void setAdminConfigParser( QgsWCSProjectParser* parser ) { mConfigParser = parser; }
5656

5757
private:
5858
/**Don't use the default constructor*/
5959
QgsWCSServer();
6060

6161
/**Get service address from REQUEST_URI if not specified in the configuration*/
6262
QString serviceUrl() const;
63+
64+
QgsWCSProjectParser* mConfigParser;
6365
};
6466

6567
#endif

‎src/mapserver/qgswfsprojectparser.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/***************************************************************************
2+
qgswfsprojectparser.cpp
3+
-----------------------
4+
begin : March 25, 2014
5+
copyright : (C) 2014 by Marco Hugentobler
6+
email : marco dot hugentobler at sourcepole dot ch
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#include "qgswfsprojectparser.h"
19+
20+
QgsWFSProjectParser::QgsWFSProjectParser( QDomDocument* xmlDoc, const QString& filePath ):
21+
mProjectParser( xmlDoc, filePath )
22+
{
23+
}
24+
25+
QgsWFSProjectParser::~QgsWFSProjectParser()
26+
{
27+
}

‎src/mapserver/qgswfsprojectparser.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/***************************************************************************
2+
qgswfsprojectparser.h
3+
---------------------
4+
begin : March 25, 2014
5+
copyright : (C) 2014 by Marco Hugentobler
6+
email : marco dot hugentobler at sourcepole dot ch
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#ifndef QGSWFSPROJECTPARSER_H
19+
#define QGSWFSPROJECTPARSER_H
20+
21+
#include "qgsserverprojectparser.h"
22+
23+
class QgsWFSProjectParser
24+
{
25+
public:
26+
QgsWFSProjectParser( QDomDocument* xmlDoc, const QString& filePath );
27+
~QgsWFSProjectParser();
28+
29+
private:
30+
QgsServerProjectParser mProjectParser;
31+
};
32+
33+
#endif // QGSWFSPROJECTPARSER_H

‎src/mapserver/qgswfsserver.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ static const QString GML_NAMESPACE = "http://www.opengis.net/gml";
6666
static const QString OGC_NAMESPACE = "http://www.opengis.net/ogc";
6767
static const QString QGS_NAMESPACE = "http://www.qgis.org/gml";
6868

69-
QgsWFSServer::QgsWFSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsConfigParser* cp,
70-
QgsRequestHandler* rh ): QgsOWSServer( configFilePath, parameters, cp, rh )
69+
QgsWFSServer::QgsWFSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsWFSProjectParser* cp,
70+
QgsRequestHandler* rh ): QgsOWSServer( configFilePath, parameters, rh ), mConfigParser( cp )
7171
{
7272
}
7373

7474
QgsWFSServer::~QgsWFSServer()
7575
{
7676
}
7777

78-
QgsWFSServer::QgsWFSServer(): QgsOWSServer( QString(), QMap<QString, QString>(), 0, 0 )
78+
QgsWFSServer::QgsWFSServer(): QgsOWSServer( QString(), QMap<QString, QString>(), 0 )
7979
{
8080
}
8181

@@ -165,6 +165,9 @@ QDomDocument QgsWFSServer::getCapabilities()
165165
{
166166
QgsDebugMsg( "Entering." );
167167
QDomDocument doc;
168+
169+
#if 0 //todo: fixme
170+
168171
//wfs:WFS_Capabilities element
169172
QDomElement wfsCapabilitiesElement = doc.createElement( "WFS_Capabilities"/*wms:WFS_Capabilities*/ );
170173
wfsCapabilitiesElement.setAttribute( "xmlns", WFS_NAMESPACE );
@@ -297,13 +300,19 @@ QDomDocument QgsWFSServer::getCapabilities()
297300
comparisonOperatorsElement.appendChild( doc.createElement( "ogc:Simple_Comparisons"/*ogc:Simple_Comparisons*/ ) );
298301
comparisonOperatorsElement.appendChild( doc.createElement( "ogc:Between"/*ogc:Between*/ ) );
299302
comparisonOperatorsElement.appendChild( doc.createElement( "ogc:Like"/*ogc:Like*/ ) );
303+
304+
#endif //0 //todo: fixme
305+
300306
return doc;
301307
}
302308

303309
QDomDocument QgsWFSServer::describeFeatureType()
304310
{
305311
QgsDebugMsg( "Entering." );
306312
QDomDocument doc;
313+
314+
#if 0 //todo: fixme
315+
307316
//xsd:schema
308317
QDomElement schemaElement = doc.createElement( "schema"/*xsd:schema*/ );
309318
schemaElement.setAttribute( "xmlns", "http://www.w3.org/2001/XMLSchema" );
@@ -358,11 +367,15 @@ QDomDocument QgsWFSServer::describeFeatureType()
358367
}
359368
mConfigParser->describeFeatureType( typeName, schemaElement, doc );
360369
}
370+
371+
#endif //0 //todo: fixme
372+
361373
return doc;
362374
}
363375

364376
int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format )
365377
{
378+
#if 0 //todo: fixme
366379
QgsDebugMsg( "Info format is:" + format );
367380

368381
QStringList wfsLayersId = mConfigParser->wfsLayers();
@@ -1071,11 +1084,14 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
10711084
else
10721085
endGetFeature( request, format );
10731086

1087+
#endif // 0 //todo: fixme
1088+
10741089
return 0;
10751090
}
10761091

10771092
void QgsWFSServer::startGetFeature( QgsRequestHandler& request, const QString& format, QgsCoordinateReferenceSystem& crs, QgsRectangle* rect )
10781093
{
1094+
#if 0 //todo: fixme
10791095
QByteArray result;
10801096
QString fcString;
10811097
if ( format == "GeoJSON" )
@@ -1202,6 +1218,9 @@ void QgsWFSServer::startGetFeature( QgsRequestHandler& request, const QString& f
12021218
request.sendGetFeatureResponse( &result );
12031219
}
12041220
fcString = "";
1221+
1222+
#endif //0 //todo: fixme
1223+
12051224
}
12061225

12071226
void QgsWFSServer::sendGetFeature( QgsRequestHandler& request, const QString& format, QgsFeature* feat, int featIdx, QgsCoordinateReferenceSystem& crs, QgsAttributeList attrIndexes, QSet<QString> excludedAttributes ) /*const*/
@@ -1271,6 +1290,10 @@ QDomDocument QgsWFSServer::transaction( const QString& requestBody )
12711290
{
12721291
// Getting the transaction document
12731292
QDomDocument doc;
1293+
return doc;
1294+
1295+
#if 0 //todo: fixme
1296+
12741297
QString errorMsg;
12751298
if ( !doc.setContent( requestBody, true, &errorMsg ) )
12761299
{
@@ -1631,6 +1654,8 @@ QDomDocument QgsWFSServer::transaction( const QString& requestBody )
16311654
respElem.appendChild( trElem );
16321655

16331656
return resp;
1657+
1658+
#endif //0 //todo: fixme
16341659
}
16351660

16361661
QgsFeatureIds QgsWFSServer::getFeatureIdsFromFilter( QDomElement filterElem, QgsVectorLayer* layer )

‎src/mapserver/qgswfsserver.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "qgis.h"
2626
#include "qgsowsserver.h"
2727
#include "qgsvectorlayer.h"
28+
#include "qgswfsprojectparser.h"
2829

2930
class QgsCoordinateReferenceSystem;
3031
class QgsComposerLayerItem;
@@ -59,7 +60,7 @@ class QgsWFSServer: public QgsOWSServer
5960
{
6061
public:
6162
/**Constructor. Takes parameter map and a pointer to a renderer object (does not take ownership)*/
62-
QgsWFSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsConfigParser* cp,
63+
QgsWFSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsWFSProjectParser* cp,
6364
QgsRequestHandler* rh );
6465
~QgsWFSServer();
6566

@@ -80,7 +81,7 @@ class QgsWFSServer: public QgsOWSServer
8081
QDomDocument transaction( const QString& requestBody );
8182

8283
/**Sets configuration parser for administration settings. Does not take ownership*/
83-
void setAdminConfigParser( QgsConfigParser* parser ) { mConfigParser = parser; }
84+
void setAdminConfigParser( QgsWFSProjectParser* parser ) { mConfigParser = parser; }
8485

8586
private:
8687
/**Don't use the default constructor*/
@@ -98,6 +99,8 @@ class QgsWFSServer: public QgsOWSServer
9899
/* Error messages */
99100
QStringList mErrors;
100101

102+
QgsWFSProjectParser* mConfigParser;
103+
101104
protected:
102105

103106
void startGetFeature( QgsRequestHandler& request, const QString& format, QgsCoordinateReferenceSystem& crs, QgsRectangle* rect );

‎src/mapserver/qgswmsconfigparser.h

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/***************************************************************************
2+
qgswmsconfigparser.h
3+
--------------------
4+
begin : March 25, 2014
5+
copyright : (C) 2014 by Marco Hugentobler
6+
email : marco dot hugentobler at sourcepole dot ch
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#ifndef QGSWMSCONFIGPARSER_H
19+
#define QGSWMSCONFIGPARSER_H
20+
21+
#include "qgsconfigparser.h"
22+
23+
class QgsWMSConfigParser
24+
{
25+
public:
26+
27+
/**Adds layer and style specific capabilities elements to the parent node. This includes the individual layers and styles, their description, native CRS, bounding boxes, etc.
28+
@param fullProjectInformation If true: add extended project information (does not validate against WMS schema)*/
29+
virtual void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings = false ) const = 0;
30+
31+
/**Returns one or possibly several maplayers for a given layer name and style. If no layers/style are found, an empty list is returned*/
32+
virtual QList<QgsMapLayer*> mapLayerFromStyle( const QString& lName, const QString& styleName, bool useCache = true ) const = 0;
33+
34+
/**Fills a layer and a style list. The two list have the same number of entries and the style and the layer at a position belong together (similar to the HTTP parameters 'Layers' and 'Styles'. Returns 0 in case of success*/
35+
virtual int layersAndStyles( QStringList& layers, QStringList& styles ) const = 0;
36+
37+
/**Returns the xml fragment of a style*/
38+
virtual QDomDocument getStyle( const QString& styleName, const QString& layerName ) const = 0;
39+
40+
/**Returns the xml fragment of layers styles*/
41+
virtual QDomDocument getStyles( QStringList& layerList ) const = 0;
42+
43+
/**Returns if output are MM or PIXEL*/
44+
virtual QgsMapRenderer::OutputUnits outputUnits() const = 0;
45+
46+
/**Returns an ID-list of layers which are not queryable (comes from <properties> -> <Identify> -> <disabledLayers in the project file*/
47+
virtual QStringList identifyDisabledLayers() const = 0;
48+
49+
/**True if the feature info response should contain the wkt geometry for vector features*/
50+
virtual bool featureInfoWithWktGeometry() const = 0;
51+
52+
/**Returns map with layer aliases for GetFeatureInfo (or 0 pointer if not supported). Key: layer name, Value: layer alias*/
53+
virtual QHash<QString, QString> featureInfoLayerAliasMap() const = 0;
54+
55+
virtual QString featureInfoDocumentElement( const QString& defaultValue ) const = 0;
56+
57+
virtual QString featureInfoDocumentElementNS() const = 0;
58+
59+
virtual QString featureInfoSchema() const = 0;
60+
61+
/**Return feature info in format SIA2045?*/
62+
virtual bool featureInfoFormatSIA2045() const = 0;
63+
64+
/**Draw text annotation items from the QGIS projectfile*/
65+
virtual void drawOverlays( QPainter* p, int dpi, int width, int height ) const = 0;
66+
67+
//todo: fixme
68+
virtual void loadLabelSettings( QgsLabelingEngineInterface* lbl ) {} //= 0;
69+
70+
virtual QString serviceUrl() const = 0;
71+
72+
virtual QStringList wfsLayerNames() const = 0;
73+
74+
virtual void owsGeneralAndResourceList( QDomElement& parentElement, QDomDocument& doc, const QString& strHref ) const = 0;
75+
76+
//legend
77+
virtual double legendBoxSpace() const = 0;
78+
virtual double legendLayerSpace() const = 0;
79+
virtual double legendLayerTitleSpace() const = 0;
80+
virtual double legendSymbolSpace() const = 0;
81+
virtual double legendIconLabelSpace() const = 0;
82+
virtual double legendSymbolWidth() const = 0;
83+
virtual double legendSymbolHeight() const = 0;
84+
virtual const QFont& legendLayerFont() const = 0;
85+
virtual const QFont& legendItemFont() const = 0;
86+
87+
virtual double maxWidth() const = 0;
88+
virtual double maxHeight() const = 0;
89+
90+
//printing
91+
92+
/**Creates a print composition, usually for a GetPrint request. Replaces map and label parameters*/
93+
virtual QgsComposition* createPrintComposition( const QString& composerTemplate, QgsMapRenderer* mapRenderer, const QMap< QString, QString >& parameterMap ) const = 0;
94+
95+
/**Creates a composition from the project file (probably delegated to the fallback parser)*/
96+
virtual QgsComposition* initComposition( const QString& composerTemplate, QgsMapRenderer* mapRenderer, QList< QgsComposerMap*>& mapList, QList< QgsComposerLabel* >& labelList, QList<const QgsComposerHtml *>& htmlFrameList ) const = 0;
97+
98+
/**Adds print capabilities to xml document. ParentElem usually is the <Capabilities> element*/
99+
virtual void printCapabilities( QDomElement& parentElement, QDomDocument& doc ) const = 0;
100+
101+
virtual void setFallbackParser( QgsWMSConfigParser* p ) {}
102+
virtual void setScaleDenominator( double denom ) = 0;
103+
virtual void addExternalGMLData( const QString& layerName, QDomDocument* gmlDoc ) = 0;
104+
105+
virtual QList< QPair< QString, QgsLayerCoordinateTransform > > layerCoordinateTransforms() const = 0;
106+
};
107+
108+
#endif // QGSWMSCONFIGPARSER_H

‎src/mapserver/qgswmsprojectparser.cpp

Lines changed: 1585 additions & 0 deletions
Large diffs are not rendered by default.

‎src/mapserver/qgswmsprojectparser.h

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/***************************************************************************
2+
qgswmsprojectparser.h
3+
---------------------
4+
begin : March 25, 2014
5+
copyright : (C) 2014 by Marco Hugentobler
6+
email : marco dot hugentobler at sourcepole dot ch
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#ifndef QGSWMSPROJECTPARSER_H
19+
#define QGSWMSPROJECTPARSER_H
20+
21+
#include "qgswmsconfigparser.h"
22+
#include "qgsserverprojectparser.h"
23+
24+
class QgsWMSProjectParser: public QgsWMSConfigParser
25+
{
26+
public:
27+
QgsWMSProjectParser( QDomDocument* xmlDoc, const QString& filePath );
28+
virtual ~QgsWMSProjectParser();
29+
30+
/**Adds layer and style specific capabilities elements to the parent node. This includes the individual layers and styles, their description, native CRS, bounding boxes, etc.
31+
@param fullProjectInformation If true: add extended project information (does not validate against WMS schema)*/
32+
void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings = false ) const;
33+
34+
QList<QgsMapLayer*> mapLayerFromStyle( const QString& lName, const QString& styleName, bool useCache = true ) const;
35+
36+
QString serviceUrl() const;
37+
38+
QStringList wfsLayerNames() const;
39+
40+
void owsGeneralAndResourceList( QDomElement& parentElement, QDomDocument& doc, const QString& strHref ) const;
41+
42+
//legend
43+
double legendBoxSpace() const;
44+
double legendLayerSpace() const;
45+
double legendLayerTitleSpace() const;
46+
double legendSymbolSpace() const;
47+
double legendIconLabelSpace() const;
48+
double legendSymbolWidth() const;
49+
double legendSymbolHeight() const;
50+
const QFont& legendLayerFont() const;
51+
const QFont& legendItemFont() const;
52+
53+
double maxWidth() const;
54+
double maxHeight() const;
55+
56+
//printing
57+
QgsComposition* createPrintComposition( const QString& composerTemplate, QgsMapRenderer* mapRenderer, const QMap< QString, QString >& parameterMap ) const;
58+
59+
QgsComposition* initComposition( const QString& composerTemplate, QgsMapRenderer* mapRenderer, QList< QgsComposerMap*>& mapList, QList< QgsComposerLabel* >& labelList, QList<const QgsComposerHtml *>& htmlFrameList ) const;
60+
61+
void printCapabilities( QDomElement& parentElement, QDomDocument& doc ) const;
62+
63+
//todo: fixme
64+
void setScaleDenominator( double denom ) {}
65+
void addExternalGMLData( const QString& layerName, QDomDocument* gmlDoc ) {}
66+
67+
QList< QPair< QString, QgsLayerCoordinateTransform > > layerCoordinateTransforms() const;
68+
69+
/**Fills a layer and a style list. The two list have the same number of entries and the style and the layer at a position belong together (similar to the HTTP parameters 'Layers' and 'Styles'. Returns 0 in case of success*/
70+
int layersAndStyles( QStringList& layers, QStringList& styles ) const;
71+
72+
/**Returns the xml fragment of a style*/
73+
QDomDocument getStyle( const QString& styleName, const QString& layerName ) const;
74+
75+
/**Returns the xml fragment of layers styles*/
76+
QDomDocument getStyles( QStringList& layerList ) const;
77+
78+
/**Returns if output are MM or PIXEL*/
79+
QgsMapRenderer::OutputUnits outputUnits() const;
80+
81+
/**True if the feature info response should contain the wkt geometry for vector features*/
82+
bool featureInfoWithWktGeometry() const;
83+
84+
/**Returns map with layer aliases for GetFeatureInfo (or 0 pointer if not supported). Key: layer name, Value: layer alias*/
85+
QHash<QString, QString> featureInfoLayerAliasMap() const;
86+
87+
QString featureInfoDocumentElement( const QString& defaultValue ) const;
88+
89+
QString featureInfoDocumentElementNS() const;
90+
91+
QString featureInfoSchema() const;
92+
93+
/**Return feature info in format SIA2045?*/
94+
bool featureInfoFormatSIA2045() const;
95+
96+
/**Draw text annotation items from the QGIS projectfile*/
97+
void drawOverlays( QPainter* p, int dpi, int width, int height ) const;
98+
99+
private:
100+
QgsServerProjectParser mProjectParser;
101+
102+
/**Names of layers and groups which should not be published*/
103+
QSet<QString> mRestrictedLayers;
104+
105+
mutable QFont mLegendLayerFont;
106+
107+
mutable QFont mLegendItemFont;
108+
109+
/**Returns an ID-list of layers which are not queryable (comes from <properties> -> <Identify> -> <disabledLayers in the project file*/
110+
virtual QStringList identifyDisabledLayers() const;
111+
112+
/**Reads layer drawing order from the legend section of the project file and appends it to the parent elemen (usually the <Capability> element)*/
113+
void addDrawingOrder( QDomElement& parentElem, QDomDocument& doc ) const;
114+
115+
/**Adds drawing order info from layer element or group element (recursive)*/
116+
void addDrawingOrder( QDomElement groupElem, bool useDrawingOrder, QMap<int, QString>& orderedLayerList ) const;
117+
118+
void addLayers( QDomDocument &doc,
119+
QDomElement &parentLayer,
120+
const QDomElement &legendElem,
121+
const QMap<QString, QgsMapLayer *> &layerMap,
122+
const QStringList &nonIdentifiableLayers,
123+
QString version, //1.1.1 or 1.3.0
124+
bool fullProjectSettings = false ) const;
125+
126+
void addOWSLayers( QDomDocument &doc, QDomElement &parentElem, const QDomElement &legendElem,
127+
const QMap<QString, QgsMapLayer *> &layerMap, const QStringList &nonIdentifiableLayers,
128+
const QString& strHref, QgsRectangle& combinedBBox, QString strGroup ) const;
129+
};
130+
131+
#endif // QGSWMSPROJECTPARSER_H

‎src/mapserver/qgswmsserver.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@
5757
#include <QUrl>
5858
#include <QPaintEngine>
5959

60-
QgsWMSServer::QgsWMSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsConfigParser* cp,
60+
QgsWMSServer::QgsWMSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsWMSConfigParser* cp,
6161
QgsRequestHandler* rh, QgsMapRenderer* renderer, QgsCapabilitiesCache* capCache )
62-
: QgsOWSServer( configFilePath, parameters, cp, rh )
63-
, mMapRenderer( renderer ), mCapabilitiesCache( capCache )
62+
: QgsOWSServer( configFilePath, parameters, rh )
63+
, mMapRenderer( renderer ), mCapabilitiesCache( capCache ), mConfigParser( cp )
6464
{
6565
}
6666

6767
QgsWMSServer::~QgsWMSServer()
6868
{
6969
}
7070

71-
QgsWMSServer::QgsWMSServer(): QgsOWSServer( QString(), QMap<QString, QString>(), 0, 0 )
71+
QgsWMSServer::QgsWMSServer(): QgsOWSServer( QString(), QMap<QString, QString>(), 0 )
7272
{
7373
}
7474

@@ -318,11 +318,6 @@ QDomDocument QgsWMSServer::getCapabilities( QString version, bool fullProjectInf
318318
wmsCapabilitiesElement.setAttribute( "version", version );
319319
doc.appendChild( wmsCapabilitiesElement );
320320

321-
if ( mConfigParser )
322-
{
323-
mConfigParser->serviceCapabilities( wmsCapabilitiesElement, doc );
324-
}
325-
326321
//wms:Capability element
327322
QDomElement capabilityElement = doc.createElement( "Capability"/*wms:Capability*/ );
328323
wmsCapabilitiesElement.appendChild( capabilityElement );
@@ -1569,6 +1564,8 @@ int QgsWMSServer::initializeSLDParser( QStringList& layersList, QStringList& sty
15691564
delete theDocument;
15701565
return 0;
15711566
}
1567+
1568+
#if 0 //todo: fixme
15721569
QgsSLDParser* userSLDParser = new QgsSLDParser( theDocument );
15731570
userSLDParser->setParameterMap( mParameters );
15741571
userSLDParser->setFallbackParser( mConfigParser );
@@ -1590,6 +1587,7 @@ int QgsWMSServer::initializeSLDParser( QStringList& layersList, QStringList& sty
15901587
layersList << *layersIt;
15911588
stylesList << *stylesIt;
15921589
}
1590+
#endif //0 //todo: fixme
15931591
}
15941592
return 0;
15951593
}

‎src/mapserver/qgswmsserver.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define QGSWMSSERVER_H
2020

2121
#include "qgsowsserver.h"
22+
#include "qgswmsconfigparser.h"
2223
#include <QDomDocument>
2324
#include <QMap>
2425
#include <QPair>
@@ -59,7 +60,7 @@ class QgsWMSServer: public QgsOWSServer
5960
public:
6061
/**Constructor. Takes ownership of QgsRequestHandler. Does _NOT_ take ownership of
6162
QgsConfigParser, QgsCapabilitiesCache and QgsMapRenderer*/
62-
QgsWMSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsConfigParser* cp, QgsRequestHandler* rh,
63+
QgsWMSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsWMSConfigParser* cp, QgsRequestHandler* rh,
6364
QgsMapRenderer* renderer, QgsCapabilitiesCache* capCache );
6465
~QgsWMSServer();
6566

@@ -92,7 +93,7 @@ class QgsWMSServer: public QgsOWSServer
9293
int getFeatureInfo( QDomDocument& result, QString version = "1.3.0" );
9394

9495
/**Sets configuration parser for administration settings. Does not take ownership*/
95-
void setAdminConfigParser( QgsConfigParser* parser ) { mConfigParser = parser; }
96+
void setAdminConfigParser( QgsWMSConfigParser* parser ) { mConfigParser = parser; }
9697

9798
private:
9899
/**Don't use the default constructor*/
@@ -231,6 +232,8 @@ class QgsWMSServer: public QgsOWSServer
231232

232233
QgsCapabilitiesCache* mCapabilitiesCache;
233234

235+
QgsWMSConfigParser* mConfigParser;
236+
234237
QDomElement createFeatureGML(
235238
QgsFeature* feat,
236239
QgsVectorLayer* layer,

0 commit comments

Comments
 (0)
Please sign in to comment.