Skip to content

Commit 734a3a5

Browse files
committed
[WFS provider] Recognize gmgml:Polygon_Surface_MultiSurface_CompositeSurfacePropertyType in DescribeFeatureType response
1 parent 37598bd commit 734a3a5

File tree

2 files changed

+75
-2
lines changed

2 files changed

+75
-2
lines changed

src/providers/wfs/qgswfsprovider.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -1250,11 +1250,18 @@ bool QgsWFSProvider::readAttributesFromSchema( QDomDocument& schemaDoc,
12501250
}
12511251
}
12521252

1253+
QRegExp gmlPT( "gml:(.*)PropertyType" );
1254+
// gmgml: is Geomedia Web Server
1255+
if ( type == "gmgml:Polygon_Surface_MultiSurface_CompositeSurfacePropertyType" )
1256+
{
1257+
foundGeometryAttribute = true;
1258+
geometryAttribute = name;
1259+
geomType = QGis::WKBMultiPolygon;
1260+
}
12531261
//is it a geometry attribute?
12541262
//MH 090428: sometimes the <element> tags for geometry attributes have only attribute ref="gml:polygonProperty" and no name
1255-
QRegExp gmlPT( "gml:(.*)PropertyType" );
12561263
// the GeometryAssociationType has been seen in #11785
1257-
if ( type.indexOf( gmlPT ) == 0 || type == "gml:GeometryAssociationType" || name.isEmpty() )
1264+
else if ( type.indexOf( gmlPT ) == 0 || type == "gml:GeometryAssociationType" || name.isEmpty() )
12581265
{
12591266
foundGeometryAttribute = true;
12601267
geometryAttribute = name;

tests/src/python/test_provider_wfs.py

+66
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,72 @@ def testWrongCapabilityExtent(self):
18551855
# Check that the approx extent contains the geometry
18561856
assert vl.extent().contains(QgsPoint(2, 49))
18571857

1858+
def testGeomedia(self):
1859+
"""Test various interoperability specifities that occur with Geomedia Web Server."""
1860+
1861+
endpoint = self.__class__.basetestpath + '/fake_qgis_http_endpoint_geomedia'
1862+
1863+
with open(sanitize(endpoint, '?SERVICE=WFS?REQUEST=GetCapabilities?VERSION=2.0.0'), 'wb') as f:
1864+
f.write("""
1865+
<wfs:WFS_Capabilities version="2.0.0" xmlns="http://www.opengis.net/wfs/2.0" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://schemas.opengis.net/gml/3.2" xmlns:fes="http://www.opengis.net/fes/2.0">
1866+
<FeatureTypeList>
1867+
<FeatureType>
1868+
<Name>my:typename</Name>
1869+
<Title>Title</Title>
1870+
<Abstract>Abstract</Abstract>
1871+
<DefaultCRS>urn:ogc:def:crs:EPSG::32631</DefaultCRS>
1872+
<ows:WGS84BoundingBox>
1873+
<ows:LowerCorner>0 40</ows:LowerCorner>
1874+
<ows:UpperCorner>15 50</ows:UpperCorner>
1875+
</ows:WGS84BoundingBox>
1876+
</FeatureType>
1877+
</FeatureTypeList>
1878+
</wfs:WFS_Capabilities>""".encode('UTF-8'))
1879+
1880+
with open(sanitize(endpoint, '?SERVICE=WFS&REQUEST=DescribeFeatureType&VERSION=2.0.0&TYPENAME=my:typename'), 'wb') as f:
1881+
f.write("""
1882+
<xsd:schema xmlns:my="http://my" xmlns:gml="http://www.opengis.net/gml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://my">
1883+
<xsd:import namespace="http://www.opengis.net/gml"/>
1884+
<xsd:complexType name="typenameType">
1885+
<xsd:complexContent>
1886+
<xsd:extension base="gml:AbstractFeatureType">
1887+
<xsd:sequence>
1888+
<xsd:element maxOccurs="1" minOccurs="0" name="intfield" nillable="true" type="xsd:int"/>
1889+
<xsd:element maxOccurs="1" minOccurs="0" name="geometryProperty" nillable="true" type="gmgml:Polygon_Surface_MultiSurface_CompositeSurfacePropertyType"/>
1890+
</xsd:sequence>
1891+
</xsd:extension>
1892+
</xsd:complexContent>
1893+
</xsd:complexType>
1894+
<xsd:element name="typename" substitutionGroup="gml:_Feature" type="my:typenameType"/>
1895+
</xsd:schema>
1896+
""".encode('UTF-8'))
1897+
1898+
with open(sanitize(endpoint, """?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=my:typename&SRSNAME=urn:ogc:def:crs:EPSG::32631"""), 'wb') as f:
1899+
f.write("""
1900+
<wfs:FeatureCollection
1901+
xmlns:wfs="http://www.opengis.net/wfs/2.0"
1902+
xmlns:gml="http://www.opengis.net/gml/3.2"
1903+
xmlns:my="http://my">
1904+
<wfs:member>
1905+
<my:typename gml:id="typename.0">
1906+
<my:intfield>1</my:intfield>
1907+
<my:geometryProperty><gml:Polygon srsName="urn:ogc:def:crs:EPSG::32631" gml:id="typename.geom.0"><gml:exterior><gml:LinearRing><gml:posList>500000 4500000 500000 4510000 510000 4510000 510000 4500000 500000 4500000</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></my:geometryProperty>
1908+
</my:typename>
1909+
</wfs:member>
1910+
</wfs:FeatureCollection>""".encode('UTF-8'))
1911+
1912+
vl = QgsVectorLayer(u"url='http://" + endpoint + u"' typename='my:typename' version='2.0.0'", u'test', u'WFS')
1913+
assert vl.isValid()
1914+
self.assertEqual(vl.wkbType(), QgsWKBTypes.MultiPolygon)
1915+
1916+
# Download all features
1917+
features = [f for f in vl.getFeatures()]
1918+
self.assertEqual(len(features), 1)
1919+
1920+
reference = QgsGeometry.fromRect(QgsRectangle(500000, 4500000, 510000, 4510000))
1921+
vl_extent = QgsGeometry.fromRect(vl.extent())
1922+
assert QgsGeometry.compare(vl_extent.asPolygon()[0], reference.asPolygon()[0], 0.00001), 'Expected {}, got {}'.format(reference.exportToWkt(), vl_extent.exportToWkt())
1923+
18581924

18591925
if __name__ == '__main__':
18601926
unittest.main()

0 commit comments

Comments
 (0)