Skip to content
Permalink
Browse files

Add $atlasfeatureid and $atlasgeometry

  • Loading branch information
NathanW2 committed Nov 24, 2013
1 parent 5c4966e commit 8d167180072ae9efd3f2c497a007f9624ba42901
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/core/composer/qgsatlascomposition.cpp
@@ -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()
@@ -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()));
}

//
@@ -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 )
{

0 comments on commit 8d16718

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