Skip to content
Permalink
Browse files

[WFS provider] Do not append crs at end of BBOX in WFS 1.0

Fixes #15464
  • Loading branch information
rouault committed Oct 6, 2016
1 parent 85e9389 commit eba8c5d945a2d8b5f2dde88cff8a5eb6ed6afe96
Showing with 31 additions and 1 deletion.
  1. +6 −1 src/providers/wfs/qgswfsfeatureiterator.cpp
  2. +25 −0 tests/src/python/test_provider_wfs.py
@@ -310,7 +310,12 @@ QUrl QgsWFSFeatureDownloader::buildURL( int startIndex, int maxFeatures, bool fo
qgsDoubleToString( mShared->mRect.yMaximum() ) ) );
// Some servers like Geomedia need the srsname to be explictly appended
// otherwise they are confused and do not interpret it properly
bbox += "," + mShared->srsName();
if ( !mShared->mWFSVersion.startsWith( "1.0" ) )
{
// but it is illegal in WFS 1.0 and some servers definitely not like
// it. See #15464
bbox += "," + mShared->srsName();
}
getFeatureUrl.addQueryItem( "BBOX", bbox );
}
else if ( !mShared->mWFSFilter.isEmpty() )
@@ -462,6 +462,31 @@ def testWFS10(self):

assert not vl.dataProvider().deleteFeatures([0])

# Test with restrictToRequestBBOX=1
with open(sanitize(endpoint, '?SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0&TYPENAME=my:typename&SRSNAME=EPSG:32631&BBOX=400000,5400000,450000,5500000'), 'wb') as f:
f.write("""
<wfs:FeatureCollection
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:gml="http://www.opengis.net/gml"
xmlns:my="http://my">
<gml:boundedBy><gml:null>unknown</gml:null></gml:boundedBy>
<gml:featureMember>
<my:typename fid="typename.0">
<my:geometry>
<gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"><gml:coordinates decimal="." cs="," ts=" ">426858,5427937</gml:coordinates></gml:Point>
</my:geometry>
<my:INTFIELD>100</my:INTFIELD>
</my:typename>
</gml:featureMember>
</wfs:FeatureCollection>""".encode('UTF-8'))

vl = QgsVectorLayer("url='http://" + endpoint + "' typename='my:typename' version='1.0.0' retrictToRequestBBOX=1", 'test', 'WFS')

extent = QgsRectangle(400000.0, 5400000.0, 450000.0, 5500000.0)
request = QgsFeatureRequest().setFilterRect(extent)
values = [f['INTFIELD'] for f in vl.getFeatures(request)]
self.assertEqual(values, [100])

def testWFS10_latlongboundingbox_in_WGS84(self):
"""Test WFS 1.0 with non conformatn LatLongBoundingBox"""

0 comments on commit eba8c5d

Please sign in to comment.
You can’t perform that action at this time.