Skip to content

Commit 655fc93

Browse files
committed
Avoid labels being marked as overlapping obstacles when features
neighbour each other
1 parent 7797e80 commit 655fc93

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/core/qgspallabeling.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2907,16 +2907,24 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
29072907
}
29082908
}
29092909

2910+
if ( distinmapunit ) //convert distance from mm/map units to pixels
2911+
{
2912+
distance /= distMapUnitScale.computeMapUnitsPerPixel( context );
2913+
}
2914+
else //mm
2915+
{
2916+
distance *= vectorScaleFactor;
2917+
}
2918+
2919+
// when using certain placement modes, we force a tiny minimum distance. This ensures that
2920+
// candidates are created just offset from a border and avoids candidates being incorrectly flagged as colliding with neighbours
2921+
if ( placement == QgsPalLayerSettings::Line || placement == QgsPalLayerSettings::Curved || placement == QgsPalLayerSettings::PerimeterCurved )
2922+
{
2923+
distance = qMax( distance, 1.0 );
2924+
}
2925+
29102926
if ( !qgsDoubleNear( distance, 0.0 ) )
29112927
{
2912-
if ( distinmapunit ) //convert distance from mm/map units to pixels
2913-
{
2914-
distance /= distMapUnitScale.computeMapUnitsPerPixel( context );
2915-
}
2916-
else //mm
2917-
{
2918-
distance *= vectorScaleFactor;
2919-
}
29202928
double d = ptOne.distance( ptZero ) * distance;
29212929
( *labelFeature )->setDistLabel( d );
29222930
}

0 commit comments

Comments
 (0)