Skip to content

Commit

Permalink
Merge pull request #352 from Oslandia/atlas
Browse files Browse the repository at this point in the history
Fix atlas composition
  • Loading branch information
mhugent committed Dec 12, 2012
2 parents e38b222 + d584b76 commit 51d7d56
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/core/composer/qgsatlascomposition.cpp
Expand Up @@ -48,12 +48,8 @@ void QgsAtlasComposition::setCoverageLayer( QgsVectorLayer* layer )
{
mCoverageLayer = layer;

if ( mCoverageLayer != 0 )
{
// update the number of features
QgsVectorDataProvider* provider = mCoverageLayer->dataProvider();
QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )provider->featureCount() ) );
}
// update the number of features
QgsExpression::setSpecialColumn( "$numfeatures", QVariant( (int)mFeatureIds.size() ) );
}

void QgsAtlasComposition::beginRender()
Expand Down Expand Up @@ -93,6 +89,7 @@ void QgsAtlasComposition::beginRender()
// We cannot use nextFeature() directly since the feature pointer is rewinded by the rendering process
// We thus store the feature ids for future extraction
QgsFeature feat;
mFeatureIds.clear();
while ( provider->nextFeature( feat ) )
{
mFeatureIds.push_back( feat.id() );
Expand All @@ -115,7 +112,7 @@ void QgsAtlasComposition::beginRender()

// special columns for expressions
QgsExpression::setSpecialColumn( "$numpages", QVariant( mComposition->numPages() ) );
QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )provider->featureCount() ) );
QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )mFeatureIds.size() ) );
}

void QgsAtlasComposition::endRender()
Expand Down Expand Up @@ -147,11 +144,7 @@ void QgsAtlasComposition::endRender()

size_t QgsAtlasComposition::numFeatures() const
{
if ( mCoverageLayer )
{
return mCoverageLayer->dataProvider()->featureCount();
}
return 0;
return mFeatureIds.size();
}

void QgsAtlasComposition::prepareForFeature( size_t featureI )
Expand Down

0 comments on commit 51d7d56

Please sign in to comment.