QGIS API Documentation  3.2.0-Bonn (bc43194)
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 "rtree.hpp"
36 #include "costcalculator.h"
37 #include "feature.h"
38 #include "geomfunction.h"
39 #include "labelposition.h"
40 #include "problem.h"
41 #include "pointset.h"
42 #include "internalexception.h"
43 #include "util.h"
44 #include <cfloat>
45 
46 using namespace pal;
47 
49 {
50  // do not init and exit GEOS - we do it inside QGIS
51  //initGEOS( geosNotice, geosError );
52 
53  fnIsCanceled = nullptr;
54  fnIsCanceledContext = nullptr;
55 
56  ejChainDeg = 50;
57  tenure = 10;
58  candListSize = 0.2;
59 
60  tabuMinIt = 3;
61  tabuMaxIt = 4;
62  searchMethod = POPMUSIC_CHAIN;
63  popmusic_r = 30;
64 
65  searchMethod = CHAIN;
66 
67  setSearch( CHAIN );
68 
69  point_p = 16;
70  line_p = 50;
71  poly_p = 30;
72 
73  showPartial = true;
74 }
75 
76 void Pal::removeLayer( Layer *layer )
77 {
78  if ( !layer )
79  return;
80 
81  mMutex.lock();
82  if ( QgsAbstractLabelProvider *key = mLayers.key( layer, nullptr ) )
83  {
84  mLayers.remove( key );
85  delete layer;
86  }
87  mMutex.unlock();
88 }
89 
91 {
92 
93  mMutex.lock();
94 
95  qDeleteAll( mLayers );
96  mLayers.clear();
97  mMutex.unlock();
98 
99  // do not init and exit GEOS - we do it inside QGIS
100  //finishGEOS();
101 }
102 
103 Layer *Pal::addLayer( QgsAbstractLabelProvider *provider, const QString &layerName, QgsPalLayerSettings::Placement arrangement, double defaultPriority, bool active, bool toLabel, bool displayAll )
104 {
105  mMutex.lock();
106 
107  Q_ASSERT( !mLayers.contains( provider ) );
108 
109  Layer *layer = new Layer( provider, layerName, arrangement, defaultPriority, active, toLabel, this, displayAll );
110  mLayers.insert( provider, layer );
111  mMutex.unlock();
112 
113  return layer;
114 }
115 
116 typedef struct _featCbackCtx
117 {
118  Layer *layer = nullptr;
119  QLinkedList<Feats *> *fFeats;
120  RTree<FeaturePart *, double, 2, double> *obstacles;
121  RTree<LabelPosition *, double, 2, double> *candidates;
122  const GEOSPreparedGeometry *mapBoundary = nullptr;
124 
125 
126 
127 /*
128  * Callback function
129  *
130  * Extract a specific shape from indexes
131  */
132 bool extractFeatCallback( FeaturePart *ft_ptr, void *ctx )
133 {
134  double amin[2], amax[2];
135  FeatCallBackCtx *context = reinterpret_cast< FeatCallBackCtx * >( ctx );
136 
137  // Holes of the feature are obstacles
138  for ( int i = 0; i < ft_ptr->getNumSelfObstacles(); i++ )
139  {
140  ft_ptr->getSelfObstacle( i )->getBoundingBox( amin, amax );
141  context->obstacles->Insert( amin, amax, ft_ptr->getSelfObstacle( i ) );
142 
143  if ( !ft_ptr->getSelfObstacle( i )->getHoleOf() )
144  {
145  //ERROR: SHOULD HAVE A PARENT!!!!!
146  }
147  }
148 
149  // generate candidates for the feature part
150  QList< LabelPosition * > lPos;
151  if ( ft_ptr->createCandidates( lPos, context->mapBoundary, ft_ptr, context->candidates ) )
152  {
153  // valid features are added to fFeats
154  Feats *ft = new Feats();
155  ft->feature = ft_ptr;
156  ft->shape = nullptr;
157  ft->lPos = lPos;
158  ft->priority = ft_ptr->calculatePriority();
159  context->fFeats->append( ft );
160  }
161  else
162  {
163  // Others are deleted
164  qDeleteAll( lPos );
165  }
166 
167  return true;
168 }
169 
170 typedef struct _obstaclebackCtx
171 {
172  RTree<FeaturePart *, double, 2, double> *obstacles;
175 
176 /*
177  * Callback function
178  *
179  * Extract obstacles from indexes
180  */
181 bool extractObstaclesCallback( FeaturePart *ft_ptr, void *ctx )
182 {
183  double amin[2], amax[2];
184  ObstacleCallBackCtx *context = reinterpret_cast< ObstacleCallBackCtx * >( ctx );
185 
186  // insert into obstacles
187  ft_ptr->getBoundingBox( amin, amax );
188  context->obstacles->Insert( amin, amax, ft_ptr );
189  context->obstacleCount++;
190  return true;
191 }
192 
193 typedef struct _filterContext
194 {
195  RTree<LabelPosition *, double, 2, double> *cdtsIndex;
196  Pal *pal = nullptr;
197 } FilterContext;
198 
199 bool filteringCallback( FeaturePart *featurePart, void *ctx )
200 {
201 
202  RTree<LabelPosition *, double, 2, double> *cdtsIndex = ( reinterpret_cast< FilterContext * >( ctx ) )->cdtsIndex;
203  Pal *pal = ( reinterpret_cast< FilterContext * >( ctx ) )->pal;
204 
205  if ( pal->isCanceled() )
206  return false; // do not continue searching
207 
208  double amin[2], amax[2];
209  featurePart->getBoundingBox( amin, amax );
210 
211  LabelPosition::PruneCtx pruneContext;
212  pruneContext.obstacle = featurePart;
213  pruneContext.pal = pal;
214  cdtsIndex->Search( amin, amax, LabelPosition::pruneCallback, static_cast< void * >( &pruneContext ) );
215 
216  return true;
217 }
218 
219 std::unique_ptr<Problem> Pal::extract( const QgsRectangle &extent, const QgsGeometry &mapBoundary )
220 {
221  // to store obstacles
222  RTree<FeaturePart *, double, 2, double> *obstacles = new RTree<FeaturePart *, double, 2, double>();
223 
224  std::unique_ptr< Problem > prob = qgis::make_unique< Problem >();
225 
226  int i, j;
227 
228  double bbx[4];
229  double bby[4];
230 
231  double amin[2];
232  double amax[2];
233 
234  int max_p = 0;
235 
236  LabelPosition *lp = nullptr;
237 
238  bbx[0] = bbx[3] = amin[0] = prob->bbox[0] = extent.xMinimum();
239  bby[0] = bby[1] = amin[1] = prob->bbox[1] = extent.yMinimum();
240  bbx[1] = bbx[2] = amax[0] = prob->bbox[2] = extent.xMaximum();
241  bby[2] = bby[3] = amax[1] = prob->bbox[3] = extent.yMaximum();
242 
243  prob->pal = this;
244 
245  QLinkedList<Feats *> *fFeats = new QLinkedList<Feats *>;
246 
247  FeatCallBackCtx context;
248 
249  // prepare map boundary
250  geos::unique_ptr mapBoundaryGeos( QgsGeos::asGeos( mapBoundary ) );
251  geos::prepared_unique_ptr mapBoundaryPrepared( GEOSPrepare_r( QgsGeos::getGEOSHandler(), mapBoundaryGeos.get() ) );
252 
253  context.fFeats = fFeats;
254  context.obstacles = obstacles;
255  context.candidates = prob->candidates;
256  context.mapBoundary = mapBoundaryPrepared.get();
257 
258  ObstacleCallBackCtx obstacleContext;
259  obstacleContext.obstacles = obstacles;
260  obstacleContext.obstacleCount = 0;
261 
262  // first step : extract features from layers
263 
264  int previousFeatureCount = 0;
265  int previousObstacleCount = 0;
266 
267  QStringList layersWithFeaturesInBBox;
268 
269  mMutex.lock();
270  Q_FOREACH ( Layer *layer, mLayers )
271  {
272  if ( !layer )
273  {
274  // invalid layer name
275  continue;
276  }
277 
278  // only select those who are active
279  if ( !layer->active() )
280  continue;
281 
282  // check for connected features with the same label text and join them
283  if ( layer->mergeConnectedLines() )
284  layer->joinConnectedFeatures();
285 
287 
288  layer->mMutex.lock();
289 
290  // find features within bounding box and generate candidates list
291  context.layer = layer;
292  layer->mFeatureIndex->Search( amin, amax, extractFeatCallback, static_cast< void * >( &context ) );
293  // find obstacles within bounding box
294  layer->mObstacleIndex->Search( amin, amax, extractObstaclesCallback, static_cast< void * >( &obstacleContext ) );
295 
296  layer->mMutex.unlock();
297 
298  if ( context.fFeats->size() - previousFeatureCount > 0 || obstacleContext.obstacleCount > previousObstacleCount )
299  {
300  layersWithFeaturesInBBox << layer->name();
301  }
302  previousFeatureCount = context.fFeats->size();
303  previousObstacleCount = obstacleContext.obstacleCount;
304  }
305  mMutex.unlock();
306 
307  prob->nbLabelledLayers = layersWithFeaturesInBBox.size();
308  prob->labelledLayersName = layersWithFeaturesInBBox;
309 
310  if ( fFeats->isEmpty() )
311  {
312  delete fFeats;
313  delete obstacles;
314  return nullptr;
315  }
316 
317  prob->nbft = fFeats->size();
318  prob->nblp = 0;
319  prob->featNbLp = new int [prob->nbft];
320  prob->featStartId = new int [prob->nbft];
321  prob->inactiveCost = new double[prob->nbft];
322 
323  Feats *feat = nullptr;
324 
325  // Filtering label positions against obstacles
326  amin[0] = amin[1] = std::numeric_limits<double>::lowest();
327  amax[0] = amax[1] = std::numeric_limits<double>::max();
328  FilterContext filterCtx;
329  filterCtx.cdtsIndex = prob->candidates;
330  filterCtx.pal = this;
331  obstacles->Search( amin, amax, filteringCallback, static_cast< void * >( &filterCtx ) );
332 
333  if ( isCanceled() )
334  {
335  Q_FOREACH ( Feats *feat, *fFeats )
336  {
337  qDeleteAll( feat->lPos );
338  feat->lPos.clear();
339  }
340 
341  qDeleteAll( *fFeats );
342  delete fFeats;
343  delete obstacles;
344  return nullptr;
345  }
346 
347  int idlp = 0;
348  for ( i = 0; i < prob->nbft; i++ ) /* foreach feature into prob */
349  {
350  feat = fFeats->takeFirst();
351 
352  prob->featStartId[i] = idlp;
353  prob->inactiveCost[i] = std::pow( 2, 10 - 10 * feat->priority );
354 
355  switch ( feat->feature->getGeosType() )
356  {
357  case GEOS_POINT:
358  max_p = point_p;
359  break;
360  case GEOS_LINESTRING:
361  max_p = line_p;
362  break;
363  case GEOS_POLYGON:
364  max_p = poly_p;
365  break;
366  }
367 
368  // sort candidates by cost, skip less interesting ones, calculate polygon costs (if using polygons)
369  max_p = CostCalculator::finalizeCandidatesCosts( feat, max_p, obstacles, bbx, bby );
370 
371  // only keep the 'max_p' best candidates
372  while ( feat->lPos.count() > max_p )
373  {
374  // TODO remove from index
375  feat->lPos.last()->removeFromIndex( prob->candidates );
376  delete feat->lPos.takeLast();
377  }
378 
379  // update problem's # candidate
380  prob->featNbLp[i] = feat->lPos.count();
381  prob->nblp += feat->lPos.count();
382 
383  // add all candidates into a rtree (to speed up conflicts searching)
384  for ( j = 0; j < feat->lPos.count(); j++, idlp++ )
385  {
386  lp = feat->lPos.at( j );
387  //lp->insertIntoIndex(prob->candidates);
388  lp->setProblemIds( i, idlp ); // bugfix #1 (maxence 10/23/2008)
389  }
390  fFeats->append( feat );
391  }
392 
393  int nbOverlaps = 0;
394 
395  while ( !fFeats->isEmpty() ) // foreach feature
396  {
397  if ( isCanceled() )
398  {
399  Q_FOREACH ( Feats *feat, *fFeats )
400  {
401  qDeleteAll( feat->lPos );
402  feat->lPos.clear();
403  }
404 
405  qDeleteAll( *fFeats );
406  delete fFeats;
407  delete obstacles;
408  return nullptr;
409  }
410 
411  feat = fFeats->takeFirst();
412  while ( !feat->lPos.isEmpty() ) // foreach label candidate
413  {
414  lp = feat->lPos.takeFirst();
415  lp->resetNumOverlaps();
416 
417  // make sure that candidate's cost is less than 1
418  lp->validateCost();
419 
420  prob->addCandidatePosition( lp );
421  //prob->feat[idlp] = j;
422 
423  lp->getBoundingBox( amin, amax );
424 
425  // lookup for overlapping candidate
426  prob->candidates->Search( amin, amax, LabelPosition::countOverlapCallback, static_cast< void * >( lp ) );
427 
428  nbOverlaps += lp->getNumOverlaps();
429  }
430  delete feat;
431  }
432  delete fFeats;
433 
434  //delete candidates;
435  delete obstacles;
436 
437  nbOverlaps /= 2;
438  prob->all_nblp = prob->nblp;
439  prob->nbOverlap = nbOverlaps;
440 
441  return prob;
442 }
443 
444 void Pal::registerCancelationCallback( Pal::FnIsCanceled fnCanceled, void *context )
445 {
446  fnIsCanceled = fnCanceled;
447  fnIsCanceledContext = context;
448 }
449 
450 std::unique_ptr<Problem> Pal::extractProblem( const QgsRectangle &extent, const QgsGeometry &mapBoundary )
451 {
452  return extract( extent, mapBoundary );
453 }
454 
455 QList<LabelPosition *> Pal::solveProblem( Problem *prob, bool displayAll )
456 {
457  if ( !prob )
458  return QList<LabelPosition *>();
459 
460  prob->reduce();
461 
462  try
463  {
464  if ( searchMethod == FALP )
465  prob->init_sol_falp();
466  else if ( searchMethod == CHAIN )
467  prob->chain_search();
468  else
469  prob->popmusic();
470  }
471  catch ( InternalException::Empty & )
472  {
473  return QList<LabelPosition *>();
474  }
475 
476  return prob->getSolution( displayAll );
477 }
478 
479 
480 void Pal::setPointP( int point_p )
481 {
482  if ( point_p > 0 )
483  this->point_p = point_p;
484 }
485 
486 void Pal::setLineP( int line_p )
487 {
488  if ( line_p > 0 )
489  this->line_p = line_p;
490 }
491 
492 void Pal::setPolyP( int poly_p )
493 {
494  if ( poly_p > 0 )
495  this->poly_p = poly_p;
496 }
497 
498 
499 void Pal::setMinIt( int min_it )
500 {
501  if ( min_it >= 0 )
502  tabuMinIt = min_it;
503 }
504 
505 void Pal::setMaxIt( int max_it )
506 {
507  if ( max_it > 0 )
508  tabuMaxIt = max_it;
509 }
510 
511 void Pal::setPopmusicR( int r )
512 {
513  if ( r > 0 )
514  popmusic_r = r;
515 }
516 
517 void Pal::setEjChainDeg( int degree )
518 {
519  this->ejChainDeg = degree;
520 }
521 
522 void Pal::setTenure( int tenure )
523 {
524  this->tenure = tenure;
525 }
526 
527 void Pal::setCandListSize( double fact )
528 {
529  this->candListSize = fact;
530 }
531 
532 void Pal::setShowPartial( bool show )
533 {
534  this->showPartial = show;
535 }
536 
538 {
539  return point_p;
540 }
541 
543 {
544  return line_p;
545 }
546 
548 {
549  return poly_p;
550 }
551 
552 int Pal::getMinIt()
553 {
554  return tabuMaxIt;
555 }
556 
557 int Pal::getMaxIt()
558 {
559  return tabuMinIt;
560 }
561 
563 {
564  return showPartial;
565 }
566 
568 {
569  return searchMethod;
570 }
571 
573 {
574  switch ( method )
575  {
576  case POPMUSIC_CHAIN:
577  searchMethod = method;
578  popmusic_r = 30;
579  tabuMinIt = 2;
580  tabuMaxIt = 4;
581  tenure = 10;
582  ejChainDeg = 50;
583  candListSize = 0.2;
584  break;
585  case CHAIN:
586  searchMethod = method;
587  ejChainDeg = 50;
588  break;
589  case POPMUSIC_TABU:
590  searchMethod = method;
591  popmusic_r = 25;
592  tabuMinIt = 2;
593  tabuMaxIt = 4;
594  tenure = 10;
595  ejChainDeg = 50;
596  candListSize = 0.2;
597  break;
598  case POPMUSIC_TABU_CHAIN:
599  searchMethod = method;
600  popmusic_r = 25;
601  tabuMinIt = 2;
602  tabuMaxIt = 4;
603  tenure = 10;
604  ejChainDeg = 50;
605  candListSize = 0.2;
606  break;
607  case FALP:
608  searchMethod = method;
609  break;
610  }
611 }
612 
613 
struct _obstaclebackCtx ObstacleCallBackCtx
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:103
struct _filterContext FilterContext
A rectangle specified with double values.
Definition: qgsrectangle.h:40
bool mergeConnectedLines() const
Returns whether connected lines will be merged before labeling.
Definition: layer.h:216
Pal * pal
Definition: pal.cpp:196
PointSet * getHoleOf()
Returns NULL if this isn&#39;t a hole. Otherwise returns pointer to parent pointset.
Definition: pointset.h:135
FeaturePart * feature
Definition: util.h:56
struct _featCbackCtx FeatCallBackCtx
Definition: pal.h:65
void reduce()
Definition: problem.cpp:113
void getBoundingBox(double amin[2], double amax[2]) const
Returns bounding box - amin: xmin,ymin - amax: xmax,ymax.
SearchMethod getSearch()
Returns the search method in use.
Definition: pal.cpp:567
std::unique_ptr< const GEOSPreparedGeometry, GeosDeleter > prepared_unique_ptr
Scoped GEOS prepared geometry pointer.
Definition: qgsgeos.h:84
A set of features which influence the labeling process.
Definition: layer.h:63
RTree< LabelPosition *, double, 2, double > * candidates
Definition: pal.cpp:121
Main Pal labeling class.
Definition: pal.h:87
void chopFeaturesAtRepeatDistance()
Chop layer features at the repeat distance *.
Definition: layer.cpp:419
Is slower and best than TABU, worse and faster than TABU_CHAIN.
Definition: pal.h:64
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:104
int getNumSelfObstacles() const
Gets number of holes (inner rings) - they are considered as obstacles.
Definition: feature.h:277
void setShowPartial(bool show)
Set flag show partial label.
Definition: pal.cpp:532
const GEOSPreparedGeometry * mapBoundary
Definition: pal.cpp:122
int getPointP()
Returns the number of candidates to generate for point features.
Definition: pal.cpp:537
PointSet * shape
Definition: util.h:57
Is a little bit better than CHAIN but slower.
Definition: pal.h:63
static GEOSContextHandle_t getGEOSHandler()
Definition: qgsgeos.cpp:2775
void removeLayer(Layer *layer)
remove a layer
Definition: pal.cpp:76
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:450
RTree< FeaturePart *, double, 2, double, 8, 4 > * mFeatureIndex
Definition: layer.h:300
int getPolyP()
Returns the number of candidates to generate for polygon features.
Definition: pal.cpp:547
void chain_search()
Test with very-large scale neighborhood.
Definition: problem.cpp:2127
bool(* FnIsCanceled)(void *ctx)
Definition: pal.h:129
bool getShowPartial()
Returns whether partial labels should be allowed.
Definition: pal.cpp:562
void joinConnectedFeatures()
Join connected features with the same label text.
Definition: layer.cpp:351
void getBoundingBox(double min[2], double max[2]) const
Definition: pointset.h:126
Is the best but slowest.
Definition: pal.h:62
bool isCanceled()
Check whether the job has been canceled.
Definition: pal.h:135
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79
double calculatePriority() const
Calculates the priority for the feature.
Definition: feature.cpp:1713
void setPointP(int point_p)
set # candidates to generate for points features Higher the value is, longer Pal::labeller will spend...
Definition: pal.cpp:480
void setLineP(int line_p)
set maximum # candidates to generate for lines features Higher the value is, longer Pal::labeller wil...
Definition: pal.cpp:486
int createCandidates(QList< LabelPosition *> &lPos, const GEOSPreparedGeometry *mapBoundary, PointSet *mapShape, RTree< LabelPosition *, double, 2, double > *candidates)
Generic method to generate label candidates for the feature.
Definition: feature.cpp:1519
static int finalizeCandidatesCosts(Feats *feat, int max_p, RTree< pal::FeaturePart *, double, 2, double > *obstacles, double bbx[4], double bby[4])
Sort candidates by costs, skip the worse ones, evaluate polygon candidates.
void validateCost()
Make sure the cost is less than 1.
QList< LabelPosition * > lPos
Definition: util.h:59
For usage in problem solving algorithm.
Definition: util.h:50
void popmusic()
popmusic framework
Definition: problem.cpp:379
double priority
Definition: util.h:58
bool extractObstaclesCallback(FeaturePart *ft_ptr, void *ctx)
Definition: pal.cpp:181
Main class to handle feature.
Definition: feature.h:96
The QgsAbstractLabelProvider class is an interface class.
static bool pruneCallback(LabelPosition *candidatePosition, void *ctx)
Check whether the candidate in ctx overlap with obstacle feat.
QLinkedList< Feats * > * fFeats
Definition: pal.cpp:119
friend class Layer
Definition: pal.h:91
Pal()
Create an new pal instance.
Definition: pal.cpp:48
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:176
double xMaximum() const
Returns the x maximum value (right side of rectangle).
Definition: qgsrectangle.h:161
Placement
Placement modes which determine how label candidates are generated for a feature. ...
RTree< LabelPosition *, double, 2, double > * cdtsIndex
Definition: pal.cpp:195
static bool countOverlapCallback(LabelPosition *lp, void *ctx)
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:166
void setPolyP(int poly_p)
set maximum # candidates to generate for polygon features Higher the value is, longer Pal::labeller w...
Definition: pal.cpp:492
void registerCancelationCallback(FnIsCanceled fnCanceled, void *context)
Register a function that returns whether this job has been canceled - PAL calls it during the computa...
Definition: pal.cpp:444
int getNumOverlaps() const
RTree< FeaturePart *, double, 2, double > * obstacles
Definition: pal.cpp:120
RTree< FeaturePart *, double, 2, double, 8, 4 > * mObstacleIndex
Definition: layer.h:305
QList< LabelPosition * > solveProblem(Problem *prob, bool displayAll)
Definition: pal.cpp:455
FeaturePart * getSelfObstacle(int i)
Gets hole (inner ring) - considered as obstacle.
Definition: feature.h:279
QMutex mMutex
Definition: layer.h:311
int getGeosType() const
Definition: pointset.h:124
int obstacleCount
Definition: pal.cpp:173
QString name() const
Returns the layer&#39;s name.
Definition: layer.h:96
bool active() const
Returns whether the layer is currently active.
Definition: layer.h:145
bool filteringCallback(FeaturePart *featurePart, void *ctx)
Definition: pal.cpp:199
LabelPosition is a candidate feature label position.
Definition: labelposition.h:55
double xMinimum() const
Returns the x minimum value (left side of rectangle).
Definition: qgsrectangle.h:166
RTree< FeaturePart *, double, 2, double > * obstacles
Definition: pal.cpp:172
Representation of a labeling problem.
Definition: problem.h:107
double yMaximum() const
Returns the y maximum value (top side of rectangle).
Definition: qgsrectangle.h:171
~Pal()
Definition: pal.cpp:90
bool extractFeatCallback(FeaturePart *ft_ptr, void *ctx)
Definition: pal.cpp:132
SearchMethod
Search method to use.
Definition: pal.h:59
void setProblemIds(int probFid, int lpId)
Set problem feature ID and assigned label candidate ID.
Is the worst but fastest method.
Definition: pal.h:61
Thrown when trying to access an empty data set.
Layer * layer
Definition: pal.cpp:118
void setSearch(SearchMethod method)
Select the search method to use.
Definition: pal.cpp:572
QList< LabelPosition * > getSolution(bool returnInactive)
Definition: problem.cpp:2231
int getLineP()
Returns the number of candidates to generate for line features.
Definition: pal.cpp:542
void init_sol_falp()
Definition: problem.cpp:266