Skip to content

Commit 641c09b

Browse files
committed
fix spatialindex creation
1 parent 4bcdecd commit 641c09b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

python/plugins/processing/tools/vector.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,13 @@ def testForUniqueness(fieldList1, fieldList2):
200200
def spatialindex(layer):
201201
"""Creates a spatial index for the passed vector layer.
202202
"""
203-
idx = QgsSpatialIndex(features(layer))
203+
request = QgsFeatureRequest()
204+
request.setSubsetOfAttributes([])
205+
if ProcessingConfig.getSetting(ProcessingConfig.USE_SELECTED) \
206+
and layer.selectedFeatureCount() > 0:
207+
idx = layer.selectedFeaturesIterator(request)
208+
else:
209+
idx = QgsSpatialIndex(layer.getFeatures(request))
204210
return idx
205211

206212

0 commit comments

Comments
 (0)