From 59fd8df336f9ba0160ee79935741431ab9f80827 Mon Sep 17 00:00:00 2001 From: Alessandro Pasotti Date: Tue, 22 Jan 2019 14:28:36 +0100 Subject: [PATCH] Fix server WFS TYPENAME filter in describeFeatureType Fixes #20198 with tests --- .../wfs/qgswfsdescribefeaturetype.cpp | 14 +- tests/src/python/test_qgsserver_wfs.py | 17 +- .../test_project_wms_grouped_layers.qgs | 1139 ++++++++--------- ...tureType_1_0_0_typename_as_areas_1_0_0.txt | 38 + ...FeatureType_1_0_0_typename_empty_1_0_0.txt | 112 ++ ...FeatureType_1_0_0_typename_wrong_1_0_0.txt | 6 + ...ibeFeatureType_1_1_0_typename_as_areas.txt | 38 + ...scribeFeatureType_1_1_0_typename_empty.txt | 112 ++ ...scribeFeatureType_1_1_0_typename_wrong.txt | 6 + 9 files changed, 870 insertions(+), 612 deletions(-) create mode 100644 tests/testdata/qgis_server/wfs_describeFeatureType_1_0_0_typename_as_areas_1_0_0.txt create mode 100644 tests/testdata/qgis_server/wfs_describeFeatureType_1_0_0_typename_empty_1_0_0.txt create mode 100644 tests/testdata/qgis_server/wfs_describeFeatureType_1_0_0_typename_wrong_1_0_0.txt create mode 100644 tests/testdata/qgis_server/wfs_describeFeatureType_1_1_0_typename_as_areas.txt create mode 100644 tests/testdata/qgis_server/wfs_describeFeatureType_1_1_0_typename_empty.txt create mode 100644 tests/testdata/qgis_server/wfs_describeFeatureType_1_1_0_typename_wrong.txt diff --git a/src/server/services/wfs/qgswfsdescribefeaturetype.cpp b/src/server/services/wfs/qgswfsdescribefeaturetype.cpp index fd9028525b1..7d77905f590 100644 --- a/src/server/services/wfs/qgswfsdescribefeaturetype.cpp +++ b/src/server/services/wfs/qgswfsdescribefeaturetype.cpp @@ -130,19 +130,7 @@ namespace QgsWfs } else { - QString typeNames = request.parameter( QStringLiteral( "TYPENAME" ) ); - if ( !typeNames.isEmpty() ) - { - QStringList typeNameSplit = typeNames.split( ',' ); - for ( int i = 0; i < typeNameSplit.size(); ++i ) - { - QString typeName = typeNameSplit.at( i ).trimmed(); - if ( typeName.contains( ':' ) ) - typeNameList << typeName.section( ':', 1, 1 ); - else - typeNameList << typeName; - } - } + typeNameList = wfsParameters.typeNames(); } QStringList wfsLayerIds = QgsServerProjectUtils::wfsLayerIds( *project ); diff --git a/tests/src/python/test_qgsserver_wfs.py b/tests/src/python/test_qgsserver_wfs.py index 2d1c07f73d1..c74549239e6 100644 --- a/tests/src/python/test_qgsserver_wfs.py +++ b/tests/src/python/test_qgsserver_wfs.py @@ -44,10 +44,10 @@ class TestQgsServerWFS(QgsServerTestBase): """QGIS Server WFS Tests""" # Set to True in child classes to re-generate reference files for this class - #regenerate_reference = True + regenerate_reference = False - def wfs_request_compare(self, request, version='', extra_query_string='', reference_base_name=None): - project = self.testdata_path + "test_project_wfs.qgs" + def wfs_request_compare(self, request, version='', extra_query_string='', reference_base_name=None, project_file="test_project_wfs.qgs"): + project = self.testdata_path + project_file assert os.path.exists(project), "Project file not found: " + project query_string = '?MAP=%s&SERVICE=WFS&REQUEST=%s' % (urllib.parse.quote(project), request) @@ -385,6 +385,17 @@ class TestQgsServerWFS(QgsServerTestBase): self.wfs_request_compare("GetFeature", '1.0.0', "SRSNAME=EPSG:4326&TYPENAME=testlayer&EXP_FILTER=intersects($geometry, geom_from_gml(' 8.20344750430995617,44.9013881888184514 8.20347909100379269,44.90140004005827024'))", 'wfs_getFeature_1_0_0_EXP_FILTER_gml_bbox_three') self.wfs_request_compare("GetFeature", '1.0.0', "SRSNAME=EPSG:4326&TYPENAME=testlayer&EXP_FILTER=intersects($geometry, geom_from_gml(' 8.20348458304175665,44.90147459621791626 8.20351616973559317,44.9014864474577351'))", 'wfs_getFeature_1_0_0_EXP_FILTER_gml_bbox_one') + def test_describeFeatureType(self): + """Test DescribeFeatureType with TYPENAME filters""" + + project_file = "test_project_wms_grouped_layers.qgs" + self.wfs_request_compare("DescribeFeatureType", '1.0.0', "TYPENAME=as_areas&", 'wfs_describeFeatureType_1_0_0_typename_as_areas', project_file=project_file) + self.wfs_request_compare("DescribeFeatureType", '1.1.0', "TYPENAME=as_areas&", 'wfs_describeFeatureType_1_1_0_typename_as_areas', project_file=project_file) + self.wfs_request_compare("DescribeFeatureType", '1.0.0', "", 'wfs_describeFeatureType_1_0_0_typename_empty', project_file=project_file) + self.wfs_request_compare("DescribeFeatureType", '1.1.0', "", 'wfs_describeFeatureType_1_1_0_typename_empty', project_file=project_file) + self.wfs_request_compare("DescribeFeatureType", '1.0.0', "TYPENAME=does_not_exist&", 'wfs_describeFeatureType_1_0_0_typename_wrong', project_file=project_file) + self.wfs_request_compare("DescribeFeatureType", '1.1.0', "TYPENAME=does_not_exist&", 'wfs_describeFeatureType_1_1_0_typename_wrong', project_file=project_file) + if __name__ == '__main__': unittest.main() diff --git a/tests/testdata/qgis_server/test_project_wms_grouped_layers.qgs b/tests/testdata/qgis_server/test_project_wms_grouped_layers.qgs index 9745efa33cb..63cda3f43af 100644 --- a/tests/testdata/qgis_server/test_project_wms_grouped_layers.qgs +++ b/tests/testdata/qgis_server/test_project_wms_grouped_layers.qgs @@ -1,5 +1,5 @@ - + QGIS Server - Grouped Layer @@ -19,25 +19,25 @@ - + - + - + - + - + - + - + @@ -48,12 +48,12 @@ as_symbols_3a1cdeef_9082_4d07_be5c_47c956bd7e76 - + - - - - + + + + @@ -79,112 +79,43 @@ 0 + - - + + - + - - + + - + - + - - - meters - - 613671.31718749995343387 - 5808474.67499999981373549 - 620973.87031250004656613 - 5814032.32500000018626451 - - 0 - - - +proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs - 2105 - 25832 - EPSG:25832 - ETRS89 / UTM zone 32N - utm - GRS80 - false - - - 0 - - - meters - - 613671.31718749995343387 - 5808474.67499999981373549 - 620973.87031250004656613 - 5814032.32500000018626451 - - 0 - - - +proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs - 2105 - 25832 - EPSG:25832 - ETRS89 / UTM zone 32N - utm - GRS80 - false - - - 0 - - - meters - - 613671.31718749995343387 - 5808474.67499999981373549 - 620973.87031250004656613 - 5814032.32500000018626451 - - 0 - - - +proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs - 2105 - 25832 - EPSG:25832 - ETRS89 / UTM zone 32N - utm - GRS80 - false - - - 0 - - + 614440.5625 5808607 @@ -248,10 +179,10 @@ 1 1 - + - - + + @@ -265,9 +196,9 @@ @@ -441,108 +372,108 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -562,7 +493,7 @@ - + 613845.1875 5810420 @@ -626,10 +557,10 @@ 1 1 - + - - + + @@ -650,9 +581,9 @@ @@ -770,76 +701,76 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - + @@ -859,7 +790,7 @@ - + 613794.8125 5800447 @@ -923,10 +854,10 @@ 1 1 - + - - + + @@ -947,9 +878,9 @@ @@ -960,26 +891,26 @@ - - - - + + + + - - - + + + - + @@ -987,17 +918,17 @@ 0 1 - + - + - + @@ -1183,147 +1114,147 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - @@ -1354,64 +1285,64 @@ def my_form_open(dialog, layer, feature): 0 generatedlayout - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + fid - + 611951 5797784.5 @@ -1475,14 +1406,14 @@ def my_form_open(dialog, layer, feature): 1 1 - + - - + + - - + + @@ -1496,15 +1427,15 @@ def my_form_open(dialog, layer, feature): - - + + @@ -1518,17 +1449,17 @@ def my_form_open(dialog, layer, feature): - - + + @@ -1542,9 +1473,9 @@ def my_form_open(dialog, layer, feature): @@ -1554,8 +1485,8 @@ def my_form_open(dialog, layer, feature): - - + + @@ -1563,17 +1494,17 @@ def my_form_open(dialog, layer, feature): 0 1 - + - + - + @@ -1619,46 +1550,46 @@ def my_form_open(dialog, layer, feature): - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - + - + - @@ -1689,22 +1620,22 @@ def my_form_open(dialog, layer, feature): 0 generatedlayout - - - - + + + + - - - - + + + + id - + 611425.600499999942258 5808334.13232080265879631 @@ -1755,10 +1686,10 @@ def my_form_open(dialog, layer, feature): gdal - - - - + + + + @@ -1766,13 +1697,13 @@ def my_form_open(dialog, layer, feature): 1 1 - 1 + 0 - + - + MinMax @@ -1799,7 +1730,7 @@ def my_form_open(dialog, layer, feature): - + 0 @@ -1813,106 +1744,122 @@ def my_form_open(dialog, layer, feature): - - m2 - meters - - false - 8 - - false - - - + + + true + + + 1 + + + None - false + false + + true + + + + 255 + 255 + 255 + 255 + 255 + 255 + 0 + + + as_areas_bbe3c71b_356c_49f5_9fc2_ae771bcdd467 + as_symbols_3a1cdeef_9082_4d07_be5c_47c956bd7e76 + cdb_labels_8ee74af8_e7ba_4d80_9e0d_5b0b956d3daf + cdb_lines_3f5c3c6d_db6d_4681_9291_7109f8d69f8b + + false + + + + + + + + + + + 1 + 8 + + + + + + + false + + false + + false + + + + + false + + conditions unknown + + GRS80 + + + MU + true + 2 + 1 - - false - - - false - - - - + 90 + 5000 + + 8 + 8 + 8 + 8 + + + - - false - - 5000 - 90 - - - - - 255 - 255 - 255 - 255 - 255 - 0 - 255 - - - GRS80 - - - - - - - false - - - - true - 2 - MU - - false - true - conditions unknown - None - - + false + + m2 + meters + - 30 - true 0 + 30 false - 0 - 50 true + 50 16 - false + 0 false + false + true - - - - - - - - true - - - 1 - - false - + + false + + + + + false + - diff --git a/tests/testdata/qgis_server/wfs_describeFeatureType_1_0_0_typename_as_areas_1_0_0.txt b/tests/testdata/qgis_server/wfs_describeFeatureType_1_0_0_typename_as_areas_1_0_0.txt new file mode 100644 index 00000000000..df7f64142e0 --- /dev/null +++ b/tests/testdata/qgis_server/wfs_describeFeatureType_1_0_0_typename_as_areas_1_0_0.txt @@ -0,0 +1,38 @@ +Content-Length: 1840 +Content-Type: text/xml; charset=utf-8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/testdata/qgis_server/wfs_describeFeatureType_1_0_0_typename_empty_1_0_0.txt b/tests/testdata/qgis_server/wfs_describeFeatureType_1_0_0_typename_empty_1_0_0.txt new file mode 100644 index 00000000000..72172068b91 --- /dev/null +++ b/tests/testdata/qgis_server/wfs_describeFeatureType_1_0_0_typename_empty_1_0_0.txt @@ -0,0 +1,112 @@ +Content-Length: 4894 +Content-Type: text/xml; charset=utf-8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/testdata/qgis_server/wfs_describeFeatureType_1_0_0_typename_wrong_1_0_0.txt b/tests/testdata/qgis_server/wfs_describeFeatureType_1_0_0_typename_wrong_1_0_0.txt new file mode 100644 index 00000000000..d7f2860ec40 --- /dev/null +++ b/tests/testdata/qgis_server/wfs_describeFeatureType_1_0_0_typename_wrong_1_0_0.txt @@ -0,0 +1,6 @@ +Content-Length: 422 +Content-Type: text/xml; charset=utf-8 + + + + diff --git a/tests/testdata/qgis_server/wfs_describeFeatureType_1_1_0_typename_as_areas.txt b/tests/testdata/qgis_server/wfs_describeFeatureType_1_1_0_typename_as_areas.txt new file mode 100644 index 00000000000..79346200925 --- /dev/null +++ b/tests/testdata/qgis_server/wfs_describeFeatureType_1_1_0_typename_as_areas.txt @@ -0,0 +1,38 @@ +Content-Length: 1841 +Content-Type: text/xml; charset=utf-8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/testdata/qgis_server/wfs_describeFeatureType_1_1_0_typename_empty.txt b/tests/testdata/qgis_server/wfs_describeFeatureType_1_1_0_typename_empty.txt new file mode 100644 index 00000000000..edfd5f1dee8 --- /dev/null +++ b/tests/testdata/qgis_server/wfs_describeFeatureType_1_1_0_typename_empty.txt @@ -0,0 +1,112 @@ +Content-Length: 4895 +Content-Type: text/xml; charset=utf-8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/testdata/qgis_server/wfs_describeFeatureType_1_1_0_typename_wrong.txt b/tests/testdata/qgis_server/wfs_describeFeatureType_1_1_0_typename_wrong.txt new file mode 100644 index 00000000000..6214d48d3a0 --- /dev/null +++ b/tests/testdata/qgis_server/wfs_describeFeatureType_1_1_0_typename_wrong.txt @@ -0,0 +1,6 @@ +Content-Length: 423 +Content-Type: text/xml; charset=utf-8 + + + +