Skip to content

Commit

Permalink
vector layer: avoid iterating over all feature to deduce extent
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Sep 21, 2015
1 parent 657c600 commit 9cbfeea
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -805,7 +805,7 @@ QgsRectangle QgsVectorLayer::extent()
QgsDebugMsg( "invoked with null mDataProvider" );
}

if ( mDataProvider && mEditBuffer && mEditBuffer->mDeletedFeatureIds.isEmpty() && mEditBuffer->mChangedGeometries.isEmpty() )
if ( mDataProvider && ( !mEditBuffer || ( mEditBuffer->mDeletedFeatureIds.isEmpty() && mEditBuffer->mChangedGeometries.isEmpty() ) ) )
{
mDataProvider->updateExtents();

Expand All @@ -817,12 +817,15 @@ QgsRectangle QgsVectorLayer::extent()
rect.combineExtentWith( &r );
}

for ( QgsFeatureMap::iterator it = mEditBuffer->mAddedFeatures.begin(); it != mEditBuffer->mAddedFeatures.end(); ++it )
if ( mEditBuffer )
{
if ( it->constGeometry() )
for ( QgsFeatureMap::iterator it = mEditBuffer->mAddedFeatures.begin(); it != mEditBuffer->mAddedFeatures.end(); ++it )
{
QgsRectangle r = it->constGeometry()->boundingBox();
rect.combineExtentWith( &r );
if ( it->constGeometry() )
{
QgsRectangle r = it->constGeometry()->boundingBox();
rect.combineExtentWith( &r );
}
}
}
}
Expand Down

0 comments on commit 9cbfeea

Please sign in to comment.