Skip to content
Permalink
Browse files

Avoid labels being marked as overlapping obstacles when features

neighbour each other
  • Loading branch information
nyalldawson committed Aug 8, 2016
1 parent 7797e80 commit 655fc93cef99542738cf0eebd371222c35380c80
Showing with 16 additions and 8 deletions.
  1. +16 −8 src/core/qgspallabeling.cpp
@@ -2907,16 +2907,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 );
}

0 comments on commit 655fc93

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