Skip to content
Permalink
Browse files

vector layer: avoid iterating over all feature to deduce extent

  • Loading branch information
jef-n committed Sep 21, 2015
1 parent 657c600 commit 9cbfeea64503245a31ee5a95d53200031c0c9db5
Showing with 8 additions and 5 deletions.
  1. +8 −5 src/core/qgsvectorlayer.cpp
@@ -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();

@@ -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 );
}
}
}
}

0 comments on commit 9cbfeea

Please sign in to comment.
You can’t perform that action at this time.