Skip to content

Commit

Permalink
Avoid labels being marked as overlapping obstacles when features
Browse files Browse the repository at this point in the history
neighbour each other

(cherry-picked from 655fc93)
  • Loading branch information
nyalldawson committed Aug 9, 2016
1 parent 00e9c32 commit 93389a8
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/core/qgspallabeling.cpp
Expand Up @@ -2926,16 +2926,24 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
}
}

if ( distinmapunit ) //convert distance from mm/map units to pixels
{
distance /= distMapUnitScale.computeMapUnitsPerPixel( context );
}
else //mm
{
distance *= vectorScaleFactor;
}

// when using certain placement modes, we force a tiny minimum distance. This ensures that
// candidates are created just offset from a border and avoids candidates being incorrectly flagged as colliding with neighbours
if ( placement == QgsPalLayerSettings::Line || placement == QgsPalLayerSettings::Curved || placement == QgsPalLayerSettings::PerimeterCurved )
{
distance = qMax( distance, 1.0 );
}

if ( !qgsDoubleNear( distance, 0.0 ) )
{
if ( distinmapunit ) //convert distance from mm/map units to pixels
{
distance /= distMapUnitScale.computeMapUnitsPerPixel( context );
}
else //mm
{
distance *= vectorScaleFactor;
}
double d = ptOne.distance( ptZero ) * distance;
( *labelFeature )->setDistLabel( d );
}
Expand Down

0 comments on commit 93389a8

Please sign in to comment.