Skip to content
Permalink
Browse files
Merge pull request #352 from Oslandia/atlas
Fix atlas composition
  • Loading branch information
mhugent committed Dec 12, 2012
2 parents e38b222 + d584b76 commit 51d7d56039c9a8640ea6faa68e3965027a44f446
Showing with 5 additions and 12 deletions.
  1. +5 −12 src/core/composer/qgsatlascomposition.cpp
@@ -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()
@@ -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() );
@@ -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()
@@ -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 )

0 comments on commit 51d7d56

Please sign in to comment.