@@ -123,16 +123,11 @@ QgsWFSProvider::QgsWFSProvider( const QString& uri )
123123 setDataSourceUri ( bkUri );
124124 }
125125
126- #if 0 //non-cached mode is broken
127126 mCached = !uri.contains ( " BBOX=" );
128127 if ( mCached )
129128 { // "Cache Features" option; get all features in layer immediately
130129 reloadData ();
131130 } // otherwise, defer feature retrieval until layer is first rendered
132- #endif // 0
133-
134- mCached = true ;
135- reloadData ();
136131
137132 if ( mValid )
138133 {
@@ -159,7 +154,8 @@ QgsAbstractFeatureSource* QgsWFSProvider::featureSource() const
159154void QgsWFSProvider::reloadData ()
160155{
161156 mPendingRetrieval = false ;
162- deleteData ();
157+ if (mCached )
158+ deleteData ();
163159 delete mSpatialIndex ;
164160 mSpatialIndex = new QgsSpatialIndex ();
165161 mValid = !getFeature ( dataSourceUri () );
@@ -285,8 +281,29 @@ QgsFeatureIterator QgsWFSProvider::getFeatures( const QgsFeatureRequest& request
285281 }
286282
287283 }
288- #endif
289284 return new QgsWFSFeatureIterator( new QgsWFSFeatureSource( this ), true, request );
285+ #else
286+ QgsRectangle rect = request.filterRect ();
287+ if ( !( request.flags () & QgsFeatureRequest::NoGeometry ) && !rect.isEmpty () )
288+ {
289+ deleteData ();
290+ mGetExtent = rect;
291+
292+ QString dsURI = dataSourceUri ();
293+ dsURI = dsURI.replace ( QRegExp ( " BBOX=[^&]*" ),
294+ QString ( " BBOX=%1,%2,%3,%4" )
295+ .arg ( qgsDoubleToString ( rect.xMinimum () ) )
296+ .arg ( qgsDoubleToString ( rect.yMinimum () ) )
297+ .arg ( qgsDoubleToString ( rect.xMaximum () ) )
298+ .arg ( qgsDoubleToString ( rect.yMaximum () ) ) );
299+ // TODO: BBOX may not be combined with FILTER. WFS spec v. 1.1.0, sec. 14.7.3 ff.
300+ // if a FILTER is present, the BBOX must be merged into it, capabilities permitting.
301+ // Else one criterion must be abandoned and the user warned. [WBC 111221]
302+ setDataSourceUri ( dsURI );
303+ reloadData ();
304+ }
305+ return new QgsWFSFeatureIterator ( new QgsWFSFeatureSource ( this ), true , request );
306+ #endif
290307}
291308
292309int QgsWFSProvider::getFeature ( const QString& uri )
@@ -1723,6 +1740,7 @@ void QgsWFSProvider::extendExtent( const QgsRectangle &extent )
17231740 if ( mGetExtent .contains ( r ) )
17241741 return ;
17251742
1743+ #if 0
17261744 if ( mGetExtent.isEmpty() )
17271745 {
17281746 mGetExtent = r;
@@ -1738,6 +1756,9 @@ void QgsWFSProvider::extendExtent( const QgsRectangle &extent )
17381756 {
17391757 mGetExtent.combineExtentWith( &r );
17401758 }
1759+ #else
1760+ mGetExtent = extent;
1761+ #endif
17411762
17421763 setDataSourceUri ( dataSourceUri ().replace ( QRegExp ( " BBOX=[^&]*" ),
17431764 QString ( " BBOX=%1,%2,%3,%4" )
0 commit comments