QGIS API Documentation  2.12.0-Lyon
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 
21 namespace pal
22 {
23  class Feats;
24 
26  {
27  public:
29  static void addObstacleCostPenalty( LabelPosition* lp, pal::FeaturePart *obstacle );
30 
31  static void setPolygonCandidatesCost( int nblp, QList< LabelPosition* >& lPos, RTree<pal::FeaturePart*, double, 2, double> *obstacles, double bbx[4], double bby[4] );
32 
34  static void setCandidateCostFromPolygon( LabelPosition* lp, RTree<pal::FeaturePart *, double, 2, double> *obstacles, double bbx[4], double bby[4] );
35 
37  static int finalizeCandidatesCosts( Feats* feat, int max_p, RTree<pal::FeaturePart *, double, 2, double> *obstacles, double bbx[4], double bby[4] );
38 
41  static bool candidateSortGrow( const LabelPosition *c1, const LabelPosition *c2 );
42 
45  static bool candidateSortShrink( const LabelPosition *c1, const LabelPosition *c2 );
46  };
47 
56  {
57 
58  public:
59  explicit PolygonCostCalculator( LabelPosition *lp );
60 
61  void update( pal::PointSet *pset );
62 
63  double getCost();
64 
66 
67  private:
68 
69  LabelPosition *lp;
70  double px, py;
71  double dist;
72  bool ok;
73  };
74 }
75 
76 #endif // COSTCALCULATOR_H
static bool candidateSortGrow(const LabelPosition *c1, const LabelPosition *c2)
Sorts label candidates in ascending order of cost.
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's centroid and a polygon stored in geoetry field...
For usage in problem solving algorithm.
Definition: util.h:50
Main class to handle feature.
Definition: feature.h:79
static void addObstacleCostPenalty(LabelPosition *lp, pal::FeaturePart *obstacle)
Increase candidate's cost according to its collision with passed feature.
void update(pal::PointSet *pset)
LabelPosition is a candidate feature label position.
Definition: labelposition.h:48
PolygonCostCalculator(LabelPosition *lp)
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.
static bool candidateSortShrink(const LabelPosition *c1, const LabelPosition *c2)
Sorts label candidates in descending order of cost.
Data structure to compute polygon's candidates costs.