Skip to content

Commit

Permalink
Fix obstacle factor is ignored when a layer is set to blocking mode
Browse files Browse the repository at this point in the history
It was only correctly being respected for fully labeled layers
  • Loading branch information
nyalldawson committed Dec 3, 2019
1 parent 7f4226d commit bee6ab8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/core/qgspallabeling.cpp
Expand Up @@ -2624,6 +2624,26 @@ void QgsPalLayerSettings::registerObstacleFeature( const QgsFeature &f, QgsRende
*obstacleFeature = new QgsLabelFeature( f.id(), std::move( geos_geom_clone ), QSizeF( 0, 0 ) );
( *obstacleFeature )->setIsObstacle( true );
( *obstacleFeature )->setFeature( f );

double featObstacleFactor = obstacleFactor;
if ( mDataDefinedProperties.isActive( QgsPalLayerSettings::ObstacleFactor ) )
{
context.expressionContext().setOriginalValueVariable( featObstacleFactor );
QVariant exprVal = mDataDefinedProperties.value( QgsPalLayerSettings::ObstacleFactor, context.expressionContext() );
if ( exprVal.isValid() )
{
bool ok;
double factorD = exprVal.toDouble( &ok );
if ( ok )
{
factorD = qBound( 0.0, factorD, 10.0 );
factorD = factorD / 5.0 + 0.0001; // convert 0 -> 10 to 0.0001 -> 2.0
featObstacleFactor = factorD;
}
}
}
( *obstacleFeature )->setObstacleFactor( featObstacleFactor );

mFeatsRegPal++;
}

Expand Down

0 comments on commit bee6ab8

Please sign in to comment.