Skip to content

Commit 0e0f473

Browse files
committed
Much faster zoom to selection on large PostGIS layers
(cherry-picked from 6772ffb)
1 parent e604a48 commit 0e0f473

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/core/qgsvectorlayer.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -619,17 +619,16 @@ QgsRectangle QgsVectorLayer::boundingBoxOfSelected()
619619
QgsFeature fet;
620620
if ( mDataProvider->capabilities() & QgsVectorDataProvider::SelectAtId )
621621
{
622-
Q_FOREACH ( QgsFeatureId fid, mSelectedFeatureIds )
622+
QgsFeatureIterator fit = getFeatures( QgsFeatureRequest()
623+
.setFilterFids( mSelectedFeatureIds )
624+
.setSubsetOfAttributes( QgsAttributeList() ) );
625+
626+
while ( fit.nextFeature( fet ) )
623627
{
624-
if ( getFeatures( QgsFeatureRequest()
625-
.setFilterFid( fid )
626-
.setSubsetOfAttributes( QgsAttributeList() ) )
627-
.nextFeature( fet ) &&
628-
fet.constGeometry() )
629-
{
630-
r = fet.constGeometry()->boundingBox();
631-
retval.combineExtentWith( &r );
632-
}
628+
if ( !fet.constGeometry() || fet.constGeometry()->isEmpty() )
629+
continue;
630+
r = fet.constGeometry()->boundingBox();
631+
retval.combineExtentWith( &r );
633632
}
634633
}
635634
else

0 commit comments

Comments
 (0)