Skip to content
Permalink
Browse files

Prepared expression evaluation

  • Loading branch information
m-kuhn committed Mar 10, 2019
1 parent dd003da commit bb60f4c367fd46350c1f71ef6fcf164b49aaa2c3
Showing with 9 additions and 6 deletions.
  1. +7 −6 src/core/qgspallabeling.cpp
  2. +2 −0 src/core/qgspallabeling.h
@@ -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 );
}

@@ -927,6 +927,8 @@ class CORE_EXPORT QgsPalLayerSettings

QgsTextFormat mFormat;

QgsExpression mGeometryGeneratorExpression;

static const QVector< PredefinedPointPosition > DEFAULT_PLACEMENT_ORDER;

static void initPropertyDefinitions();

0 comments on commit bb60f4c

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