Skip to content

Commit

Permalink
Prepared expression evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 10, 2019
1 parent dd003da commit bb60f4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/qgspallabeling.cpp
Expand Up @@ -1223,12 +1223,13 @@ void QgsPalLayerSettings::registerFeature( const QgsFeature &f, QgsRenderContext
QgsFeature feature = f;
if ( geometryGeneratorEnabled )
{
QgsExpressionContext expContext = context.expressionContext();
// TODO: cache and prepare
QgsExpression exp( geometryGenerator );
exp.prepare( &expContext );
expContext.setFeature( feature );
QgsGeometry geometry = exp.evaluate( &expContext ).value<QgsGeometry>();
if ( !mGeometryGeneratorExpression.isValid() )
{
mGeometryGeneratorExpression = QgsExpression( geometryGenerator );
mGeometryGeneratorExpression.prepare( &context.expressionContext() );
}
context.expressionContext().setFeature( feature );
const QgsGeometry geometry = mGeometryGeneratorExpression.evaluate( &context.expressionContext() ).value<QgsGeometry>();
feature.setGeometry( geometry );
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/qgspallabeling.h
Expand Up @@ -927,6 +927,8 @@ class CORE_EXPORT QgsPalLayerSettings

QgsTextFormat mFormat;

QgsExpression mGeometryGeneratorExpression;

static const QVector< PredefinedPointPosition > DEFAULT_PLACEMENT_ORDER;

static void initPropertyDefinitions();
Expand Down

0 comments on commit bb60f4c

Please sign in to comment.