mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
[server][bugfix][wfs] Allow CRS in BBOX
Fixes #17977 - QGIS server 2.99 doesn't handles BBOX parameter on WFS request
This commit is contained in:
parent
998c67d3ff
commit
1f2109a51f
@ -658,12 +658,39 @@ namespace QgsWfs
|
||||
|
||||
if ( paramContainsBbox )
|
||||
{
|
||||
// get bbox corners
|
||||
QString bbox = mWfsParameters.bbox();
|
||||
|
||||
// get bbox extent
|
||||
QgsRectangle extent = mWfsParameters.bboxAsRectangle();
|
||||
|
||||
// handle WFS 1.1.0 optional CRS
|
||||
if ( mWfsParameters.bbox().split( ',' ).size() == 5 && ! mWfsParameters.srsName().isEmpty() )
|
||||
{
|
||||
QString crs( mWfsParameters.bbox().split( ',' )[4] );
|
||||
if ( crs != mWfsParameters.srsName() )
|
||||
{
|
||||
QgsCoordinateReferenceSystem sourceCrs( crs );
|
||||
QgsCoordinateReferenceSystem destinationCrs( mWfsParameters.srsName() );
|
||||
if ( sourceCrs.isValid() && destinationCrs.isValid( ) )
|
||||
{
|
||||
QgsGeometry extentGeom = QgsGeometry::fromRect( extent );
|
||||
QgsCoordinateTransform transform;
|
||||
transform.setSourceCrs( sourceCrs );
|
||||
transform.setDestinationCrs( destinationCrs );
|
||||
try
|
||||
{
|
||||
if ( extentGeom.transform( transform ) == 0 )
|
||||
{
|
||||
extent = QgsRectangle( extentGeom.boundingBox() );
|
||||
}
|
||||
}
|
||||
catch ( QgsException &cse )
|
||||
{
|
||||
Q_UNUSED( cse );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set feature request filter rectangle
|
||||
QList<getFeatureQuery>::iterator qIt = request.queries.begin();
|
||||
for ( ; qIt != request.queries.end(); ++qIt )
|
||||
|
@ -384,8 +384,8 @@ namespace QgsWfs
|
||||
if ( !bbox.isEmpty() )
|
||||
{
|
||||
QStringList corners = bbox.split( ',' );
|
||||
|
||||
if ( corners.size() == 4 )
|
||||
// We need at least 4 elements, an optional fifth could be the CRS in WFS 1.1.0 BBOX
|
||||
if ( corners.size() >= 4 )
|
||||
{
|
||||
double d[4];
|
||||
bool ok;
|
||||
@ -402,6 +402,7 @@ namespace QgsWfs
|
||||
}
|
||||
|
||||
extent = QgsRectangle( d[0], d[1], d[2], d[3] );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -44,18 +44,26 @@ class TestQgsServerWFS(QgsServerTestBase):
|
||||
|
||||
"""QGIS Server WFS Tests"""
|
||||
|
||||
def wfs_request_compare(self, request, version=''):
|
||||
def wfs_request_compare(self, request, version='', extra_query_string='', reference_base_name=None):
|
||||
project = self.testdata_path + "test_project_wfs.qgs"
|
||||
assert os.path.exists(project), "Project file not found: " + project
|
||||
|
||||
query_string = '?MAP=%s&SERVICE=WFS&REQUEST=%s' % (urllib.parse.quote(project), request)
|
||||
if version:
|
||||
query_string += '&VERSION=%s' % version
|
||||
|
||||
if extra_query_string:
|
||||
query_string += '&%s' % extra_query_string
|
||||
|
||||
header, body = self._execute_request(query_string)
|
||||
self.assert_headers(header, body)
|
||||
response = header + body
|
||||
|
||||
reference_name = 'wfs_' + request.lower()
|
||||
if reference_base_name is not None:
|
||||
reference_name = reference_base_name
|
||||
else:
|
||||
reference_name = 'wfs_' + request.lower()
|
||||
|
||||
if version == '1.0.0':
|
||||
reference_name += '_1_0_0'
|
||||
reference_name += '.txt'
|
||||
@ -247,6 +255,19 @@ class TestQgsServerWFS(QgsServerTestBase):
|
||||
for id, req in tests:
|
||||
self.wfs_getfeature_post_compare(id, req)
|
||||
|
||||
def test_getFeatureBBOX(self):
|
||||
"""Test with (1.1.0) and without (1.0.0) CRS"""
|
||||
|
||||
self.wfs_request_compare("GetFeature", '1.0.0', "SRSNAME=EPSG:4326&TYPENAME=testlayer&RESULTTYPE=hits&BBOX=8.20347,44.901471,8.2035354,44.901493,EPSG:4326", 'wfs_getFeature_1_0_0_epsgbbox_1_feature')
|
||||
self.wfs_request_compare("GetFeature", '1.0.0', "SRSNAME=EPSG:4326&TYPENAME=testlayer&RESULTTYPE=hits&BBOX=8.203127,44.9012765,8.204138,44.901632,EPSG:4326", 'wfs_getFeature_1_0_0_epsgbbox_3_feature')
|
||||
self.wfs_request_compare("GetFeature", '1.1.0', "SRSNAME=EPSG:4326&TYPENAME=testlayer&RESULTTYPE=hits&BBOX=8.20347,44.901471,8.2035354,44.901493,EPSG:4326", 'wfs_getFeature_1_1_0_epsgbbox_1_feature')
|
||||
self.wfs_request_compare("GetFeature", '1.1.0', "SRSNAME=EPSG:4326&TYPENAME=testlayer&RESULTTYPE=hits&BBOX=8.203127,44.9012765,8.204138,44.901632,EPSG:4326", 'wfs_getFeature_1_1_0_epsgbbox_3_feature')
|
||||
|
||||
self.wfs_request_compare("GetFeature", '1.0.0', "SRSNAME=EPSG:4326&TYPENAME=testlayer&RESULTTYPE=hits&BBOX=913144,5605992,913303,5606048,EPSG:3857", 'wfs_getFeature_1_0_0_epsgbbox_3_feature_3857')
|
||||
self.wfs_request_compare("GetFeature", '1.0.0', "SRSNAME=EPSG:4326&TYPENAME=testlayer&RESULTTYPE=hits&BBOX=913206,5606024,913213,5606026,EPSG:3857", 'wfs_getFeature_1_0_0_epsgbbox_1_feature_3857')
|
||||
self.wfs_request_compare("GetFeature", '1.1.0', "SRSNAME=EPSG:4326&TYPENAME=testlayer&RESULTTYPE=hits&BBOX=913144,5605992,913303,5606048,EPSG:3857", 'wfs_getFeature_1_1_0_epsgbbox_3_feature_3857')
|
||||
self.wfs_request_compare("GetFeature", '1.1.0', "SRSNAME=EPSG:4326&TYPENAME=testlayer&RESULTTYPE=hits&BBOX=913206,5606024,913213,5606026,EPSG:3857", 'wfs_getFeature_1_1_0_epsgbbox_1_feature_3857')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
6
tests/testdata/qgis_server/wfs_getFeature_1_0_0_epsgbbox_1_feature_1_0_0.txt
vendored
Normal file
6
tests/testdata/qgis_server/wfs_getFeature_1_0_0_epsgbbox_1_feature_1_0_0.txt
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
Content-Type: text/xml; subtype=gml/2.1.2; charset=utf-8
|
||||
|
||||
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:qgs="http://www.qgis.org/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd http://www.qgis.org/gml ?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test_project_wfs.qgs&SRSNAME=EPSG:4326&RESULTTYPE=hits&SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=testlayer&OUTPUTFORMAT=XMLSCHEMA"
|
||||
timeStamp="2018-01-30T16:59:26"
|
||||
numberOfFeatures="1">
|
||||
</wfs:FeatureCollection>
|
6
tests/testdata/qgis_server/wfs_getFeature_1_0_0_epsgbbox_1_feature_3857_1_0_0.txt
vendored
Normal file
6
tests/testdata/qgis_server/wfs_getFeature_1_0_0_epsgbbox_1_feature_3857_1_0_0.txt
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
Content-Type: text/xml; subtype=gml/2.1.2; charset=utf-8
|
||||
|
||||
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:qgs="http://www.qgis.org/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd http://www.qgis.org/gml ?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test_project_wfs.qgs&SRSNAME=EPSG:4326&RESULTTYPE=hits&SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=testlayer&OUTPUTFORMAT=XMLSCHEMA"
|
||||
timeStamp="2018-01-30T16:59:26"
|
||||
numberOfFeatures="1">
|
||||
</wfs:FeatureCollection>
|
6
tests/testdata/qgis_server/wfs_getFeature_1_0_0_epsgbbox_3_feature_1_0_0.txt
vendored
Normal file
6
tests/testdata/qgis_server/wfs_getFeature_1_0_0_epsgbbox_3_feature_1_0_0.txt
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
Content-Type: text/xml; subtype=gml/2.1.2; charset=utf-8
|
||||
|
||||
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:qgs="http://www.qgis.org/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd http://www.qgis.org/gml ?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test_project_wfs.qgs&SRSNAME=EPSG:4326&RESULTTYPE=hits&SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=testlayer&OUTPUTFORMAT=XMLSCHEMA"
|
||||
timeStamp="2018-01-30T16:59:26"
|
||||
numberOfFeatures="3">
|
||||
</wfs:FeatureCollection>
|
6
tests/testdata/qgis_server/wfs_getFeature_1_0_0_epsgbbox_3_feature_3857_1_0_0.txt
vendored
Normal file
6
tests/testdata/qgis_server/wfs_getFeature_1_0_0_epsgbbox_3_feature_3857_1_0_0.txt
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
Content-Type: text/xml; subtype=gml/2.1.2; charset=utf-8
|
||||
|
||||
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:qgs="http://www.qgis.org/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd http://www.qgis.org/gml ?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test_project_wfs.qgs&SRSNAME=EPSG:4326&RESULTTYPE=hits&SERVICE=WFS&VERSION=1.0.0&REQUEST=DescribeFeatureType&TYPENAME=testlayer&OUTPUTFORMAT=XMLSCHEMA"
|
||||
timeStamp="2018-01-30T16:59:26"
|
||||
numberOfFeatures="3">
|
||||
</wfs:FeatureCollection>
|
6
tests/testdata/qgis_server/wfs_getFeature_1_1_0_epsgbbox_1_feature.txt
vendored
Normal file
6
tests/testdata/qgis_server/wfs_getFeature_1_1_0_epsgbbox_1_feature.txt
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
Content-Type: text/xml; subtype=gml/3.1.1; charset=utf-8
|
||||
|
||||
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:qgs="http://www.qgis.org/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd http://www.qgis.org/gml ?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test_project_wfs.qgs&SRSNAME=EPSG:4326&RESULTTYPE=hits&SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=testlayer&OUTPUTFORMAT=text/xml; subtype%3Dgml/3.1.1"
|
||||
timeStamp="2018-01-30T16:59:26"
|
||||
numberOfFeatures="1">
|
||||
</wfs:FeatureCollection>
|
6
tests/testdata/qgis_server/wfs_getFeature_1_1_0_epsgbbox_1_feature_3857.txt
vendored
Normal file
6
tests/testdata/qgis_server/wfs_getFeature_1_1_0_epsgbbox_1_feature_3857.txt
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
Content-Type: text/xml; subtype=gml/3.1.1; charset=utf-8
|
||||
|
||||
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:qgs="http://www.qgis.org/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd http://www.qgis.org/gml ?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test_project_wfs.qgs&SRSNAME=EPSG:4326&RESULTTYPE=hits&SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=testlayer&OUTPUTFORMAT=text/xml; subtype%3Dgml/3.1.1"
|
||||
timeStamp="2018-01-30T16:59:26"
|
||||
numberOfFeatures="1">
|
||||
</wfs:FeatureCollection>
|
6
tests/testdata/qgis_server/wfs_getFeature_1_1_0_epsgbbox_3_feature.txt
vendored
Normal file
6
tests/testdata/qgis_server/wfs_getFeature_1_1_0_epsgbbox_3_feature.txt
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
Content-Type: text/xml; subtype=gml/3.1.1; charset=utf-8
|
||||
|
||||
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:qgs="http://www.qgis.org/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd http://www.qgis.org/gml ?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test_project_wfs.qgs&SRSNAME=EPSG:4326&RESULTTYPE=hits&SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=testlayer&OUTPUTFORMAT=text/xml; subtype%3Dgml/3.1.1"
|
||||
timeStamp="2018-01-30T16:59:26"
|
||||
numberOfFeatures="3">
|
||||
</wfs:FeatureCollection>
|
6
tests/testdata/qgis_server/wfs_getFeature_1_1_0_epsgbbox_3_feature_3857.txt
vendored
Normal file
6
tests/testdata/qgis_server/wfs_getFeature_1_1_0_epsgbbox_3_feature_3857.txt
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
Content-Type: text/xml; subtype=gml/3.1.1; charset=utf-8
|
||||
|
||||
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:qgs="http://www.qgis.org/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd http://www.qgis.org/gml ?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test_project_wfs.qgs&SRSNAME=EPSG:4326&RESULTTYPE=hits&SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=testlayer&OUTPUTFORMAT=text/xml; subtype%3Dgml/3.1.1"
|
||||
timeStamp="2018-01-30T16:59:26"
|
||||
numberOfFeatures="3">
|
||||
</wfs:FeatureCollection>
|
Loading…
x
Reference in New Issue
Block a user