Skip to content

Commit

Permalink
Fix server WFS TYPENAME filter in describeFeatureType
Browse files Browse the repository at this point in the history
Fixes #20198

with tests
  • Loading branch information
elpaso committed Jan 22, 2019
1 parent b129850 commit 59fd8df
Show file tree
Hide file tree
Showing 9 changed files with 861 additions and 603 deletions.
14 changes: 1 addition & 13 deletions src/server/services/wfs/qgswfsdescribefeaturetype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
17 changes: 14 additions & 3 deletions tests/src/python/test_qgsserver_wfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -385,6 +385,17 @@ def test_getFeature_EXP_FILTER_regression_20927(self):
self.wfs_request_compare("GetFeature", '1.0.0', "SRSNAME=EPSG:4326&TYPENAME=testlayer&EXP_FILTER=intersects($geometry, geom_from_gml('<gml:Box> <gml:coordinates cs=\",\" ts=\" \">8.20344750430995617,44.9013881888184514 8.20347909100379269,44.90140004005827024</gml:coordinates></gml:Box>'))", '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('<gml:Box> <gml:coordinates cs=\",\" ts=\" \">8.20348458304175665,44.90147459621791626 8.20351616973559317,44.9014864474577351</gml:coordinates></gml:Box>'))", '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()
1,121 changes: 534 additions & 587 deletions tests/testdata/qgis_server/test_project_wms_grouped_layers.qgs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Content-Length: 1840
Content-Type: text/xml; charset=utf-8

<schema xmlns:gml="http://www.opengis.net/gml" targetNamespace="http://www.qgis.org/gml" xmlns:qgs="http://www.qgis.org/gml" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ogc="http://www.opengis.net/ogc" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
<element type="qgs:as_areasType" name="as_areas" substitutionGroup="gml:_Feature"/>
<complexType name="as_areasType">
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element maxOccurs="1" type="gml:MultiPolygonPropertyType" minOccurs="0" name="geometry"/>
<element type="long" name="fid"/>
<element type="int" name="gid"/>
<element type="string" name="datum"/>
<element type="string" name="bearbeiter"/>
<element type="string" name="veranstaltung"/>
<element type="string" name="beschriftung"/>
<element type="string" name="name"/>
<element type="string" name="flaechentyp"/>
<element type="string" name="farbe"/>
<element type="string" name="schraff_width"/>
<element type="string" name="schraff_width_prt"/>
<element type="string" name="schraff_size"/>
<element type="string" name="schraff_size_prt"/>
<element type="string" name="schraff_winkel"/>
<element type="string" name="umrissfarbe"/>
<element type="string" name="umrisstyp"/>
<element type="string" name="umrissstaerke"/>
<element type="string" name="umrissstaerke_prt"/>
<element type="decimal" name="umfang"/>
<element type="decimal" name="flaeche"/>
<element type="string" name="bemerkung"/>
<element type="string" name="last_change"/>
</sequence>
</extension>
</complexContent>
</complexType>
</schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
Content-Length: 4894
Content-Type: text/xml; charset=utf-8

<schema xmlns:gml="http://www.opengis.net/gml" targetNamespace="http://www.qgis.org/gml" xmlns:qgs="http://www.qgis.org/gml" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ogc="http://www.opengis.net/ogc" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
<element type="qgs:as_areasType" name="as_areas" substitutionGroup="gml:_Feature"/>
<complexType name="as_areasType">
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element maxOccurs="1" type="gml:MultiPolygonPropertyType" minOccurs="0" name="geometry"/>
<element type="long" name="fid"/>
<element type="int" name="gid"/>
<element type="string" name="datum"/>
<element type="string" name="bearbeiter"/>
<element type="string" name="veranstaltung"/>
<element type="string" name="beschriftung"/>
<element type="string" name="name"/>
<element type="string" name="flaechentyp"/>
<element type="string" name="farbe"/>
<element type="string" name="schraff_width"/>
<element type="string" name="schraff_width_prt"/>
<element type="string" name="schraff_size"/>
<element type="string" name="schraff_size_prt"/>
<element type="string" name="schraff_winkel"/>
<element type="string" name="umrissfarbe"/>
<element type="string" name="umrisstyp"/>
<element type="string" name="umrissstaerke"/>
<element type="string" name="umrissstaerke_prt"/>
<element type="decimal" name="umfang"/>
<element type="decimal" name="flaeche"/>
<element type="string" name="bemerkung"/>
<element type="string" name="last_change"/>
</sequence>
</extension>
</complexContent>
</complexType>
<element type="qgs:as_symbolsType" name="as_symbols" substitutionGroup="gml:_Feature"/>
<complexType name="as_symbolsType">
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element maxOccurs="1" type="gml:PointPropertyType" minOccurs="0" name="geometry"/>
<element type="long" name="fid"/>
<element type="int" name="gid"/>
<element type="string" name="datum"/>
<element type="string" name="bearbeiter"/>
<element type="string" name="veranstaltung"/>
<element type="string" name="beschriftung"/>
<element type="string" name="name"/>
<element type="string" name="form"/>
<element type="string" name="groesse"/>
<element type="string" name="groesse_red"/>
<element type="string" name="winkel"/>
<element type="string" name="farbe"/>
<element type="string" name="bemerkung"/>
<element type="string" name="last_change"/>
</sequence>
</extension>
</complexContent>
</complexType>
<element type="qgs:cdb_labelsType" name="cdb_labels" substitutionGroup="gml:_Feature"/>
<complexType name="cdb_labelsType">
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element maxOccurs="1" type="gml:PointPropertyType" minOccurs="0" name="geometry"/>
<element type="long" name="fid"/>
<element type="decimal" name="AREA"/>
<element type="decimal" name="PERIMETER"/>
<element type="int" name="STADTTEILE"/>
<element type="int" name="STADTTEI_1"/>
<element type="int" name="S_A_"/>
<element type="int" name="S_A_ID"/>
<element type="string" name="O_NAME"/>
<element type="string" name="ORTSTEIL"/>
<element type="string" name="STADTTEIL"/>
<element type="string" name="OT_SCHL"/>
<element type="string" name="GEM_SCHL"/>
<element type="decimal" name="ZVS"/>
<element type="string" name="NAME"/>
<element type="string" name="PLZ"/>
<element type="string" name="KERNSTADT_"/>
<element type="string" name="ORTSRATSBE"/>
<element type="decimal" name="PLG_KITA"/>
<element type="decimal" name="PLG_BERATU"/>
<element type="decimal" name="PLG_JUFOE"/>
<element type="decimal" name="VERFLECHTU"/>
<element type="decimal" name="FUNKTIONSB"/>
<element type="string" name="T_DATUM"/>
<element type="string" name="Impfbez_Nr"/>
<element type="string" name="Impfzentru"/>
</sequence>
</extension>
</complexContent>
</complexType>
<element type="qgs:cdb_linesType" name="cdb_lines" substitutionGroup="gml:_Feature"/>
<complexType name="cdb_linesType">
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element maxOccurs="1" type="gml:PolygonPropertyType" minOccurs="0" name="geometry"/>
<element type="long" name="fid"/>
<element type="int" name="id"/>
<element type="string" name="typ"/>
<element type="string" name="name"/>
<element type="string" name="ortsrat"/>
</sequence>
</extension>
</complexContent>
</complexType>
</schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Content-Length: 422
Content-Type: text/xml; charset=utf-8

<schema xmlns:gml="http://www.opengis.net/gml" targetNamespace="http://www.qgis.org/gml" xmlns:qgs="http://www.qgis.org/gml" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ogc="http://www.opengis.net/ogc" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
</schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Content-Length: 1841
Content-Type: text/xml; charset=utf-8

<schema xmlns:gml="http://www.opengis.net/gml" targetNamespace="http://www.qgis.org/gml" xmlns:qgs="http://www.qgis.org/gml" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ogc="http://www.opengis.net/ogc" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"/>
<element type="qgs:as_areasType" name="as_areas" substitutionGroup="gml:_Feature"/>
<complexType name="as_areasType">
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element maxOccurs="1" type="gml:MultiPolygonPropertyType" minOccurs="0" name="geometry"/>
<element type="long" name="fid"/>
<element type="int" name="gid"/>
<element type="string" name="datum"/>
<element type="string" name="bearbeiter"/>
<element type="string" name="veranstaltung"/>
<element type="string" name="beschriftung"/>
<element type="string" name="name"/>
<element type="string" name="flaechentyp"/>
<element type="string" name="farbe"/>
<element type="string" name="schraff_width"/>
<element type="string" name="schraff_width_prt"/>
<element type="string" name="schraff_size"/>
<element type="string" name="schraff_size_prt"/>
<element type="string" name="schraff_winkel"/>
<element type="string" name="umrissfarbe"/>
<element type="string" name="umrisstyp"/>
<element type="string" name="umrissstaerke"/>
<element type="string" name="umrissstaerke_prt"/>
<element type="decimal" name="umfang"/>
<element type="decimal" name="flaeche"/>
<element type="string" name="bemerkung"/>
<element type="string" name="last_change"/>
</sequence>
</extension>
</complexContent>
</complexType>
</schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
Content-Length: 4895
Content-Type: text/xml; charset=utf-8

<schema xmlns:gml="http://www.opengis.net/gml" targetNamespace="http://www.qgis.org/gml" xmlns:qgs="http://www.qgis.org/gml" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ogc="http://www.opengis.net/ogc" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"/>
<element type="qgs:as_areasType" name="as_areas" substitutionGroup="gml:_Feature"/>
<complexType name="as_areasType">
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element maxOccurs="1" type="gml:MultiPolygonPropertyType" minOccurs="0" name="geometry"/>
<element type="long" name="fid"/>
<element type="int" name="gid"/>
<element type="string" name="datum"/>
<element type="string" name="bearbeiter"/>
<element type="string" name="veranstaltung"/>
<element type="string" name="beschriftung"/>
<element type="string" name="name"/>
<element type="string" name="flaechentyp"/>
<element type="string" name="farbe"/>
<element type="string" name="schraff_width"/>
<element type="string" name="schraff_width_prt"/>
<element type="string" name="schraff_size"/>
<element type="string" name="schraff_size_prt"/>
<element type="string" name="schraff_winkel"/>
<element type="string" name="umrissfarbe"/>
<element type="string" name="umrisstyp"/>
<element type="string" name="umrissstaerke"/>
<element type="string" name="umrissstaerke_prt"/>
<element type="decimal" name="umfang"/>
<element type="decimal" name="flaeche"/>
<element type="string" name="bemerkung"/>
<element type="string" name="last_change"/>
</sequence>
</extension>
</complexContent>
</complexType>
<element type="qgs:as_symbolsType" name="as_symbols" substitutionGroup="gml:_Feature"/>
<complexType name="as_symbolsType">
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element maxOccurs="1" type="gml:PointPropertyType" minOccurs="0" name="geometry"/>
<element type="long" name="fid"/>
<element type="int" name="gid"/>
<element type="string" name="datum"/>
<element type="string" name="bearbeiter"/>
<element type="string" name="veranstaltung"/>
<element type="string" name="beschriftung"/>
<element type="string" name="name"/>
<element type="string" name="form"/>
<element type="string" name="groesse"/>
<element type="string" name="groesse_red"/>
<element type="string" name="winkel"/>
<element type="string" name="farbe"/>
<element type="string" name="bemerkung"/>
<element type="string" name="last_change"/>
</sequence>
</extension>
</complexContent>
</complexType>
<element type="qgs:cdb_labelsType" name="cdb_labels" substitutionGroup="gml:_Feature"/>
<complexType name="cdb_labelsType">
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element maxOccurs="1" type="gml:PointPropertyType" minOccurs="0" name="geometry"/>
<element type="long" name="fid"/>
<element type="decimal" name="AREA"/>
<element type="decimal" name="PERIMETER"/>
<element type="int" name="STADTTEILE"/>
<element type="int" name="STADTTEI_1"/>
<element type="int" name="S_A_"/>
<element type="int" name="S_A_ID"/>
<element type="string" name="O_NAME"/>
<element type="string" name="ORTSTEIL"/>
<element type="string" name="STADTTEIL"/>
<element type="string" name="OT_SCHL"/>
<element type="string" name="GEM_SCHL"/>
<element type="decimal" name="ZVS"/>
<element type="string" name="NAME"/>
<element type="string" name="PLZ"/>
<element type="string" name="KERNSTADT_"/>
<element type="string" name="ORTSRATSBE"/>
<element type="decimal" name="PLG_KITA"/>
<element type="decimal" name="PLG_BERATU"/>
<element type="decimal" name="PLG_JUFOE"/>
<element type="decimal" name="VERFLECHTU"/>
<element type="decimal" name="FUNKTIONSB"/>
<element type="string" name="T_DATUM"/>
<element type="string" name="Impfbez_Nr"/>
<element type="string" name="Impfzentru"/>
</sequence>
</extension>
</complexContent>
</complexType>
<element type="qgs:cdb_linesType" name="cdb_lines" substitutionGroup="gml:_Feature"/>
<complexType name="cdb_linesType">
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element maxOccurs="1" type="gml:PolygonPropertyType" minOccurs="0" name="geometry"/>
<element type="long" name="fid"/>
<element type="int" name="id"/>
<element type="string" name="typ"/>
<element type="string" name="name"/>
<element type="string" name="ortsrat"/>
</sequence>
</extension>
</complexContent>
</complexType>
</schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Content-Length: 423
Content-Type: text/xml; charset=utf-8

<schema xmlns:gml="http://www.opengis.net/gml" targetNamespace="http://www.qgis.org/gml" xmlns:qgs="http://www.qgis.org/gml" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ogc="http://www.opengis.net/ogc" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"/>
</schema>

0 comments on commit 59fd8df

Please sign in to comment.