Skip to content
Permalink
Browse files

Fix incorrect extents returned by memory provider when subset string set

  • Loading branch information
nyalldawson committed Nov 18, 2017
1 parent 1cfd6ee commit e9e7efc6d3b9a3846e1e5dd69a0d77cac3385f3f
Showing with 22 additions and 3 deletions.
  1. +22 −3 src/core/providers/memory/qgsmemoryprovider.cpp
@@ -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;
}
@@ -511,6 +529,7 @@ bool QgsMemoryProvider::setSubsetString( const QString &theSQL, bool updateFeatu

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

emit dataChanged();
return true;

0 comments on commit e9e7efc

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