QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
costcalculator.h
Go to the documentation of this file.
1 /***************************************************************************
2  costcalculator.h
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef COSTCALCULATOR_H
16 #define COSTCALCULATOR_H
17 
18 #include <QList>
19 #include "rtree.hpp"
20 
26 namespace pal
27 {
28  class Feats;
29 
33  {
34  public:
36  static void addObstacleCostPenalty( LabelPosition* lp, pal::FeaturePart *obstacle );
37 
38  static void setPolygonCandidatesCost( int nblp, QList< LabelPosition* >& lPos, RTree<pal::FeaturePart*, double, 2, double> *obstacles, double bbx[4], double bby[4] );
39 
41  static void setCandidateCostFromPolygon( LabelPosition* lp, RTree<pal::FeaturePart *, double, 2, double> *obstacles, double bbx[4], double bby[4] );
42 
44  static int finalizeCandidatesCosts( Feats* feat, int max_p, RTree<pal::FeaturePart *, double, 2, double> *obstacles, double bbx[4], double bby[4] );
45 
48  static bool candidateSortGrow( const LabelPosition *c1, const LabelPosition *c2 );
49 
52  static bool candidateSortShrink( const LabelPosition *c1, const LabelPosition *c2 );
53  };
54 
66  {
67 
68  public:
69  explicit PolygonCostCalculator( LabelPosition *lp );
70 
71  void update( pal::PointSet *pset );
72 
73  double getCost();
74 
75  LabelPosition *getLabel();
76 
77  private:
78 
79  LabelPosition *lp;
80  double px, py;
81  double dist;
82  bool ok;
83  };
84 }
85 
86 #endif // COSTCALCULATOR_H
static bool candidateSortGrow(const LabelPosition *c1, const LabelPosition *c2)
Sorts label candidates in ascending order of cost.
static void addObstacleCostPenalty(LabelPosition *lp, pal::FeaturePart *obstacle)
Increase candidate&#39;s cost according to its collision with passed feature.
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.
For usage in problem solving algorithm.
Definition: util.h:50
Main class to handle feature.
Definition: feature.h:91
static void setPolygonCandidatesCost(int nblp, QList< LabelPosition * > &lPos, RTree< pal::FeaturePart *, double, 2, double > *obstacles, double bbx[4], double bby[4])
static void setCandidateCostFromPolygon(LabelPosition *lp, RTree< pal::FeaturePart *, double, 2, double > *obstacles, double bbx[4], double bby[4])
Set cost to the smallest distance between lPos&#39;s centroid and a polygon stored in geoetry field...
LabelPosition is a candidate feature label position.
Definition: labelposition.h:51
static bool candidateSortShrink(const LabelPosition *c1, const LabelPosition *c2)
Sorts label candidates in descending order of cost.
Data structure to compute polygon&#39;s candidates costs.