Skip to content
Permalink
Browse files
Publish layer titles and abstracts in WMS capabilities
  • Loading branch information
mhugent committed Dec 15, 2011
1 parent 3f7def9 commit bea1a4667aa977a45746c8e54d08aeafecedbecf
Showing with 22 additions and 18 deletions.
  1. +6 −16 src/mapserver/qgsconfigparser.cpp
  2. +1 −1 src/mapserver/qgsconfigparser.h
  3. +15 −1 src/mapserver/qgsprojectparser.cpp
@@ -363,44 +363,34 @@ void QgsConfigParser::appendCRSElementsToLayer( QDomElement& layerElement, QDomD

//insert the CRS elements after the title element to be in accordance with the WMS 1.3 specification
QDomElement titleElement = layerElement.firstChildElement( "Title" );
QDomElement abstractElement = layerElement.firstChildElement( "Abstract" );
QDomElement CRSPrecedingElement = abstractElement.isNull() ? titleElement : abstractElement; //last element before the CRS elements

//In case the number of advertised CRS is constrained
QStringList constrainedCrsList = supportedOutputCrsList();
if ( constrainedCrsList.size() > 0 )
{
for ( int i = constrainedCrsList.size() - 1; i >= 0; --i )
{
appendCRSElementToLayer( layerElement, titleElement, constrainedCrsList.at( i ), doc );
#if 0
QDomElement crsElement = doc.createElement( "CRS" );
QDomText crsText = doc.createTextNode( constrainedCrsList.at( i ) );
crsElement.appendChild( crsText );
layerElement.insertAfter( crsElement, titleElement );
#endif
appendCRSElementToLayer( layerElement, CRSPrecedingElement, constrainedCrsList.at( i ), doc );
}
}
else //no crs constraint
{
foreach( QString crs, crsList )
{
appendCRSElementToLayer( layerElement, titleElement, crs, doc );
#if 0
QDomElement crsElement = doc.createElement( "CRS" );
QDomText crsText = doc.createTextNode( *crsIt );
crsElement.appendChild( crsText );
layerElement.insertAfter( crsElement, titleElement );
#endif
appendCRSElementToLayer( layerElement, CRSPrecedingElement, crs, doc );
}
}
}

void QgsConfigParser::appendCRSElementToLayer( QDomElement& layerElement, const QDomElement& titleElement, const QString& crsText, QDomDocument& doc ) const
void QgsConfigParser::appendCRSElementToLayer( QDomElement& layerElement, const QDomElement& precedingElement, const QString& crsText, QDomDocument& doc ) const
{
QString version = doc.documentElement().attribute( "version" );
QDomElement crsElement = doc.createElement( version == "1.1.1" ? "SRS" : "CRS" );
QDomText crsTextNode = doc.createTextNode( crsText );
crsElement.appendChild( crsTextNode );
layerElement.insertAfter( crsElement, titleElement );
layerElement.insertAfter( crsElement, precedingElement );
}

QgsComposition* QgsConfigParser::createPrintComposition( const QString& composerTemplate, QgsMapRenderer* mapRenderer, const QMap< QString, QString >& parameterMap ) const
@@ -170,7 +170,7 @@ class QgsConfigParser
@return true in case of success*/
bool crsSetForLayer( const QDomElement& layerElement, QSet<QString> &crsSet ) const;
void appendCRSElementsToLayer( QDomElement& layerElement, QDomDocument& doc, const QStringList &crsList ) const;
void appendCRSElementToLayer( QDomElement& layerElement, const QDomElement& titleElement, const QString& crsText, QDomDocument& doc ) const;
void appendCRSElementToLayer( QDomElement& layerElement, const QDomElement& precedingElement, const QString& crsText, QDomDocument& doc ) const;

void setDefaultLegendSettings();
};
@@ -239,10 +239,24 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
layerElem.appendChild( nameElem );

QDomElement titleElem = doc.createElement( "Title" );
QDomText titleText = doc.createTextNode( currentLayer->name() );
QString titleName = currentLayer->title();
if ( titleName.isEmpty() )
{
titleName = currentLayer->name();
}
QDomText titleText = doc.createTextNode( titleName );
titleElem.appendChild( titleText );
layerElem.appendChild( titleElem );

QString abstract = currentLayer->abstract();
if ( !abstract.isEmpty() )
{
QDomElement abstractElem = doc.createElement( "Abstract" );
QDomText abstractText = doc.createTextNode( abstract );
abstractElem.appendChild( abstractText );
layerElem.appendChild( abstractElem );
}

//CRS
QStringList crsList = createCRSListForLayer( currentLayer );
appendCRSElementsToLayer( layerElem, doc, crsList );

0 comments on commit bea1a46

Please sign in to comment.