@@ -123,16 +123,11 @@ QgsWFSProvider::QgsWFSProvider( const QString& uri )
123
123
setDataSourceUri ( bkUri );
124
124
}
125
125
126
- #if 0 //non-cached mode is broken
127
126
mCached = !uri.contains ( " BBOX=" );
128
127
if ( mCached )
129
128
{ // "Cache Features" option; get all features in layer immediately
130
129
reloadData ();
131
130
} // otherwise, defer feature retrieval until layer is first rendered
132
- #endif // 0
133
-
134
- mCached = true ;
135
- reloadData ();
136
131
137
132
if ( mValid )
138
133
{
@@ -159,7 +154,8 @@ QgsAbstractFeatureSource* QgsWFSProvider::featureSource() const
159
154
void QgsWFSProvider::reloadData ()
160
155
{
161
156
mPendingRetrieval = false ;
162
- deleteData ();
157
+ if (mCached )
158
+ deleteData ();
163
159
delete mSpatialIndex ;
164
160
mSpatialIndex = new QgsSpatialIndex ();
165
161
mValid = !getFeature ( dataSourceUri () );
@@ -285,8 +281,29 @@ QgsFeatureIterator QgsWFSProvider::getFeatures( const QgsFeatureRequest& request
285
281
}
286
282
287
283
}
288
- #endif
289
284
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
290
307
}
291
308
292
309
int QgsWFSProvider::getFeature ( const QString& uri )
@@ -1723,6 +1740,7 @@ void QgsWFSProvider::extendExtent( const QgsRectangle &extent )
1723
1740
if ( mGetExtent .contains ( r ) )
1724
1741
return ;
1725
1742
1743
+ #if 0
1726
1744
if ( mGetExtent.isEmpty() )
1727
1745
{
1728
1746
mGetExtent = r;
@@ -1738,6 +1756,9 @@ void QgsWFSProvider::extendExtent( const QgsRectangle &extent )
1738
1756
{
1739
1757
mGetExtent.combineExtentWith( &r );
1740
1758
}
1759
+ #else
1760
+ mGetExtent = extent;
1761
+ #endif
1741
1762
1742
1763
setDataSourceUri ( dataSourceUri ().replace ( QRegExp ( " BBOX=[^&]*" ),
1743
1764
QString ( " BBOX=%1,%2,%3,%4" )
0 commit comments