@@ -71,12 +71,15 @@ QgsAfsFeatureIterator::QgsAfsFeatureIterator( QgsAfsFeatureSource *source, bool
71
71
requestIds.insert ( mRequest .filterFid () );
72
72
}
73
73
74
- if ( !mFilterRect .isNull () )
74
+ if ( !mFilterRect .isNull () && ! mSource -> sharedData ()-> hasCachedAllFeatures () )
75
75
{
76
76
// defer request to find features in filter rect until first feature is requested
77
77
// this allows time for a interruption checker to be installed on the iterator
78
78
// and avoids performing this expensive check in the main thread when just
79
79
// preparing iterators
80
+
81
+ // (but if we've already cached ALL the features, we skip this -- there's no need for
82
+ // firing off another request to the server)
80
83
mDeferredFeaturesInFilterRectCheck = true ;
81
84
}
82
85
@@ -129,6 +132,10 @@ bool QgsAfsFeatureIterator::fetchFeature( QgsFeature &f )
129
132
mFeatureIterator = mRemainingFeatureIds .at ( 0 );
130
133
131
134
mDeferredFeaturesInFilterRectCheck = false ;
135
+
136
+ // discard the filter rect - we know that the features in mRemainingFeatureIds are gauranteed
137
+ // to be intersecting the rect, so avoid any extra unnecessary checks
138
+ mFilterRect = QgsRectangle ();
132
139
}
133
140
134
141
if ( !mFeatureIdList .empty () && mRemainingFeatureIds .empty () )
@@ -171,6 +178,10 @@ bool QgsAfsFeatureIterator::fetchFeature( QgsFeature &f )
171
178
{
172
179
++mFeatureIterator ;
173
180
}
181
+
182
+ if ( !mFilterRect .isNull () && ( !f.hasGeometry () || !f.geometry ().intersects ( mFilterRect ) ) )
183
+ success = false ;
184
+
174
185
if ( !success )
175
186
continue ;
176
187
geometryToDestinationCrs ( f, mTransform );
0 commit comments