QGIS API Documentation  3.6.0-Noosa (5873452)
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 #define SIP_NO_FILE
19 
20 #include <QList>
21 #include "rtree.hpp"
22 
28 namespace pal
29 {
30  class Feats;
31 
36  {
37  public:
39  static void addObstacleCostPenalty( LabelPosition *lp, pal::FeaturePart *obstacle );
40 
41  static void setPolygonCandidatesCost( int nblp, QList< LabelPosition * > &lPos, RTree<pal::FeaturePart *, double, 2, double> *obstacles, double bbx[4], double bby[4] );
42 
44  static void setCandidateCostFromPolygon( LabelPosition *lp, RTree<pal::FeaturePart *, double, 2, double> *obstacles, double bbx[4], double bby[4] );
45 
47  static int finalizeCandidatesCosts( Feats *feat, int max_p, RTree<pal::FeaturePart *, double, 2, double> *obstacles, double bbx[4], double bby[4] );
48 
52  static bool candidateSortGrow( const LabelPosition *c1, const LabelPosition *c2 );
53 
57  static bool candidateSortShrink( const LabelPosition *c1, const LabelPosition *c2 );
58  };
59 
71  {
72 
73  public:
74  explicit PolygonCostCalculator( LabelPosition *lp );
75 
76  void update( pal::PointSet *pset );
77 
78  double getCost();
79 
80  LabelPosition *getLabel();
81 
82  private:
83 
84  LabelPosition *lp = nullptr;
85  double px, py;
86  double dist;
87  bool ok;
88  };
89 }
90 
91 #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:96
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])
Sets 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:55
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.