Skip to content
Permalink
Browse files

Keep name and add metadata and keywordlist for root layer

  • Loading branch information
pblottiere committed Nov 16, 2017
1 parent f52300d commit 0a38003ba5e8bb5beaac72201d771093e6479bbd
Showing with 58 additions and 30 deletions.
  1. +58 −30 src/server/services/wms/qgswmsgetcapabilities.cpp
@@ -84,6 +84,7 @@ namespace QgsWms
const QgsLayerTreeGroup *layerTreeGroup,
bool projectSettings );

void addKeywordListElement( const QgsProject *project, QDomDocument &doc, QDomElement &parent );
}

void writeGetCapabilities( QgsServerInterface *serverIface, const QgsProject *project,
@@ -225,8 +226,6 @@ namespace QgsWms
QDomElement getServiceElement( QDomDocument &doc, const QgsProject *project, const QString &version,
const QgsServerRequest &request )
{
bool sia2045 = QgsServerProjectUtils::wmsInfoFormatSia2045( *project );

//Service element
QDomElement serviceElem = doc.createElement( QStringLiteral( "Service" ) );

@@ -254,34 +253,7 @@ namespace QgsWms
serviceElem.appendChild( abstractElem );
}

QDomElement keywordsElem = doc.createElement( QStringLiteral( "KeywordList" ) );
//add default keyword
QDomElement keywordElem = doc.createElement( QStringLiteral( "Keyword" ) );
keywordElem.setAttribute( QStringLiteral( "vocabulary" ), QStringLiteral( "ISO" ) );
QDomText keywordText = doc.createTextNode( QStringLiteral( "infoMapAccessService" ) );
keywordElem.appendChild( keywordText );
keywordsElem.appendChild( keywordElem );
serviceElem.appendChild( keywordsElem );
QStringList keywords = QgsServerProjectUtils::owsServiceKeywords( *project );
if ( !keywords.isEmpty() )
{
for ( int i = 0; i < keywords.size(); ++i )
{
QString keyword = keywords.at( i );
if ( !keyword.isEmpty() )
{
keywordElem = doc.createElement( QStringLiteral( "Keyword" ) );
keywordText = doc.createTextNode( keyword );
keywordElem.appendChild( keywordText );
if ( sia2045 )
{
keywordElem.setAttribute( QStringLiteral( "vocabulary" ), QStringLiteral( "SIA_Geo405" ) );
}
keywordsElem.appendChild( keywordElem );
}
}
serviceElem.appendChild( keywordsElem );
}
addKeywordListElement( project, doc, serviceElem );

QString onlineResource = QgsServerProjectUtils::owsServiceOnlineResource( *project );
if ( onlineResource.isEmpty() )
@@ -782,6 +754,28 @@ namespace QgsWms
layerParentAbstElem.appendChild( layerParentAbstText );
layerParentElem.appendChild( layerParentAbstElem );

// Root Layer name
QDomElement layerParentNameElem = doc.createElement( QStringLiteral( "Name" ) );
QString rootName = QgsServerProjectUtils::wmsRootName( *project );
if ( rootName.isEmpty() )
{
QDomText layerParentNameText = doc.createTextNode( project->title() );
layerParentNameElem.appendChild( layerParentNameText );
}
else
{
QDomText layerParentNameText = doc.createTextNode( rootName );
layerParentNameElem.appendChild( layerParentNameText );
}
layerParentElem.appendChild( layerParentNameElem );

// Keyword list
addKeywordListElement( project, doc, layerParentElem );

// Metadata (empty but needed for OGC tests RECOMMENDATIONS)
QDomElement metaUrlElem = doc.createElement( QStringLiteral( "MetadataURL" ) );
layerParentElem.appendChild( metaUrlElem );

// Root Layer tree name
if ( projectSettings )
{
@@ -1725,6 +1719,40 @@ namespace QgsWms
}
}

void addKeywordListElement( const QgsProject *project, QDomDocument &doc, QDomElement &parent )
{
bool sia2045 = QgsServerProjectUtils::wmsInfoFormatSia2045( *project );

QDomElement keywordsElem = doc.createElement( QStringLiteral( "KeywordList" ) );
//add default keyword
QDomElement keywordElem = doc.createElement( QStringLiteral( "Keyword" ) );
keywordElem.setAttribute( QStringLiteral( "vocabulary" ), QStringLiteral( "ISO" ) );
QDomText keywordText = doc.createTextNode( QStringLiteral( "infoMapAccessService" ) );
keywordElem.appendChild( keywordText );
keywordsElem.appendChild( keywordElem );
parent.appendChild( keywordsElem );
QStringList keywords = QgsServerProjectUtils::owsServiceKeywords( *project );
if ( !keywords.isEmpty() )
{
for ( int i = 0; i < keywords.size(); ++i )
{
QString keyword = keywords.at( i );
if ( !keyword.isEmpty() )
{
keywordElem = doc.createElement( QStringLiteral( "Keyword" ) );
keywordText = doc.createTextNode( keyword );
keywordElem.appendChild( keywordText );
if ( sia2045 )
{
keywordElem.setAttribute( QStringLiteral( "vocabulary" ), QStringLiteral( "SIA_Geo405" ) );
}
keywordsElem.appendChild( keywordElem );
}
}

parent.appendChild( keywordsElem );
}
}
}


0 comments on commit 0a38003

Please sign in to comment.
You can’t perform that action at this time.