Skip to content

Commit 1a7ad76

Browse files
committed
Re-enable GetCapabilities in WFS server
1 parent db87e4d commit 1a7ad76

9 files changed

+443
-13
lines changed

src/mapserver/qgsconfigcache.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,30 @@ QgsWCSProjectParser* QgsConfigCache::wcsConfiguration( const QString& filePath )
5050

5151
QgsWFSProjectParser* QgsConfigCache::wfsConfiguration( const QString& filePath )
5252
{
53-
return 0; //todo...
53+
QgsWFSProjectParser* p = mWFSConfigCache.object( filePath );
54+
if ( p )
55+
{
56+
return p;
57+
}
58+
59+
QDomDocument* doc = xmlDocument( filePath );
60+
if ( !doc )
61+
{
62+
return 0;
63+
}
64+
65+
p = new QgsWFSProjectParser( doc, filePath );
66+
mWFSConfigCache.insert( filePath, p );
67+
return p;
5468
}
5569

5670
QgsWMSConfigParser* QgsConfigCache::wmsConfiguration( const QString& filePath )
5771
{
5872
QgsWMSConfigParser* p = mWMSConfigCache.object( filePath );
73+
if ( p )
74+
{
75+
return p;
76+
}
5977

6078
QDomDocument* doc = xmlDocument( filePath );
6179
if ( !doc )

src/mapserver/qgsconfigparserutils.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <QDomDocument>
2727
#include <QDomElement>
28+
#include <QFile>
2829
#include <QString>
2930

3031
#include <sqlite3.h>
@@ -184,3 +185,21 @@ QStringList QgsConfigParserUtils::createCRSListForLayer( QgsMapLayer* theMapLaye
184185
sqlite3_close( myDatabase );
185186
return crsNumbers;
186187
}
188+
189+
void QgsConfigParserUtils::fallbackServiceCapabilities( QDomElement& parentElement, QDomDocument& doc )
190+
{
191+
Q_UNUSED( doc );
192+
QFile wmsService( "wms_metadata.xml" );
193+
if ( wmsService.open( QIODevice::ReadOnly ) )
194+
{
195+
QDomDocument externServiceDoc;
196+
QString parseError;
197+
int errorLineNo;
198+
if ( externServiceDoc.setContent( &wmsService, false, &parseError, &errorLineNo ) )
199+
{
200+
wmsService.close();
201+
QDomElement service = externServiceDoc.firstChildElement();
202+
parentElement.appendChild( service );
203+
}
204+
}
205+
}

src/mapserver/qgsconfigparserutils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class QgsConfigParserUtils
3838
const QgsCoordinateReferenceSystem& layerCRS );
3939
/**Returns a list of supported EPSG coordinate system numbers from a layer*/
4040
static QStringList createCRSListForLayer( QgsMapLayer* theMapLayer );
41+
42+
/**Returns default service capabilities from wms_metadata.xml if nothing else is defined*/
43+
static void fallbackServiceCapabilities( QDomElement& parentElement, QDomDocument& doc );
4144
};
4245

4346
#endif // QGSCONFIGPARSERUTILS_H

src/mapserver/qgsserverprojectparser.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,27 @@ QString QgsServerProjectParser::layerName( const QDomElement& layerElem ) const
303303
return nameElem.text().replace( "," , "%60" ); //commas are not allowed in layer names
304304
}
305305

306+
QString QgsServerProjectParser::serviceUrl() const
307+
{
308+
QString url;
309+
310+
if ( !mXMLDoc )
311+
{
312+
return url;
313+
}
314+
315+
QDomElement propertiesElement = propertiesElem();
316+
if ( !propertiesElement.isNull() )
317+
{
318+
QDomElement wmsUrlElem = propertiesElement.firstChildElement( "WMSUrl" );
319+
if ( !wmsUrlElem.isNull() )
320+
{
321+
url = wmsUrlElem.text();
322+
}
323+
}
324+
return url;
325+
}
326+
306327
void QgsServerProjectParser::combineExtentAndCrsOfGroupChildren( QDomElement& groupElem, QDomDocument& doc, bool considerMapExtent ) const
307328
{
308329
QgsRectangle combinedBBox;

src/mapserver/qgsserverprojectparser.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ class QgsServerProjectParser
101101
@return id or a null string in case of error*/
102102
QString layerName( const QDomElement& layerElem ) const;
103103

104+
QString serviceUrl() const;
105+
106+
QStringList wfsLayers() const;
107+
104108
private:
105109

106110
/**Content of project file*/
@@ -135,8 +139,6 @@ class QgsServerProjectParser
135139

136140
/**Adds sublayers of an embedded group to layer set*/
137141
static void sublayersOfEmbeddedGroup( const QString& projectFilePath, const QString& groupName, QSet<QString>& layerSet );
138-
139-
QStringList wfsLayers() const;
140142
};
141143

142144
#endif // QGSSERVERPROJECTPARSER_H

0 commit comments

Comments
 (0)