Skip to content
Permalink
Browse files

Fix point label placement

  • Loading branch information
nyalldawson committed Dec 26, 2019
1 parent 29955a5 commit df2debcba3c2ce848aec6a960de4e034782de6a6
Showing with 7 additions and 7 deletions.
  1. +7 −7 src/core/pal/pal.cpp
@@ -299,20 +299,20 @@ std::unique_ptr<Problem> Pal::extract( const QgsRectangle &extent, const QgsGeom
prob->mFeatStartId[i] = idlp;
prob->mInactiveCost[i] = std::pow( 2, 10 - 10 * feat->priority );

std::size_t max_p = 0;
std::size_t maxCandidates = 0;
switch ( feat->feature->getGeosType() )
{
case GEOS_POINT:
// this is usually 0, i.e. no maximum
max_p = feat->feature->maximumPointCandidates();
maxCandidates = feat->feature->maximumPointCandidates();
break;

case GEOS_LINESTRING:
max_p = feat->feature->maximumLineCandidates();
maxCandidates = feat->feature->maximumLineCandidates();
break;

case GEOS_POLYGON:
max_p = feat->feature->maximumPolygonCandidates();
maxCandidates = feat->feature->maximumPolygonCandidates();
break;
}

@@ -355,10 +355,10 @@ std::unique_ptr<Problem> Pal::extract( const QgsRectangle &extent, const QgsGeom
// sort candidates list, best label to worst
std::sort( feat->candidates.begin(), feat->candidates.end(), CostCalculator::candidateSortGrow );

// only keep the 'max_p' best candidates
if ( feat->candidates.size() > max_p )
// only keep the 'maxCandidates' best candidates
if ( maxCandidates > 0 && feat->candidates.size() > maxCandidates )
{
feat->candidates.resize( max_p );
feat->candidates.resize( maxCandidates );
}

if ( isCanceled() )

0 comments on commit df2debc

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