Skip to content

Commit

Permalink
Publish layer titles and abstracts in WMS capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Dec 15, 2011
1 parent 3f7def9 commit bea1a46
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
22 changes: 6 additions & 16 deletions src/mapserver/qgsconfigparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgsconfigparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down
16 changes: 15 additions & 1 deletion src/mapserver/qgsprojectparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit bea1a46

Please sign in to comment.