54 else if ( dist < distlabel )
85 std::cout <<
"LabelPosition for feat: " << lPos[0]->
feature->uid << std::endl;
88 for ( i = 0; i < nblp; i++ )
97 double cost_max = lPos[0]->
getCost();
98 double cost_min = lPos[max_p-1]->
getCost();
100 cost_max -= cost_min;
104 normalizer = 0.0020 / cost_max;
113 for ( i = 0; i < max_p; i++ )
116 std::cout <<
" lpos[" << i <<
"] = " << lPos[i]->
cost;
121 lPos[i]->
cost = 0.0021 - ( lPos[i]->
getCost() - cost_min ) * normalizer;
126 lPos[i]->
cost = 0.0001;
130 std::cout <<
" ==> " << lPos[i]->
cost << std::endl;
167 if ( max_p > feat->
nblp )
174 double discrim = 0.0;
179 for ( stop = 0; stop < feat->
nblp && feat->
lPos[stop]->
getCost() < discrim; stop++ )
182 while ( stop == 0 && discrim < feat->lPos[feat->
nblp-1]->getCost() + 2.0 );
187 for ( k = 0; k < stop; k++ )
219 px = ( lp->
x[0] + lp->
x[2] ) / 2.0;
220 py = ( lp->
y[0] + lp->
y[2] ) / 2.0;
229 pset->
getDist( px, py, &rx, &ry );
bool isBorderCrossingLine(PointSet *feat)
returns true if this label crosses the specified line
double getCost() const
get the position geographical cost
static void setCandidateCostFromPolygon(LabelPosition *lp, RTree< PointSet *, 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...
static void setPolygonCandidatesCost(int nblp, LabelPosition **lPos, int max_p, RTree< PointSet *, double, 2, double > *obstacles, double bbx[4], double bby[4])
void setCost(double newCost)
Modify candidate's cost.
static bool costGrow(void *l, void *r)
double dist_euc2d_sq(double x1, double y1, double x2, double y2)
Layer * getLayer()
return the layer that feature belongs to
static void addObstacleCostPenalty(LabelPosition *lp, PointSet *feat)
increase candidate's cost according to its collision with passed feature
void addSizePenalty(int nbp, LabelPosition **lPos, double bbx[4], double bby[4])
double unit_convert(double x, Units from, Units to, int dpi, double scale, double delta_canvas_width)
static bool polygonObstacleCallback(PointSet *feat, void *ctx)
double getLabelDistance() const
double getDistanceToPoint(double xp, double yp)
get distance from this label to a point.
void update(PointSet *pset)
Only for lines, labels along the line.
For usage in problem solving algorithm.
static int finalizeCandidatesCosts(Feats *feat, int max_p, RTree< PointSet *, double, 2, double > *obstacles, double bbx[4], double bby[4])
sort candidates by costs, skip the worse ones, evaluate polygon candidates
const char * getUID()
get the unique id of the feature
Arrangement getArrangement()
get arrangement policy
void getBoundingBox(double min[2], double max[2]) const
const char * getName()
get layer's name
void sort(double *heap, int *x, int *y, int N)
double getDist(double px, double py, double *rx, double *ry)
return the minimum distance bw this and the point (px,py)
Only for polygon, arranges candidates with respect of polygon orientation.
LabelPosition is a candidate feature label position.
PolygonCostCalculator(LabelPosition *lp)
LabelPosition * getLabel()
Data structure to compute polygon's candidates costs.
int getNumPointsInPolygon(int npol, double *xp, double *yp)
returns number of intersections with polygon (testing border and center)
static bool costShrink(void *l, void *r)