Skip to content

Commit

Permalink
qgswfsgetcapabilities: Restore previous empty bounding box behavior
Browse files Browse the repository at this point in the history
According to the WFS 1.1.0 specs "The <WGS84BoundingBox> element is
used to indicate the edges of an enclosing rectangle in decimal
degrees of latitude and longitude in WGS84" but the expected behavior
is not specified when the data are empty.

Up to QGIS 3.32, QGIS server returned:
```
<ows:WGS84BoundingBox dimensions="2">
<ows:LowerCorner>0 0</ows:LowerCorner>
<ows:UpperCorner>0 0</ows:UpperCorner>
```

However, as a side effect of a change in `QGSRectangle` (see:
#54646), QGIS server now returns
since the 3.34 version:
```
<ows:WGS84BoundingBox dimensions="2">
<ows:LowerCorner>inf inf</ows:LowerCorner>
<ows:UpperCorner>-inf -inf</ows:UpperCorner>
```

This changes restores the QGIS 3.32 behavior.
  • Loading branch information
ptitjano authored and lbartoletti committed Feb 2, 2024
1 parent adcd4e5 commit 44e6e78
Show file tree
Hide file tree
Showing 5 changed files with 832 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/server/services/wfs/qgswfsgetcapabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ namespace QgsWfs
//transform the layers native CRS into WGS84
const QgsCoordinateReferenceSystem wgs84 = QgsCoordinateReferenceSystem::fromOgcWmsCrs( geoEpsgCrsAuthId() );
const int wgs84precision = 6;
QgsRectangle wgs84BoundingRect;
QgsRectangle wgs84BoundingRect( 0, 0, 0, 0 );
if ( !layerExtent.isNull() )
{
const QgsCoordinateTransform exGeoTransform( layer->crs(), wgs84, project );
Expand All @@ -592,7 +592,7 @@ namespace QgsWfs
}
catch ( const QgsCsException & )
{
wgs84BoundingRect = QgsRectangle();
wgs84BoundingRect = QgsRectangle( 0, 0, 0, 0 );
}
}

Expand Down
22 changes: 22 additions & 0 deletions tests/src/python/test_qgsserver_wfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,28 @@ def test_wfs_getcapabilities_100_url(self):
self.assertEqual(
"onlineResource=\"my_wfs_advertised_url\"" in item, True)

def test_wfs_getcapabilities_110_no_data(self):
"""Check that GetCapabilities response is correct if a layer
does not contain data"""

project = self.testdata_path + "test_wfs_no_data.qgs"
self.assertTrue(os.path.exists(project), "Project file not found: " + project)

query_string = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(project),
"SERVICE": "WFS",
"VERSION": "1.1.0",
"REQUEST": "GetCapabilities"
}.items())])

header, body = self._execute_request(query_string)

self.result_compare(
"wfs_getCapabilities_1_1_0_no_data.txt",
f"request {query_string} failed.\n Query: GetCapabilities",
header, body
)

def result_compare(self, file_name, error_msg_header, header, body):

self.assert_headers(header, body)
Expand Down
Binary file added tests/testdata/qgis_server/test_wfs_no_data.gpkg
Binary file not shown.

0 comments on commit 44e6e78

Please sign in to comment.