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