QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 "palrtree.h"
22 
28 namespace pal
29 {
30  class Feats;
31  class LabelPosition;
32  class Pal;
33 
38  {
39  public:
41  static void addObstacleCostPenalty( pal::LabelPosition *lp, pal::FeaturePart *obstacle, Pal *pal );
42 
47  static void calculateCandidatePolygonRingDistanceCosts( std::vector<std::unique_ptr<pal::LabelPosition> > &lPos, double bbx[4], double bby[4] );
48 
54  static void calculateCandidatePolygonCentroidDistanceCosts( pal::FeaturePart *feature, std::vector<std::unique_ptr<pal::LabelPosition> > &lPos );
55 
57  static double calculatePolygonRingDistance( LabelPosition *candidate, double bbx[4], double bby[4] );
58 
60  static void finalizeCandidatesCosts( Feats *feat, double bbx[4], double bby[4] );
61 
65  static bool candidateSortGrow( const std::unique_ptr<pal::LabelPosition> &c1, const std::unique_ptr<pal::LabelPosition> &c2 );
66  };
67 
75  {
76 
77  public:
78 
83 
88  void addRing( const pal::PointSet *ring );
89 
93  double minimumDistance() const;
94 
95  private:
96 
97  double mPx;
98  double mPy;
99  double mMinDistance = std::numeric_limits<double>::max();
100  };
101 }
102 
103 #endif // COSTCALCULATOR_H
pal::CandidatePolygonRingDistanceCalculator::CandidatePolygonRingDistanceCalculator
CandidatePolygonRingDistanceCalculator(LabelPosition *candidate)
Constructor for PolygonRingDistanceCalculator, for the specified label candidate.
Definition: costcalculator.cpp:262
pal::LabelPosition
LabelPosition is a candidate feature label position.
Definition: labelposition.h:55
pal::CandidatePolygonRingDistanceCalculator::minimumDistance
double minimumDistance() const
Returns the minimum distance between the candidate and all added rings.
Definition: costcalculator.cpp:277
pal
Definition: qgsdiagramrenderer.h:49
pal::CostCalculator::calculatePolygonRingDistance
static double calculatePolygonRingDistance(LabelPosition *candidate, double bbx[4], double bby[4])
Calculates the distance between a label candidate and the closest ring for a polygon feature.
Definition: costcalculator.cpp:183
pal::CostCalculator::candidateSortGrow
static bool candidateSortGrow(const std::unique_ptr< pal::LabelPosition > &c1, const std::unique_ptr< pal::LabelPosition > &c2)
Sorts label candidates in ascending order of cost.
Definition: costcalculator.cpp:28
palrtree.h
pal::CostCalculator
Definition: costcalculator.h:37
pal::CostCalculator::finalizeCandidatesCosts
static void finalizeCandidatesCosts(Feats *feat, double bbx[4], double bby[4])
Sort candidates by costs, skip the worse ones, evaluate polygon candidates.
Definition: costcalculator.cpp:210
pal::FeaturePart
Main class to handle feature.
Definition: feature.h:95
pal::PointSet
Definition: pointset.h:71
pal::CostCalculator::addObstacleCostPenalty
static void addObstacleCostPenalty(pal::LabelPosition *lp, pal::FeaturePart *obstacle, Pal *pal)
Increase candidate's cost according to its collision with passed feature.
Definition: costcalculator.cpp:33
pal::CostCalculator::calculateCandidatePolygonCentroidDistanceCosts
static void calculateCandidatePolygonCentroidDistanceCosts(pal::FeaturePart *feature, std::vector< std::unique_ptr< pal::LabelPosition > > &lPos)
Updates the costs for polygon label candidates by considering the distance between the candidates and...
Definition: costcalculator.cpp:143
pal::CostCalculator::calculateCandidatePolygonRingDistanceCosts
static void calculateCandidatePolygonRingDistanceCosts(std::vector< std::unique_ptr< pal::LabelPosition > > &lPos, double bbx[4], double bby[4])
Updates the costs for polygon label candidates by considering the distance between the candidates and...
Definition: costcalculator.cpp:110
pal::Pal
Main Pal labeling class.
Definition: pal.h:79
pal::Feats
For usage in problem solving algorithm.
Definition: util.h:53
pal::CandidatePolygonRingDistanceCalculator
Calculates distance from a label candidate to nearest polygon ring.
Definition: costcalculator.h:74
pal::CandidatePolygonRingDistanceCalculator::addRing
void addRing(const pal::PointSet *ring)
Adds a ring to the calculation, updating the minimumDistance() value if the rings is closer to the ca...
Definition: costcalculator.cpp:268