Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
vector layer: calculate extents lazily (fixes #9510)
  • Loading branch information
jef-n committed Feb 8, 2014
1 parent 00f6236 commit 500116b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -1685,10 +1685,10 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
mValid = mDataProvider->isValid();
if ( mValid )
{

// TODO: Check if the provider has the capability to send fullExtentCalculated
connect( mDataProvider, SIGNAL( fullExtentCalculated() ), this, SLOT( updateExtents() ) );

#if 0 // allow lazy calculation of extents and give the creator of the vector layer a chance to 'manually' setExtent

This comment has been minimized.

Copy link
@ahuarte47

ahuarte47 Feb 20, 2014

Contributor

Hi @jef-n, disabling this code QGIS always reads all features to calculate the extent of the layer in QgsVectorLayer::extent().

It is very very slow for big vector layers.

This comment has been minimized.

Copy link
@jef-n

jef-n Feb 20, 2014

Author Member

Using which provider?

This comment has been minimized.

Copy link
@ahuarte47

ahuarte47 Feb 20, 2014

Contributor

OGR-provider reading a shapefile

This comment has been minimized.

Copy link
@NathanW2

NathanW2 Feb 20, 2014

Member

I think the main issue here is the QgsVectorLayer::extent() method. It is only getting the extents from the provider if there is a edit buffer.

To me it should just be:

  • Get provider extents
  • If there is a edit buffer with changed/added features, add those to the extent.

At the moment it's a if based on if there is a edit buffer or not. If there is no edit buffer it loops all the features, which is not something it should do.

This comment has been minimized.

Copy link
@ahuarte47

ahuarte47 Feb 20, 2014

Contributor
// get the extent
QgsRectangle mbr = mDataProvider->extent();

Expand All @@ -1697,6 +1697,7 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
QgsDebugMsg( "Extent of layer: " + s );
// store the extent
setExtent( mbr );
#endif

// get and store the feature type
mWkbType = mDataProvider->geometryType();
Expand Down Expand Up @@ -3693,7 +3694,7 @@ void QgsVectorLayer::readSldLabeling( const QDomNode& node )
QDomElement userStyleElem = element.firstChildElement( "UserStyle" );
if ( userStyleElem.isNull() )
{
QgsDebugMsg( "Info: UserStyle element not found.");
QgsDebugMsg( "Info: UserStyle element not found." );
return;
}

Expand Down

0 comments on commit 500116b

Please sign in to comment.