Skip to content

Commit e2d1320

Browse files
committed
[BUGFIX] WFS GetCapabilities respons misses <keywords> key
Fixes #13037 WFS GetCapabilities respons misses <keywords> key Replace KeywordList by Keywords in WFS Getcapabilities and keywords in WCS GetCapabilities.
1 parent 4511cc4 commit e2d1320

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
lines changed

src/server/qgsserverprojectparser.cpp

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -418,33 +418,50 @@ void QgsServerProjectParser::serviceCapabilities( QDomElement& parentElement, QD
418418

419419
//keyword list
420420
QDomElement keywordListElem = propertiesElement.firstChildElement( "WMSKeywordList" );
421-
QDomElement wmsKeywordElem = doc.createElement( "KeywordList" );
422-
//add default keyword
423-
QDomElement keywordElem = doc.createElement( "Keyword" );
424-
keywordElem.setAttribute( "vocabulary", "ISO" );
425-
QDomText keywordText = doc.createTextNode( "infoMapAccessService" );
426-
if ( service.compare( "WFS", Qt::CaseInsensitive ) == 0 )
427-
keywordText = doc.createTextNode( "infoFeatureAccessService" );
428-
else if ( service.compare( "WCS", Qt::CaseInsensitive ) == 0 )
429-
keywordText = doc.createTextNode( "infoCoverageAccessService" );
430-
keywordElem.appendChild( keywordText );
431-
wmsKeywordElem.appendChild( keywordElem );
432-
serviceElem.appendChild( wmsKeywordElem );
433-
//add config keywords
434-
if ( !keywordListElem.isNull() && !keywordListElem.text().isEmpty() )
435-
{
436-
QDomNodeList keywordList = keywordListElem.elementsByTagName( "value" );
437-
for ( int i = 0; i < keywordList.size(); ++i )
421+
if ( service.compare( "WMS", Qt::CaseInsensitive ) == 0 )
422+
{
423+
QDomElement wmsKeywordElem = doc.createElement( "KeywordList" );
424+
//add default keyword
425+
QDomElement keywordElem = doc.createElement( "Keyword" );
426+
keywordElem.setAttribute( "vocabulary", "ISO" );
427+
QDomText keywordText = doc.createTextNode( "infoMapAccessService" );
428+
/* If WFS and WCS 2.0 is implemented
429+
if ( service.compare( "WFS", Qt::CaseInsensitive ) == 0 )
430+
keywordText = doc.createTextNode( "infoFeatureAccessService" );
431+
else if ( service.compare( "WCS", Qt::CaseInsensitive ) == 0 )
432+
keywordText = doc.createTextNode( "infoCoverageAccessService" );*/
433+
keywordElem.appendChild( keywordText );
434+
wmsKeywordElem.appendChild( keywordElem );
435+
serviceElem.appendChild( wmsKeywordElem );
436+
//add config keywords
437+
if ( !keywordListElem.isNull() && !keywordListElem.text().isEmpty() )
438438
{
439-
keywordElem = doc.createElement( "Keyword" );
440-
keywordText = doc.createTextNode( keywordList.at( i ).toElement().text() );
441-
keywordElem.appendChild( keywordText );
442-
if ( sia2045 )
439+
QDomNodeList keywordList = keywordListElem.elementsByTagName( "value" );
440+
for ( int i = 0; i < keywordList.size(); ++i )
443441
{
444-
keywordElem.setAttribute( "vocabulary", "SIA_Geo405" );
442+
keywordElem = doc.createElement( "Keyword" );
443+
keywordText = doc.createTextNode( keywordList.at( i ).toElement().text() );
444+
keywordElem.appendChild( keywordText );
445+
if ( sia2045 )
446+
{
447+
keywordElem.setAttribute( "vocabulary", "SIA_Geo405" );
448+
}
449+
wmsKeywordElem.appendChild( keywordElem );
445450
}
446-
wmsKeywordElem.appendChild( keywordElem );
447451
}
452+
} else if ( !keywordListElem.isNull() && !keywordListElem.text().isEmpty() ) {
453+
QDomNodeList keywordNodeList = keywordListElem.elementsByTagName( "value" );
454+
QStringList keywordList;
455+
for ( int i = 0; i < keywordNodeList.size(); ++i )
456+
{
457+
keywordList.push_back( keywordNodeList.at( i ).toElement().text() );
458+
}
459+
QDomElement wmsKeywordElem = doc.createElement( "Keywords" );
460+
if ( service.compare( "WCS", Qt::CaseInsensitive ) == 0 )
461+
wmsKeywordElem = doc.createElement( "keywords" );
462+
QDomText keywordText = doc.createTextNode( keywordList.join( ", " ) );
463+
wmsKeywordElem.appendChild( keywordText );
464+
serviceElem.appendChild( wmsKeywordElem );
448465
}
449466

450467
//OnlineResource element is mandatory according to the WMS specification

tests/testdata/qgis_server/wfs_getcapabilities.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ Content-Type: text/xml; charset=utf-8
66
<Name>WFS</Name>
77
<Title>QGIS TestProject</Title>
88
<Abstract>Some UTF8 text èòù</Abstract>
9-
<KeywordList>
10-
<Keyword vocabulary="ISO">infoFeatureAccessService</Keyword>
11-
</KeywordList>
129
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href=""/>
1310
<Fees>conditions unknown</Fees>
1411
<AccessConstraints>None</AccessConstraints>

0 commit comments

Comments
 (0)