Skip to content

Commit

Permalink
Fix incorrect extents returned by memory provider when subset string set
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 18, 2017
1 parent 1cfd6ee commit e9e7efc
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/core/providers/memory/qgsmemoryprovider.cpp
Expand Up @@ -275,12 +275,30 @@ QgsRectangle QgsMemoryProvider::extent() const
if ( mExtent.isEmpty() && !mFeatures.isEmpty() )
{
mExtent.setMinimal();
Q_FOREACH ( const QgsFeature &feat, mFeatures )
if ( mSubsetString.isEmpty() )
{
if ( feat.hasGeometry() )
mExtent.combineExtentWith( feat.geometry().boundingBox() );
// fast way - iterate through all features
Q_FOREACH ( const QgsFeature &feat, mFeatures )
{
if ( feat.hasGeometry() )
mExtent.combineExtentWith( feat.geometry().boundingBox() );
}
}
else
{
QgsFeature f;
QgsFeatureIterator fi = getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() ) );
while ( fi.nextFeature( f ) )
{
if ( f.hasGeometry() )
mExtent.combineExtentWith( f.geometry().boundingBox() );
}
}
}
else if ( mFeatures.isEmpty() )
{
mExtent.setMinimal();
}

return mExtent;
}
Expand Down Expand Up @@ -511,6 +529,7 @@ bool QgsMemoryProvider::setSubsetString( const QString &theSQL, bool updateFeatu

mSubsetString = theSQL;
clearMinMaxCache();
mExtent.setMinimal();

emit dataChanged();
return true;
Expand Down

0 comments on commit e9e7efc

Please sign in to comment.