Skip to content
Permalink
Browse files

Fix data defined expressions cannot use fields in vector tile renderer

  • Loading branch information
nyalldawson committed Sep 14, 2020
1 parent 229c240 commit c192b04e7c237441b85c1195d322dd9b4eff6613
Showing with 14 additions and 4 deletions.
  1. +4 −1 src/core/symbology/qgssymbollayer.cpp
  2. +10 −3 src/core/vectortile/qgsvectortilebasicrenderer.cpp
@@ -246,7 +246,10 @@ int QgsSymbolLayer::renderingPass() const

QSet<QString> QgsSymbolLayer::usedAttributes( const QgsRenderContext &context ) const
{
QSet<QString> columns = mDataDefinedProperties.referencedFields( context.expressionContext() );
// calling referencedFields() with ignoreContext=true because in our expression context
// we do not have valid QgsFields yet - because of that the field names from expressions
// wouldn't get reported
QSet<QString> columns = mDataDefinedProperties.referencedFields( context.expressionContext(), true );
return columns;
}

@@ -122,10 +122,17 @@ void QgsVectorTileBasicRenderer::startRender( QgsRenderContext &context, int til
// figure out required fields for different layers
for ( const QgsVectorTileBasicRendererStyle &layerStyle : qgis::as_const( mStyles ) )
{
if ( layerStyle.isActive( tileZoom ) && !layerStyle.filterExpression().isEmpty() )
if ( layerStyle.isActive( tileZoom ) )
{
QgsExpression expr( layerStyle.filterExpression() );
mRequiredFields[layerStyle.layerName()].unite( expr.referencedColumns() );
if ( !layerStyle.filterExpression().isEmpty() )
{
QgsExpression expr( layerStyle.filterExpression() );
mRequiredFields[layerStyle.layerName()].unite( expr.referencedColumns() );
}
if ( layerStyle.symbol() )
{
mRequiredFields[layerStyle.layerName()].unite( layerStyle.symbol()->usedAttributes( context ) );
}
}
}
}

0 comments on commit c192b04

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