QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
pal.cpp
Go to the documentation of this file.
1 /*
2  * libpal - Automated Placement of Labels Library
3  *
4  * Copyright (C) 2008 Maxence Laurent, MIS-TIC, HEIG-VD
5  * University of Applied Sciences, Western Switzerland
6  * http://www.hes-so.ch
7  *
8  * Contact:
9  * maxence.laurent <at> heig-vd <dot> ch
10  * or
11  * eric.taillard <at> heig-vd <dot> ch
12  *
13  * This file is part of libpal.
14  *
15  * libpal is free software: you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation, either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * libpal is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with libpal. If not, see <http://www.gnu.org/licenses/>.
27  *
28  */
29 
30 #include "qgsgeometry.h"
31 #include "pal.h"
32 #include "layer.h"
33 #include "palexception.h"
34 #include "palstat.h"
35 #include "costcalculator.h"
36 #include "feature.h"
37 #include "geomfunction.h"
38 #include "labelposition.h"
39 #include "problem.h"
40 #include "pointset.h"
41 #include "internalexception.h"
42 #include "util.h"
43 #include "palrtree.h"
44 #include "qgssettings.h"
45 #include <cfloat>
46 #include <list>
47 
48 using namespace pal;
49 
51 {
52  QgsSettings settings;
53  mGlobalCandidatesLimitPoint = settings.value( QStringLiteral( "rendering/label_candidates_limit_points" ), 0, QgsSettings::Core ).toInt();
54  mGlobalCandidatesLimitLine = settings.value( QStringLiteral( "rendering/label_candidates_limit_lines" ), 0, QgsSettings::Core ).toInt();
55  mGlobalCandidatesLimitPolygon = settings.value( QStringLiteral( "rendering/label_candidates_limit_polygons" ), 0, QgsSettings::Core ).toInt();
56 }
57 
58 Pal::~Pal() = default;
59 
60 void Pal::removeLayer( Layer *layer )
61 {
62  if ( !layer )
63  return;
64 
65  mMutex.lock();
66 
67  for ( auto it = mLayers.begin(); it != mLayers.end(); ++it )
68  {
69  if ( it->second.get() == layer )
70  {
71  mLayers.erase( it );
72  break;
73  }
74  }
75  mMutex.unlock();
76 }
77 
78 Layer *Pal::addLayer( QgsAbstractLabelProvider *provider, const QString &layerName, QgsPalLayerSettings::Placement arrangement, double defaultPriority, bool active, bool toLabel, bool displayAll )
79 {
80  mMutex.lock();
81 
82  Q_ASSERT( mLayers.find( provider ) == mLayers.end() );
83 
84  std::unique_ptr< Layer > layer = qgis::make_unique< Layer >( provider, layerName, arrangement, defaultPriority, active, toLabel, this, displayAll );
85  Layer *res = layer.get();
86  mLayers.insert( std::pair<QgsAbstractLabelProvider *, std::unique_ptr< Layer >>( provider, std::move( layer ) ) );
87  mMutex.unlock();
88 
89  return res;
90 }
91 
92 std::unique_ptr<Problem> Pal::extract( const QgsRectangle &extent, const QgsGeometry &mapBoundary )
93 {
94  // expand out the incoming buffer by 1000x -- that's the visible map extent, yet we may be getting features which exceed this extent
95  // (while 1000x may seem excessive here, this value is only used for scaling coordinates in the spatial indexes
96  // and the consequence of inserting coordinates outside this extent is worse than the consequence of setting this value too large.)
97  const QgsRectangle maxCoordinateExtentForSpatialIndices = extent.buffered( std::max( extent.width(), extent.height() ) * 1000 );
98 
99  // to store obstacles
100  PalRtree< FeaturePart > obstacles( maxCoordinateExtentForSpatialIndices );
101  PalRtree< LabelPosition > allCandidatesFirstRound( maxCoordinateExtentForSpatialIndices );
102  std::vector< FeaturePart * > allObstacleParts;
103  std::unique_ptr< Problem > prob = qgis::make_unique< Problem >( maxCoordinateExtentForSpatialIndices );
104 
105  double bbx[4];
106  double bby[4];
107 
108  bbx[0] = bbx[3] = prob->mMapExtentBounds[0] = extent.xMinimum();
109  bby[0] = bby[1] = prob->mMapExtentBounds[1] = extent.yMinimum();
110  bbx[1] = bbx[2] = prob->mMapExtentBounds[2] = extent.xMaximum();
111  bby[2] = bby[3] = prob->mMapExtentBounds[3] = extent.yMaximum();
112 
113  prob->pal = this;
114 
115  std::list< std::unique_ptr< Feats > > features;
116 
117  // prepare map boundary
118  geos::unique_ptr mapBoundaryGeos( QgsGeos::asGeos( mapBoundary ) );
119  geos::prepared_unique_ptr mapBoundaryPrepared( GEOSPrepare_r( QgsGeos::getGEOSHandler(), mapBoundaryGeos.get() ) );
120 
121  int obstacleCount = 0;
122 
123  // first step : extract features from layers
124 
125  std::size_t previousFeatureCount = 0;
126  int previousObstacleCount = 0;
127 
128  QStringList layersWithFeaturesInBBox;
129 
130  QMutexLocker palLocker( &mMutex );
131  for ( const auto &it : mLayers )
132  {
133  Layer *layer = it.second.get();
134  if ( !layer )
135  {
136  // invalid layer name
137  continue;
138  }
139 
140  // only select those who are active
141  if ( !layer->active() )
142  continue;
143 
144  // check for connected features with the same label text and join them
145  if ( layer->mergeConnectedLines() )
146  layer->joinConnectedFeatures();
147 
148  if ( isCanceled() )
149  return nullptr;
150 
152 
153  if ( isCanceled() )
154  return nullptr;
155 
156  QMutexLocker locker( &layer->mMutex );
157 
158  // generate candidates for all features
159  for ( FeaturePart *featurePart : qgis::as_const( layer->mFeatureParts ) )
160  {
161  if ( isCanceled() )
162  break;
163 
164  // Holes of the feature are obstacles
165  for ( int i = 0; i < featurePart->getNumSelfObstacles(); i++ )
166  {
167  FeaturePart *selfObstacle = featurePart->getSelfObstacle( i );
168  obstacles.insert( selfObstacle, selfObstacle->boundingBox() );
169  allObstacleParts.emplace_back( selfObstacle );
170 
171  if ( !featurePart->getSelfObstacle( i )->getHoleOf() )
172  {
173  //ERROR: SHOULD HAVE A PARENT!!!!!
174  }
175  }
176 
177  // generate candidates for the feature part
178  std::vector< std::unique_ptr< LabelPosition > > candidates = featurePart->createCandidates( this );
179 
180  if ( isCanceled() )
181  break;
182 
183  // purge candidates that are outside the bbox
184  candidates.erase( std::remove_if( candidates.begin(), candidates.end(), [&mapBoundaryPrepared, this]( std::unique_ptr< LabelPosition > &candidate )
185  {
186  if ( showPartialLabels() )
187  return !candidate->intersects( mapBoundaryPrepared.get() );
188  else
189  return !candidate->within( mapBoundaryPrepared.get() );
190  } ), candidates.end() );
191 
192  if ( isCanceled() )
193  break;
194 
195  if ( !candidates.empty() )
196  {
197  for ( std::unique_ptr< LabelPosition > &candidate : candidates )
198  {
199  candidate->insertIntoIndex( allCandidatesFirstRound );
200  }
201 
202  std::sort( candidates.begin(), candidates.end(), CostCalculator::candidateSortGrow );
203 
204  // valid features are added to fFeats
205  std::unique_ptr< Feats > ft = qgis::make_unique< Feats >();
206  ft->feature = featurePart;
207  ft->shape = nullptr;
208  ft->candidates = std::move( candidates );
209  ft->priority = featurePart->calculatePriority();
210  features.emplace_back( std::move( ft ) );
211  }
212  else
213  {
214  // no candidates, so generate a default "point on surface" one
215  std::unique_ptr< LabelPosition > unplacedPosition = featurePart->createCandidatePointOnSurface( featurePart );
216  if ( !unplacedPosition )
217  continue;
218 
219  if ( layer->displayAll() )
220  {
221  // if we are displaying all labels, we throw the default candidate in too
222  unplacedPosition->insertIntoIndex( allCandidatesFirstRound );
223  candidates.emplace_back( std::move( unplacedPosition ) );
224 
225  // valid features are added to fFeats
226  std::unique_ptr< Feats > ft = qgis::make_unique< Feats >();
227  ft->feature = featurePart;
228  ft->shape = nullptr;
229  ft->candidates = std::move( candidates );
230  ft->priority = featurePart->calculatePriority();
231  features.emplace_back( std::move( ft ) );
232  }
233  else
234  {
235  // not displaying all labels for this layer, so it goes into the unlabeled feature list
236  prob->positionsWithNoCandidates()->emplace_back( std::move( unplacedPosition ) );
237  }
238  }
239  }
240  if ( isCanceled() )
241  return nullptr;
242 
243  // collate all layer obstacles
244  for ( FeaturePart *obstaclePart : qgis::as_const( layer->mObstacleParts ) )
245  {
246  if ( isCanceled() )
247  break; // do not continue searching
248 
249  // insert into obstacles
250  obstacles.insert( obstaclePart, obstaclePart->boundingBox() );
251  allObstacleParts.emplace_back( obstaclePart );
252  obstacleCount++;
253  }
254 
255  if ( isCanceled() )
256  return nullptr;
257 
258  locker.unlock();
259 
260  if ( features.size() - previousFeatureCount > 0 || obstacleCount > previousObstacleCount )
261  {
262  layersWithFeaturesInBBox << layer->name();
263  }
264  previousFeatureCount = features.size();
265  previousObstacleCount = obstacleCount;
266  }
267  palLocker.unlock();
268 
269  if ( isCanceled() )
270  return nullptr;
271 
272  prob->mLayerCount = layersWithFeaturesInBBox.size();
273  prob->labelledLayersName = layersWithFeaturesInBBox;
274 
275  prob->mFeatureCount = features.size();
276  prob->mTotalCandidates = 0;
277  prob->mFeatNbLp.resize( prob->mFeatureCount );
278  prob->mFeatStartId.resize( prob->mFeatureCount );
279  prob->mInactiveCost.resize( prob->mFeatureCount );
280 
281  if ( !features.empty() )
282  {
283  // Filtering label positions against obstacles
284  for ( FeaturePart *obstaclePart : allObstacleParts )
285  {
286  if ( isCanceled() )
287  break; // do not continue searching
288 
289  allCandidatesFirstRound.intersects( obstaclePart->boundingBox(), [obstaclePart, this]( const LabelPosition * candidatePosition ) -> bool
290  {
291  // test whether we should ignore this obstacle for the candidate. We do this if:
292  // 1. it's not a hole, and the obstacle belongs to the same label feature as the candidate (e.g.,
293  // features aren't obstacles for their own labels)
294  // 2. it IS a hole, and the hole belongs to a different label feature to the candidate (e.g., holes
295  // are ONLY obstacles for the labels of the feature they belong to)
296  if ( ( !obstaclePart->getHoleOf() && candidatePosition->getFeaturePart()->hasSameLabelFeatureAs( obstaclePart ) )
297  || ( obstaclePart->getHoleOf() && !candidatePosition->getFeaturePart()->hasSameLabelFeatureAs( dynamic_cast< FeaturePart * >( obstaclePart->getHoleOf() ) ) ) )
298  {
299  return true;
300  }
301 
302  CostCalculator::addObstacleCostPenalty( const_cast< LabelPosition * >( candidatePosition ), obstaclePart, this );
303 
304  return true;
305  } );
306  }
307 
308  if ( isCanceled() )
309  {
310  return nullptr;
311  }
312 
313  int idlp = 0;
314  for ( std::size_t i = 0; i < prob->mFeatureCount; i++ ) /* foreach feature into prob */
315  {
316  std::unique_ptr< Feats > feat = std::move( features.front() );
317  features.pop_front();
318 
319  prob->mFeatStartId[i] = idlp;
320  prob->mInactiveCost[i] = std::pow( 2, 10 - 10 * feat->priority );
321 
322  std::size_t maxCandidates = 0;
323  switch ( feat->feature->getGeosType() )
324  {
325  case GEOS_POINT:
326  // this is usually 0, i.e. no maximum
327  maxCandidates = feat->feature->maximumPointCandidates();
328  break;
329 
330  case GEOS_LINESTRING:
331  maxCandidates = feat->feature->maximumLineCandidates();
332  break;
333 
334  case GEOS_POLYGON:
335  maxCandidates = std::max( static_cast< std::size_t >( 16 ), feat->feature->maximumPolygonCandidates() );
336  break;
337  }
338 
339  if ( isCanceled() )
340  return nullptr;
341 
342  auto pruneHardConflicts = [&]
343  {
344  switch ( mPlacementVersion )
345  {
347  break;
348 
350  {
351  // v2 placement rips out candidates where the candidate cost is too high when compared to
352  // their inactive cost
353 
354  // note, we start this at the SECOND candidate (you'll see why after this loop)
355  feat->candidates.erase( std::remove_if( feat->candidates.begin() + 1, feat->candidates.end(), [ & ]( std::unique_ptr< LabelPosition > &candidate )
356  {
357  if ( candidate->hasHardObstacleConflict() )
358  {
359  return true;
360  }
361  return false;
362  } ), feat->candidates.end() );
363 
364  if ( feat->candidates.size() == 1 && feat->candidates[ 0 ]->hasHardObstacleConflict() && !feat->feature->layer()->displayAll() )
365  {
366  // we've going to end up removing ALL candidates for this label. Oh well, that's allowed. We just need to
367  // make sure we move this last candidate to the unplaced labels list
368  prob->positionsWithNoCandidates()->emplace_back( std::move( feat->candidates.front() ) );
369  feat->candidates.clear();
370  }
371  }
372  }
373  };
374 
375  // if we're not showing all labels (including conflicts) for this layer, then we prune the candidates
376  // upfront to avoid extra work...
377  if ( !feat->feature->layer()->displayAll() )
378  {
379  pruneHardConflicts();
380  }
381 
382  if ( feat->candidates.empty() )
383  continue;
384 
385  // calculate final costs
386  CostCalculator::finalizeCandidatesCosts( feat.get(), bbx, bby );
387 
388  // sort candidates list, best label to worst
389  std::sort( feat->candidates.begin(), feat->candidates.end(), CostCalculator::candidateSortGrow );
390 
391  // but if we ARE showing all labels (including conflicts), let's go ahead and prune them now.
392  // Since we've calculated all their costs and sorted them, if we've hit the situation that ALL
393  // candidates have conflicts, then at least when we pick the first candidate to display it will be
394  // the lowest cost (i.e. best possible) overlapping candidate...
395  if ( feat->feature->layer()->displayAll() )
396  {
397  pruneHardConflicts();
398  }
399 
400 
401  // only keep the 'maxCandidates' best candidates
402  if ( maxCandidates > 0 && feat->candidates.size() > maxCandidates )
403  {
404  feat->candidates.resize( maxCandidates );
405  }
406 
407  if ( isCanceled() )
408  return nullptr;
409 
410  // update problem's # candidate
411  prob->mFeatNbLp[i] = static_cast< int >( feat->candidates.size() );
412  prob->mTotalCandidates += static_cast< int >( feat->candidates.size() );
413 
414  // add all candidates into a rtree (to speed up conflicts searching)
415  for ( std::unique_ptr< LabelPosition > &candidate : feat->candidates )
416  {
417  candidate->insertIntoIndex( prob->allCandidatesIndex() );
418  candidate->setProblemIds( static_cast< int >( i ), idlp++ );
419  }
420  features.emplace_back( std::move( feat ) );
421  }
422 
423  int nbOverlaps = 0;
424 
425  double amin[2];
426  double amax[2];
427  while ( !features.empty() ) // foreach feature
428  {
429  if ( isCanceled() )
430  return nullptr;
431 
432  std::unique_ptr< Feats > feat = std::move( features.front() );
433  features.pop_front();
434 
435  for ( std::unique_ptr< LabelPosition > &candidate : feat->candidates )
436  {
437  std::unique_ptr< LabelPosition > lp = std::move( candidate );
438 
439  lp->resetNumOverlaps();
440 
441  // make sure that candidate's cost is less than 1
442  lp->validateCost();
443 
444  //prob->feat[idlp] = j;
445 
446  // lookup for overlapping candidate
447  lp->getBoundingBox( amin, amax );
448  prob->allCandidatesIndex().intersects( QgsRectangle( amin[0], amin[1], amax[0], amax[1] ), [&lp]( const LabelPosition * lp2 )->bool
449  {
450  if ( lp->isInConflict( lp2 ) )
451  {
452  lp->incrementNumOverlaps();
453  }
454 
455  return true;
456 
457  } );
458 
459  nbOverlaps += lp->getNumOverlaps();
460 
461  prob->addCandidatePosition( std::move( lp ) );
462 
463  if ( isCanceled() )
464  return nullptr;
465  }
466  }
467  nbOverlaps /= 2;
468  prob->mAllNblp = prob->mTotalCandidates;
469  prob->mNbOverlap = nbOverlaps;
470  }
471 
472  return prob;
473 }
474 
475 void Pal::registerCancellationCallback( Pal::FnIsCanceled fnCanceled, void *context )
476 {
477  fnIsCanceled = fnCanceled;
478  fnIsCanceledContext = context;
479 }
480 
481 std::unique_ptr<Problem> Pal::extractProblem( const QgsRectangle &extent, const QgsGeometry &mapBoundary )
482 {
483  return extract( extent, mapBoundary );
484 }
485 
486 QList<LabelPosition *> Pal::solveProblem( Problem *prob, bool displayAll, QList<LabelPosition *> *unlabeled )
487 {
488  if ( !prob )
489  return QList<LabelPosition *>();
490 
491  prob->reduce();
492 
493  try
494  {
495  prob->chain_search();
496  }
497  catch ( InternalException::Empty & )
498  {
499  return QList<LabelPosition *>();
500  }
501 
502  return prob->getSolution( displayAll, unlabeled );
503 }
504 
505 void Pal::setMinIt( int min_it )
506 {
507  if ( min_it >= 0 )
508  mTabuMinIt = min_it;
509 }
510 
511 void Pal::setMaxIt( int max_it )
512 {
513  if ( max_it > 0 )
514  mTabuMaxIt = max_it;
515 }
516 
517 void Pal::setPopmusicR( int r )
518 {
519  if ( r > 0 )
520  mPopmusicR = r;
521 }
522 
523 void Pal::setEjChainDeg( int degree )
524 {
525  this->mEjChainDeg = degree;
526 }
527 
528 void Pal::setTenure( int tenure )
529 {
530  this->mTenure = tenure;
531 }
532 
533 void Pal::setCandListSize( double fact )
534 {
535  this->mCandListSize = fact;
536 }
537 
538 void Pal::setShowPartialLabels( bool show )
539 {
540  this->mShowPartialLabels = show;
541 }
542 
544 {
545  return mPlacementVersion;
546 }
547 
549 {
550  mPlacementVersion = placementVersion;
551 }
552 
553 int Pal::getMinIt()
554 {
555  return mTabuMaxIt;
556 }
557 
558 int Pal::getMaxIt()
559 {
560  return mTabuMinIt;
561 }
562 
564 {
565  return mShowPartialLabels;
566 }
A rtree spatial index for use in the pal labeling engine.
Definition: palrtree.h:36
The QgsAbstractLabelProvider class is an interface class.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
static geos::unique_ptr asGeos(const QgsGeometry &geometry, double precision=0)
Returns a geos geometry - caller takes ownership of the object (should be deleted with GEOSGeom_destr...
Definition: qgsgeos.cpp:163
static GEOSContextHandle_t getGEOSHandler()
Definition: qgsgeos.cpp:2924
PlacementEngineVersion
Placement engine version.
@ PlacementEngineVersion1
Version 1, matches placement from QGIS <= 3.10.1.
@ PlacementEngineVersion2
Version 2 (default for new projects since QGIS 3.12)
Placement
Placement modes which determine how label candidates are generated for a feature.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
Definition: qgsrectangle.h:172
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
Definition: qgsrectangle.h:162
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
Definition: qgsrectangle.h:167
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:177
double height() const SIP_HOLDGIL
Returns the height of the rectangle.
Definition: qgsrectangle.h:209
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
Definition: qgsrectangle.h:202
QgsRectangle buffered(double width) const
Gets rectangle enlarged by buffer.
Definition: qgsrectangle.h:304
This class is a composition of two QSettings instances:
Definition: qgssettings.h:62
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
static void addObstacleCostPenalty(pal::LabelPosition *lp, pal::FeaturePart *obstacle, Pal *pal)
Increase candidate's cost according to its collision with passed feature.
static void finalizeCandidatesCosts(Feats *feat, double bbx[4], double bby[4])
Sort candidates by costs, skip the worse ones, evaluate polygon candidates.
static bool candidateSortGrow(const std::unique_ptr< pal::LabelPosition > &c1, const std::unique_ptr< pal::LabelPosition > &c2)
Sorts label candidates in ascending order of cost.
Main class to handle feature.
Definition: feature.h:97
std::vector< std::unique_ptr< LabelPosition > > createCandidates(Pal *pal)
Generates a list of candidate positions for labels for this feature.
Definition: feature.cpp:2066
FeaturePart * getSelfObstacle(int i)
Gets hole (inner ring) - considered as obstacle.
Definition: feature.h:332
Thrown when trying to access an empty data set.
LabelPosition is a candidate feature label position.
Definition: labelposition.h:56
A set of features which influence the labeling process.
Definition: layer.h:62
QMutex mMutex
Definition: layer.h:355
QList< FeaturePart * > mObstacleParts
List of obstacle parts.
Definition: layer.h:328
QString name() const
Returns the layer's name.
Definition: layer.h:171
bool active() const
Returns whether the layer is currently active.
Definition: layer.h:207
bool displayAll() const
Definition: layer.h:95
bool mergeConnectedLines() const
Returns whether connected lines will be merged before labeling.
Definition: layer.h:265
void joinConnectedFeatures()
Join connected features with the same label text.
Definition: layer.cpp:303
QLinkedList< FeaturePart * > mFeatureParts
List of feature parts.
Definition: layer.h:325
void chopFeaturesAtRepeatDistance()
Chop layer features at the repeat distance.
Definition: layer.cpp:348
void setPlacementVersion(QgsLabelingEngineSettings::PlacementEngineVersion placementVersion)
Sets the placement engine version, which dictates how the label placement problem is solved.
Definition: pal.cpp:548
QgsLabelingEngineSettings::PlacementEngineVersion placementVersion() const
Returns the placement engine version, which dictates how the label placement problem is solved.
Definition: pal.cpp:543
void setShowPartialLabels(bool show)
Sets whether partial labels show be allowed.
Definition: pal.cpp:538
Layer * addLayer(QgsAbstractLabelProvider *provider, const QString &layerName, QgsPalLayerSettings::Placement arrangement, double defaultPriority, bool active, bool toLabel, bool displayAll=false)
add a new layer
Definition: pal.cpp:78
std::unique_ptr< Problem > extractProblem(const QgsRectangle &extent, const QgsGeometry &mapBoundary)
Extracts the labeling problem for the specified map extent - only features within this extent will be...
Definition: pal.cpp:481
void removeLayer(Layer *layer)
remove a layer
Definition: pal.cpp:60
QList< LabelPosition * > solveProblem(Problem *prob, bool displayAll, QList< pal::LabelPosition * > *unlabeled=nullptr)
Solves the labeling problem, selecting the best candidate locations for all labels and returns a list...
Definition: pal.cpp:486
bool showPartialLabels() const
Returns whether partial labels should be allowed.
Definition: pal.cpp:563
Pal()
Create an new pal instance.
Definition: pal.cpp:50
bool isCanceled()
Check whether the job has been canceled.
Definition: pal.h:127
QgsRectangle boundingBox() const
Returns the point set bounding box.
Definition: pointset.h:157
Representation of a labeling problem.
Definition: problem.h:71
QList< LabelPosition * > getSolution(bool returnInactive, QList< LabelPosition * > *unlabeled=nullptr)
Solves the labeling problem, selecting the best candidate locations for all labels and returns a list...
Definition: problem.cpp:657
void chain_search()
Test with very-large scale neighborhood.
Definition: problem.cpp:562
void reduce()
Definition: problem.cpp:66
std::unique_ptr< const GEOSPreparedGeometry, GeosDeleter > prepared_unique_ptr
Scoped GEOS prepared geometry pointer.
Definition: qgsgeos.h:84
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79