Skip to content

Commit

Permalink
Fix zonal stats not saving values to spatialite layers (fix #11849)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 20, 2015
1 parent 5e41c43 commit 085d0ad
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/analysis/vector/qgszonalstatistics.cpp
Expand Up @@ -246,6 +246,7 @@ int QgsZonalStatistics::calculateStatistics( QProgressDialog* p )
FeatureStats featureStats( statsStoreValues, statsStoreValueCount ); FeatureStats featureStats( statsStoreValues, statsStoreValueCount );
int featureCounter = 0; int featureCounter = 0;


QgsChangedAttributesMap changeMap;
while ( fi.nextFeature( f ) ) while ( fi.nextFeature( f ) )
{ {
if ( p ) if ( p )
Expand Down Expand Up @@ -300,7 +301,6 @@ int QgsZonalStatistics::calculateStatistics( QProgressDialog* p )
} }


//write the statistics value to the vector data provider //write the statistics value to the vector data provider
QgsChangedAttributesMap changeMap;
QgsAttributeMap changeAttributeMap; QgsAttributeMap changeAttributeMap;
if ( mStatistics & QgsZonalStatistics::Count ) if ( mStatistics & QgsZonalStatistics::Count )
changeAttributeMap.insert( countIndex, QVariant( featureStats.count ) ); changeAttributeMap.insert( countIndex, QVariant( featureStats.count ) );
Expand Down Expand Up @@ -364,11 +364,11 @@ int QgsZonalStatistics::calculateStatistics( QProgressDialog* p )
} }


changeMap.insert( f.id(), changeAttributeMap ); changeMap.insert( f.id(), changeAttributeMap );
vectorProvider->changeAttributeValues( changeMap );

++featureCounter; ++featureCounter;
} }


vectorProvider->changeAttributeValues( changeMap );

if ( p ) if ( p )
{ {
p->setValue( featureCount ); p->setValue( featureCount );
Expand Down

0 comments on commit 085d0ad

Please sign in to comment.