51 else if ( dist < distlabel )
100 for (
int i = 0; i < nblp; ++i )
107 for (
int i = 0; i < nblp; ++i )
109 toSort << lPos.
at( i );
112 for (
int i = 0; i < nblp; ++i )
114 lPos[i] = toSort.
at( i );
118 double cost_max = lPos.
at( 0 )->cost();
119 double cost_min = lPos.
at( nblp - 1 )->cost();
121 cost_max -= cost_min;
125 normalizer = 0.0020 / cost_max;
134 for (
int i = 0; i < nblp; ++i )
139 lPos.
at( i )->setCost( 0.0021 - ( lPos.
at( i )->cost() - cost_min ) * normalizer );
144 lPos.
at( i )->setCost( 0.0001 );
179 if ( max_p > feat->
lPos.count() )
180 max_p = feat->
lPos.count();
186 double discrim = 0.0;
191 for ( stop = 0; stop < feat->
lPos.count() && feat->
lPos.at( stop )->cost() < discrim; stop++ )
194 while ( stop == 0 && discrim < feat->lPos.last()->cost() + 2.0 );
199 for ( k = 0; k < stop; k++ )
200 feat->
lPos.at( k )->setCost( 0.0021 );
223 px = ( lp->
x[0] + lp->
x[2] ) / 2.0;
224 py = ( lp->
y[0] + lp->
y[2] ) / 2.0;
static bool candidateSortGrow(const LabelPosition *c1, const LabelPosition *c2)
Sorts label candidates in ascending order of cost.
void setCost(double newCost)
Sets the candidate label position's geographical cost.
const T & at(int i) const
double cost() const
Returns the candidate label position's geographical cost.
void addSizePenalty(int nbp, QList< LabelPosition * > &lPos, double bbx[4], double bby[4])
LabelPosition * getLabel()
Arranges candidates following the curvature of a line feature.
void update(pal::PointSet *pset)
QgsPalLayerSettings::Placement arrangement() const
Returns the layer's arrangement policy.
static void addObstacleCostPenalty(LabelPosition *lp, pal::FeaturePart *obstacle)
Increase candidate's cost according to its collision with passed feature.
QgsPalLayerSettings::ObstacleType obstacleType() const
Returns the obstacle type, which controls how features within the layer act as obstacles for labels...
double getLabelDistance() const
PolygonCostCalculator(LabelPosition *lp)
double getDistanceToPoint(double xp, double yp) const
Get distance from this label to a point.
Layer * layer()
Returns the layer that feature belongs to.
int polygonIntersectionCost(PointSet *polygon) const
Returns cost of position intersection with polygon (testing area of intersection and center)...
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.
bool crossesLine(PointSet *line) const
Returns true if this label crosses the specified line.
For usage in problem solving algorithm.
Main class to handle feature.
void getBoundingBox(double min[2], double max[2]) const
bool intersectsWithPolygon(PointSet *polygon) const
Returns true if if any intersection between polygon and position exists.
static void setPolygonCandidatesCost(int nblp, QList< LabelPosition * > &lPos, RTree< pal::FeaturePart *, double, 2, double > *obstacles, double bbx[4], double bby[4])
bool crossesBoundary(PointSet *polygon) const
Returns true if this label crosses the boundary of the specified polygon.
void setConflictsWithObstacle(bool conflicts)
Sets whether the position is marked as conflicting with an obstacle feature.
static bool polygonObstacleCallback(pal::FeaturePart *obstacle, void *ctx)
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...
LabelPosition is a candidate feature label position.
QList< LabelPosition * > lPos
double minDistanceToPoint(double px, double py, double *rx=nullptr, double *ry=nullptr) const
Returns the squared minimum distance between the point set geometry and the point (px...
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.
Arranges candidates scattered throughout a polygon feature.