Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add $atlasfeatureid and $atlasgeometry
  • Loading branch information
NathanW2 committed Nov 24, 2013
1 parent 5c4966e commit 8d16718
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/core/composer/qgsatlascomposition.cpp
Expand Up @@ -41,7 +41,8 @@ QgsAtlasComposition::QgsAtlasComposition( QgsComposition* composition ) :
QgsExpression::setSpecialColumn( "$feature", QVariant(( int )0 ) );
QgsExpression::setSpecialColumn( "$numpages", QVariant(( int )1 ) );
QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )0 ) );
QgsExpression::setSpecialColumn( "$currentfeature", QVariant(( int )0 ) );
QgsExpression::setSpecialColumn( "$atlasfeatureid", QVariant(( int )0 ) );
QgsExpression::setSpecialColumn( "$atlasgeometry", QVariant::fromValue(QgsGeometry()));
}

QgsAtlasComposition::~QgsAtlasComposition()
Expand All @@ -54,6 +55,12 @@ void QgsAtlasComposition::setCoverageLayer( QgsVectorLayer* layer )

// update the number of features
QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )mFeatureIds.size() ) );

// Grab the first feature so that user can use it to test the style in rules.
QgsFeature fet;
layer->getFeatures().nextFeature(fet);
QgsExpression::setSpecialColumn( "$atlasfeatureid", fet.id() );
QgsExpression::setSpecialColumn( "$atlasgeometry", QVariant::fromValue(*fet.geometry()));
}

//
Expand Down Expand Up @@ -226,7 +233,8 @@ void QgsAtlasComposition::prepareForFeature( int featureI )

// retrieve the next feature, based on its id
mCoverageLayer->getFeatures( QgsFeatureRequest().setFilterFid( mFeatureIds[ featureI ] ) ).nextFeature( mCurrentFeature );
QgsExpression::setSpecialColumn( "$currentfeature", mCurrentFeature.id() );
QgsExpression::setSpecialColumn( "$atlasfeatureid", mCurrentFeature.id() );
QgsExpression::setSpecialColumn( "$atlasgeometry", QVariant::fromValue(*mCurrentFeature.geometry()));

if ( !mSingleFile && mFilenamePattern.size() > 0 )
{
Expand Down

0 comments on commit 8d16718

Please sign in to comment.