Skip to content

Commit a9850ae

Browse files
committedOct 6, 2016
[WFS provider] Do not append crs at end of BBOX in WFS 1.0
Fixes #15464
1 parent 302570e commit a9850ae

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
 

‎src/providers/wfs/qgswfsfeatureiterator.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,12 @@ QUrl QgsWFSFeatureDownloader::buildURL( int startIndex, int maxFeatures, bool fo
310310
qgsDoubleToString( mShared->mRect.yMaximum() ) ) );
311311
// Some servers like Geomedia need the srsname to be explictly appended
312312
// otherwise they are confused and do not interpret it properly
313-
bbox += "," + mShared->srsName();
313+
if ( !mShared->mWFSVersion.startsWith( "1.0" ) )
314+
{
315+
// but it is illegal in WFS 1.0 and some servers definitely not like
316+
// it. See #15464
317+
bbox += "," + mShared->srsName();
318+
}
314319
getFeatureUrl.addQueryItem( "BBOX", bbox );
315320
}
316321
else if ( !mShared->mWFSFilter.isEmpty() )

‎tests/src/python/test_provider_wfs.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,31 @@ def testWFS10(self):
462462

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

465+
# Test with restrictToRequestBBOX=1
466+
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:
467+
f.write("""
468+
<wfs:FeatureCollection
469+
xmlns:wfs="http://www.opengis.net/wfs"
470+
xmlns:gml="http://www.opengis.net/gml"
471+
xmlns:my="http://my">
472+
<gml:boundedBy><gml:null>unknown</gml:null></gml:boundedBy>
473+
<gml:featureMember>
474+
<my:typename fid="typename.0">
475+
<my:geometry>
476+
<gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"><gml:coordinates decimal="." cs="," ts=" ">426858,5427937</gml:coordinates></gml:Point>
477+
</my:geometry>
478+
<my:INTFIELD>100</my:INTFIELD>
479+
</my:typename>
480+
</gml:featureMember>
481+
</wfs:FeatureCollection>""".encode('UTF-8'))
482+
483+
vl = QgsVectorLayer("url='http://" + endpoint + "' typename='my:typename' version='1.0.0' restrictToRequestBBOX=1", 'test', 'WFS')
484+
485+
extent = QgsRectangle(400000.0, 5400000.0, 450000.0, 5500000.0)
486+
request = QgsFeatureRequest().setFilterRect(extent)
487+
values = [f['INTFIELD'] for f in vl.getFeatures(request)]
488+
self.assertEqual(values, [100])
489+
465490
def testWFS10_latlongboundingbox_in_WGS84(self):
466491
"""Test WFS 1.0 with non conformatn LatLongBoundingBox"""
467492

0 commit comments

Comments
 (0)
Please sign in to comment.