21 changes: 18 additions & 3 deletions src/mapserver/qgsprojectparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define QGSPROJECTPARSER_H

#include "qgsconfigparser.h"
#include "qgsvectorlayer.h"
#include <QList>
#include <QPair>

Expand All @@ -35,8 +36,9 @@ class QgsProjectParser: public QgsConfigParser
QgsProjectParser( QDomDocument* xmlDoc, const QString& filePath );
virtual ~QgsProjectParser();

/**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.*/
virtual void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc ) const;
/**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.
@param fullProjectInformation If true: add extended project information (does not validate against WMS schema)*/
virtual void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings = false ) const;

virtual void featureTypeList( QDomElement& parentElement, QDomDocument& doc ) const;

Expand Down Expand Up @@ -110,6 +112,9 @@ class QgsProjectParser: public QgsConfigParser

QString serviceUrl() const;

/**Returns the names of the published wfs layers (not the ids as in wfsLayers() )*/
QStringList wfsLayerNames() const;

private:

//forbidden
Expand Down Expand Up @@ -153,7 +158,11 @@ class QgsProjectParser: public QgsConfigParser
QDomElement &parentLayer,
const QDomElement &legendElem,
const QMap<QString, QgsMapLayer *> &layerMap,
const QStringList &nonIdentifiableLayers ) const;
const QStringList &nonIdentifiableLayers,
QString version, //1.1.1 or 1.3.0
bool fullProjectSettings = false ) const;

static void addLayerProjectSettings( QDomElement& layerElem, QDomDocument& doc, QgsMapLayer* currentLayer );

void combineExtentAndCrsOfGroupChildren( QDomElement& groupElement, QDomDocument& doc ) const;

Expand All @@ -173,6 +182,12 @@ class QgsProjectParser: public QgsConfigParser
void setSelectionColor();
/**Reads maxWidth / maxHeight from project and sets it to QgsConfigParser::mMaxWidth / mMaxHeight*/
void setMaxWidthHeight();
/**Reads layer drawing order from the legend section of the project file and appends it to the parent elemen (usually the <Capability> element)*/
void addDrawingOrder( QDomElement& parentElem, QDomDocument& doc ) const;
/**Returns project layers by id*/
void projectLayerMap( QMap<QString, QgsMapLayer*>& layerMap ) const;

static QString editTypeString( QgsVectorLayer::EditType type );
};

#endif // QGSPROJECTPARSER_H
2 changes: 1 addition & 1 deletion src/mapserver/qgssldparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ int QgsSLDParser::numberOfLayers() const
return ( userLayerList.size() + namedLayerList.size() );
}

void QgsSLDParser::layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc ) const
void QgsSLDParser::layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings ) const
{
//iterate over all <UserLayer> nodes
if ( mXMLDoc )
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgssldparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class QgsSLDParser: public QgsConfigParser
virtual ~QgsSLDParser();

/**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.*/
void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc ) const;
void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings = false ) const;

void featureTypeList( QDomElement &, QDomDocument & ) const {}

Expand Down
23 changes: 19 additions & 4 deletions src/mapserver/qgswmsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void QgsWMSServer::appendFormats( QDomDocument &doc, QDomElement &elem, const QS
}
}

QDomDocument QgsWMSServer::getCapabilities( QString version )
QDomDocument QgsWMSServer::getCapabilities( QString version, bool fullProjectInformation )
{
QgsDebugMsg( "Entering." );
QDomDocument doc;
Expand Down Expand Up @@ -205,17 +205,32 @@ QDomDocument QgsWMSServer::getCapabilities( QString version )
appendFormats( doc, elem, QStringList() << ( version == "1.1.1" ? "application/vnd.ogc.se_xml" : "text/xml" ) );
capabilityElement.appendChild( elem );

//Insert <ComposerTemplate> elements derived from wms:_ExtendedCapabilities
if ( mConfigParser )
if ( mConfigParser /*&& fullProjectInformation*/ ) //remove composer templates from GetCapabilities in the long term
{
//Insert <ComposerTemplate> elements derived from wms:_ExtendedCapabilities
mConfigParser->printCapabilities( capabilityElement, doc );

//WFS layers
QStringList wfsLayers = mConfigParser->wfsLayerNames();
if ( wfsLayers.size() > 0 )
{
QDomElement wfsLayersElem = doc.createElement( "WFSLayers" );
QStringList::const_iterator wfsIt = wfsLayers.constBegin();
for ( ; wfsIt != wfsLayers.constEnd(); ++wfsIt )
{
QDomElement wfsLayerElem = doc.createElement( "WFSLayer" );
wfsLayerElem.setAttribute( "name", *wfsIt );
wfsLayersElem.appendChild( wfsLayerElem );
}
capabilityElement.appendChild( wfsLayersElem );
}
}

//add the xml content for the individual layers/styles
QgsDebugMsg( "calling layersAndStylesCapabilities" );
if ( mConfigParser )
{
mConfigParser->layersAndStylesCapabilities( capabilityElement, doc );
mConfigParser->layersAndStylesCapabilities( capabilityElement, doc, version, fullProjectInformation );
}
QgsDebugMsg( "layersAndStylesCapabilities returned" );

Expand Down
6 changes: 4 additions & 2 deletions src/mapserver/qgswmsserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ class QgsWMSServer
/**Constructor. Takes parameter map and a pointer to a renderer object (does not take ownership)*/
QgsWMSServer( QMap<QString, QString> parameters, QgsMapRenderer* renderer );
~QgsWMSServer();
/**Returns an XML file with the capabilities description (as described in the WMS specs)*/
QDomDocument getCapabilities( QString version = "1.3.0" );
/**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 fullProjectInformation If true: add extended project information (does not validate against WMS schema)*/
QDomDocument getCapabilities( QString version = "1.3.0", bool fullProjectInformation = false );
/**Returns the map legend as an image (or a null pointer in case of error). The caller takes ownership
of the image object*/
QImage* getLegendGraphics();
Expand Down