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;
double obstacleFactor() const
Returns the feature's obstacle factor, which represents the penalty incurred for a label to overlap t...
static bool candidateSortGrow(const LabelPosition *c1, const LabelPosition *c2)
Sorts label candidates in ascending order of cost.
bool intersectsWithPolygon(PointSet *polygon) const
Returns true if if any intersection between polygon and position exists.
void setCost(double newCost)
Sets the candidate label position's geographical cost.
const T & at(int i) const
double getLabelDistance() const
LabelPosition * getLabel()
QgsPalLayerSettings::ObstacleType obstacleType() const
Returns the obstacle type, which controls how features within the layer act as obstacles for labels...
Arranges candidates following the curvature of a line feature.
void update(pal::PointSet *pset)
static void addObstacleCostPenalty(LabelPosition *lp, pal::FeaturePart *obstacle)
Increase candidate's cost according to its collision with passed feature.
double cost() const
Returns the candidate label position's geographical cost.
void addSizePenalty(int nbp, QList< LabelPosition *> &lPos, double bbx[4], double bby[4])
PolygonCostCalculator(LabelPosition *lp)
void getBoundingBox(double min[2], double max[2]) const
Layer * layer()
Returns the layer that feature belongs to.
QgsPalLayerSettings::Placement arrangement() const
Returns the layer's arrangement policy.
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.
Main class to handle feature.
int polygonIntersectionCost(PointSet *polygon) const
Returns cost of position intersection with polygon (testing area of intersection and center)...
static void setPolygonCandidatesCost(int nblp, QList< LabelPosition * > &lPos, RTree< pal::FeaturePart *, double, 2, double > *obstacles, double bbx[4], double bby[4])
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.
bool crossesBoundary(PointSet *polygon) const
Returns true if this label crosses the boundary of the specified polygon.
QList< LabelPosition * > lPos
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.
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...
bool crossesLine(PointSet *line) const
Returns true if this label crosses the specified line.
Arranges candidates scattered throughout a polygon feature.
double getDistanceToPoint(double xp, double yp) const
Get distance from this label to a point.