@@ -1855,6 +1855,72 @@ def testWrongCapabilityExtent(self):
1855
1855
# Check that the approx extent contains the geometry
1856
1856
assert vl .extent ().contains (QgsPoint (2 , 49 ))
1857
1857
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
+
1858
1924
1859
1925
if __name__ == '__main__' :
1860
1926
unittest .main ()
0 commit comments