From 734a3a55552105e5fe55d6718c8cdf4905effc89 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 7 Jun 2016 21:11:47 +0200 Subject: [PATCH] [WFS provider] Recognize gmgml:Polygon_Surface_MultiSurface_CompositeSurfacePropertyType in DescribeFeatureType response --- src/providers/wfs/qgswfsprovider.cpp | 11 ++++- tests/src/python/test_provider_wfs.py | 66 +++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/src/providers/wfs/qgswfsprovider.cpp b/src/providers/wfs/qgswfsprovider.cpp index eaad2e85ec97..ba17b448ad12 100644 --- a/src/providers/wfs/qgswfsprovider.cpp +++ b/src/providers/wfs/qgswfsprovider.cpp @@ -1250,11 +1250,18 @@ bool QgsWFSProvider::readAttributesFromSchema( QDomDocument& schemaDoc, } } + QRegExp gmlPT( "gml:(.*)PropertyType" ); + // gmgml: is Geomedia Web Server + if ( type == "gmgml:Polygon_Surface_MultiSurface_CompositeSurfacePropertyType" ) + { + foundGeometryAttribute = true; + geometryAttribute = name; + geomType = QGis::WKBMultiPolygon; + } //is it a geometry attribute? //MH 090428: sometimes the tags for geometry attributes have only attribute ref="gml:polygonProperty" and no name - QRegExp gmlPT( "gml:(.*)PropertyType" ); // the GeometryAssociationType has been seen in #11785 - if ( type.indexOf( gmlPT ) == 0 || type == "gml:GeometryAssociationType" || name.isEmpty() ) + else if ( type.indexOf( gmlPT ) == 0 || type == "gml:GeometryAssociationType" || name.isEmpty() ) { foundGeometryAttribute = true; geometryAttribute = name; diff --git a/tests/src/python/test_provider_wfs.py b/tests/src/python/test_provider_wfs.py index f0f8065daad0..60142204aff3 100644 --- a/tests/src/python/test_provider_wfs.py +++ b/tests/src/python/test_provider_wfs.py @@ -1855,6 +1855,72 @@ def testWrongCapabilityExtent(self): # Check that the approx extent contains the geometry assert vl.extent().contains(QgsPoint(2, 49)) + def testGeomedia(self): + """Test various interoperability specifities that occur with Geomedia Web Server.""" + + endpoint = self.__class__.basetestpath + '/fake_qgis_http_endpoint_geomedia' + + with open(sanitize(endpoint, '?SERVICE=WFS?REQUEST=GetCapabilities?VERSION=2.0.0'), 'wb') as f: + f.write(""" + + + + my:typename + Title + Abstract + urn:ogc:def:crs:EPSG::32631 + + 0 40 + 15 50 + + + +""".encode('UTF-8')) + + with open(sanitize(endpoint, '?SERVICE=WFS&REQUEST=DescribeFeatureType&VERSION=2.0.0&TYPENAME=my:typename'), 'wb') as f: + f.write(""" + + + + + + + + + + + + + + +""".encode('UTF-8')) + + 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: + f.write(""" + + + + 1 + 500000 4500000 500000 4510000 510000 4510000 510000 4500000 500000 4500000 + + +""".encode('UTF-8')) + + vl = QgsVectorLayer(u"url='http://" + endpoint + u"' typename='my:typename' version='2.0.0'", u'test', u'WFS') + assert vl.isValid() + self.assertEqual(vl.wkbType(), QgsWKBTypes.MultiPolygon) + + # Download all features + features = [f for f in vl.getFeatures()] + self.assertEqual(len(features), 1) + + reference = QgsGeometry.fromRect(QgsRectangle(500000, 4500000, 510000, 4510000)) + vl_extent = QgsGeometry.fromRect(vl.extent()) + assert QgsGeometry.compare(vl_extent.asPolygon()[0], reference.asPolygon()[0], 0.00001), 'Expected {}, got {}'.format(reference.exportToWkt(), vl_extent.exportToWkt()) + if __name__ == '__main__': unittest.main()