54 else if ( dist < distlabel )
103 std::cout <<
"LabelPosition for feat: " << lPos[0]->feature->uid << std::endl;
106 for (
int i = 0; i < nblp; ++i )
113 for (
int i = 0; i < nblp; ++i )
115 toSort << lPos.
at( i );
118 for (
int i = 0; i < nblp; ++i )
120 lPos[i] = toSort.
at( i );
125 double cost_max = lPos.
at( 0 )->cost();
126 double cost_min = lPos.
at( nblp - 1 )->cost();
128 cost_max -= cost_min;
132 normalizer = 0.0020 / cost_max;
141 for (
int i = 0; i < nblp; ++i )
144 std::cout <<
" lpos[" << i <<
"] = " << lPos[i]->cost;
149 lPos.
at( i )->setCost( 0.0021 - ( lPos.
at( i )->cost() - cost_min ) * normalizer );
154 lPos.
at( i )->setCost( 0.0001 );
158 std::cout <<
" ==> " << lPos[i]->cost << std::endl;
195 if ( max_p > feat->
lPos.count() )
196 max_p = feat->
lPos.count();
202 double discrim = 0.0;
207 for ( stop = 0; stop < feat->
lPos.count() && feat->
lPos[stop]->cost() < discrim; stop++ )
210 while ( stop == 0 && discrim < feat->lPos.last()->cost() + 2.0 );
215 for ( k = 0; k < stop; k++ )
216 feat->
lPos[k]->setCost( 0.0021 );
223 std::cout <<
"Nblabel kept for feat " << feat->
feature->getUID() <<
"/" << feat->
feature->getLayer()->getName() <<
": " << max_p <<
"/" << feat->nblp << std::endl;
247 px = ( lp->
x[0] + lp->
x[2] ) / 2.0;
248 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.
static void setPolygonCandidatesCost(int nblp, QList< LabelPosition * > &lPos, RTree< pal::FeaturePart *, double, 2, double > *obstacles, double bbx[4], double bby[4])
double getDistanceToPoint(double xp, double yp) const
Get distance from this label to a point.
static bool polygonObstacleCallback(pal::FeaturePart *obstacle, void *ctx)
ObstacleType obstacleType() const
Returns the obstacle type, which controls how features within the layer act as obstacles for labels...
Arrangement arrangement() const
Returns the layer's arrangement policy.
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.
int polygonIntersectionCost(PointSet *polygon) const
Returns cost of position intersection with polygon (testing area of intersection and center)...
bool crossesLine(PointSet *line) const
Returns true if this label crosses the specified line.
Only for polygon, arranges candidates with respect of polygon orientation.
void addSizePenalty(int nbp, QList< LabelPosition * > &lPos, double bbx[4], double bby[4])
double getLabelDistance() const
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...
Layer * layer()
Returns the layer that feature belongs to.
For usage in problem solving algorithm.
Main class to handle feature.
static void addObstacleCostPenalty(LabelPosition *lp, pal::FeaturePart *obstacle)
Increase candidate's cost according to its collision with passed feature.
void getBoundingBox(double min[2], double max[2]) const
Only for lines, labels along the line.
void update(pal::PointSet *pset)
void setConflictsWithObstacle(bool conflicts)
Sets whether the position is marked as conflicting with an obstacle feature.
LabelPosition is a candidate feature label position.
PolygonCostCalculator(LabelPosition *lp)
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.
double minDistanceToPoint(double px, double py, double *rx=0, double *ry=0) 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.
bool crossesBoundary(PointSet *polygon) const
Returns true if this label crosses the boundary of the specified polygon.
QList< LabelPosition * > lPos
LabelPosition * getLabel()
Data structure to compute polygon's candidates costs.