Skip to content

Commit

Permalink
Merge pull request #6867 from pblottiere/bugfix_nobbox
Browse files Browse the repository at this point in the history
[server] CRS position in GetCapabilities document
  • Loading branch information
rldhont committed May 2, 2018
2 parents f019bc0 + 1afe0d1 commit 956d669
Show file tree
Hide file tree
Showing 4 changed files with 936 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/server/services/wms/qgswmsgetcapabilities.cpp
Expand Up @@ -1205,6 +1205,13 @@ namespace QgsWms
QDomElement abstractElement = layerElement.firstChildElement( QStringLiteral( "Abstract" ) );
QDomElement CRSPrecedingElement = abstractElement.isNull() ? titleElement : abstractElement; //last element before the CRS elements

if ( CRSPrecedingElement.isNull() )
{
// keyword list element is never empty
const QDomElement keyElement = layerElement.firstChildElement( QStringLiteral( "KeywordList" ) );
CRSPrecedingElement = keyElement;
}

//In case the number of advertised CRS is constrained
if ( !constrainedCrsList.isEmpty() )
{
Expand Down
17 changes: 17 additions & 0 deletions tests/src/python/test_qgsserver_wms.py
Expand Up @@ -146,6 +146,23 @@ def test_project_wms_inspire(self):
for request in ('GetCapabilities',):
self.wms_inspire_request_compare(request)

def test_wms_getcapabilities_without_title(self):
# Empty title in project leads to a Layer element without Name, Title
# and Abstract tags. However, it should still have a CRS and a BBOX
# according to OGC specifications tests.
project = os.path.join(self.testdata_path, "test_project_without_title.qgs")
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(project),
"SERVICE": "WMS",
"VERSION": "1.3.0",
"REQUEST": "GetCapabilities",
"STYLES": ""
}.items())])

r, h = self._result(self._execute_request(qs))

self.wms_request_compare('GetCapabilities', reference_file='wms_getcapabilities_without_title', project='test_project_without_title.qgs')

def test_wms_getcapabilities_url(self):
# empty url in project
project = os.path.join(self.testdata_path, "test_project_without_urls.qgs")
Expand Down

0 comments on commit 956d669

Please sign in to comment.