QGIS API Documentation  2.14.0-Essen
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 
31  {
32  public:
34  static void addObstacleCostPenalty( LabelPosition* lp, pal::FeaturePart *obstacle );
35 
36  static void setPolygonCandidatesCost( int nblp, QList< LabelPosition* >& lPos, RTree<pal::FeaturePart*, double, 2, double> *obstacles, double bbx[4], double bby[4] );
37 
39  static void setCandidateCostFromPolygon( LabelPosition* lp, RTree<pal::FeaturePart *, double, 2, double> *obstacles, double bbx[4], double bby[4] );
40 
42  static int finalizeCandidatesCosts( Feats* feat, int max_p, RTree<pal::FeaturePart *, double, 2, double> *obstacles, double bbx[4], double bby[4] );
43 
46  static bool candidateSortGrow( const LabelPosition *c1, const LabelPosition *c2 );
47 
50  static bool candidateSortShrink( const LabelPosition *c1, const LabelPosition *c2 );
51  };
52 
63  {
64 
65  public:
66  explicit PolygonCostCalculator( LabelPosition *lp );
67 
68  void update( pal::PointSet *pset );
69 
70  double getCost();
71 
72  LabelPosition *getLabel();
73 
74  private:
75 
76  LabelPosition *lp;
77  double px, py;
78  double dist;
79  bool ok;
80  };
81 }
82 
83 #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:49
Main class to handle feature.
Definition: feature.h:90
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:50
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.