QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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
28namespace pal
29{
30 class Feats;
31 class LabelPosition;
32 class Pal;
33
39 {
40 public:
43
48 static void calculateCandidatePolygonRingDistanceCosts( std::vector<std::unique_ptr<pal::LabelPosition> > &lPos, double bbx[4], double bby[4] );
49
55 static void calculateCandidatePolygonCentroidDistanceCosts( pal::FeaturePart *feature, std::vector<std::unique_ptr<pal::LabelPosition> > &lPos );
56
58 static double calculatePolygonRingDistance( LabelPosition *candidate, double bbx[4], double bby[4] );
59
61 static void finalizeCandidatesCosts( Feats *feat, double bbx[4], double bby[4] );
62
66 static bool candidateSortGrow( const std::unique_ptr<pal::LabelPosition> &c1, const std::unique_ptr<pal::LabelPosition> &c2 );
67 };
68
76 {
77
78 public:
79
84
89 void addRing( const pal::PointSet *ring );
90
94 double minimumDistance() const;
95
96 private:
97
98 double mPx;
99 double mPy;
100 double mMinDistance = std::numeric_limits<double>::max();
101 };
102}
103
104#endif // COSTCALCULATOR_H
Calculates distance from a label candidate to nearest polygon ring.
void addRing(const pal::PointSet *ring)
Adds a ring to the calculation, updating the minimumDistance() value if the rings is closer to the ca...
double minimumDistance() const
Returns the minimum distance between the candidate and all added rings.
CandidatePolygonRingDistanceCalculator(LabelPosition *candidate)
Constructor for PolygonRingDistanceCalculator, for the specified label candidate.
Calculates label candidate costs considering different factors.
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.
static void addObstacleCostPenalty(pal::LabelPosition *lp, pal::FeaturePart *obstacle, Pal *pal)
Increase candidate's cost according to its collision with passed feature.
static void finalizeCandidatesCosts(Feats *feat, double bbx[4], double bby[4])
Sort candidates by costs, skip the worse ones, evaluate polygon candidates.
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.
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...
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...
For usage in problem solving algorithm.
Definition: util.h:54
Main class to handle feature.
Definition: feature.h:65
LabelPosition is a candidate feature label position.
Definition: labelposition.h:56
Main Pal labeling class.
Definition: pal.h:80
The underlying raw pal geometry class.
Definition: pointset.h:77