Fix placement of curved labels when there is just one character

This commit is contained in:
Martin Dobias 2012-06-09 16:00:18 +02:00
parent ee2f1bdbaf
commit 12ef68e834
3 changed files with 6 additions and 8 deletions

View File

@ -159,7 +159,6 @@ namespace pal
delete pCost;
}
int CostCalculator::finalizeCandidatesCosts( Feats* feat, int max_p, RTree <PointSet*, double, 2, double> *obstacles, double bbx[4], double bby[4] )
{
// If candidates list is smaller than expected
@ -191,7 +190,7 @@ namespace pal
max_p = stop;
#ifdef _DEBUG_FULL_
std::cout << "Nblabel kept for feat " << feat->feature->uid << "/" << feat->feature->layer->name << ": " << max_p << "/" << feat->nblp << std::endl;
std::cout << "Nblabel kept for feat " << feat->feature->getUID() << "/" << feat->feature->getLayer()->getName() << ": " << max_p << "/" << feat->nblp << std::endl;
#endif
// Sets costs for candidates of polygon

View File

@ -887,7 +887,6 @@ namespace pal
flags = FLAG_ON_LINE; // default flag
// generate curved labels
std::cerr << "------" << std::endl;
for ( int i = 0; i*delta < total_distance; i++ )
{
LabelPosition* slp = curvedPlacementAtOffset( mapShape, path_distances, 0, 1, i * delta );
@ -914,7 +913,7 @@ namespace pal
tmp = tmp->getNextPart();
}
double angle_diff_avg = angle_diff / ( f->labelInfo->char_num - 1 ); // <0, pi> but pi/8 is much already
double angle_diff_avg = f->labelInfo->char_num > 1 ? (angle_diff / ( f->labelInfo->char_num - 1 )) : 0; // <0, pi> but pi/8 is much already
double cost = angle_diff_avg / 100; // <0, 0.031 > but usually <0, 0.003 >
if ( cost < 0.0001 ) cost = 0.0001;

View File

@ -231,7 +231,7 @@ namespace pal
#ifdef _DEBUG_FULL_
std::cout << "extract feat : " << ft_ptr->layer->name << "/" << ft_ptr->uid << std::endl;
std::cout << "extract feat : " << ft_ptr->getLayer()->getName() << "/" << ft_ptr->getUID() << std::endl;
#endif
// all feature which are obstacle will be inserted into obstacles
@ -513,7 +513,7 @@ namespace pal
{
feat = fFeats->pop_front();
#ifdef _DEBUG_FULL_
std::cout << "Feature:" << feat->feature->layer->name << "/" << feat->feature->uid << std::endl;
std::cout << "Feature:" << feat->feature->getLayer()->getName() << "/" << feat->feature->getUID() << " candidates " << feat->nblp << std::endl;
#endif
prob->featStartId[i] = idlp;
prob->inactiveCost[i] = pow( 2, 10 - 10 * feat->priority );
@ -535,7 +535,7 @@ namespace pal
max_p = CostCalculator::finalizeCandidatesCosts( feat, max_p, obstacles, bbx, bby );
#ifdef _DEBUG_FULL_
std::cout << "All Cost are setted" << std::endl;
std::cout << "All costs are set" << std::endl;
#endif
// only keep the 'max_p' best candidates
for ( j = max_p; j < feat->nblp; j++ )
@ -597,7 +597,7 @@ namespace pal
nbOverlaps += lp->getNumOverlaps();
#ifdef _DEBUG_FULL_
std::cout << "Nb overlap for " << idlp << "/" << prob->nblp - 1 << " : " << lp->nbOverlap << std::endl;
std::cout << "Nb overlap for " << idlp << "/" << prob->nblp - 1 << " : " << lp->getNumOverlaps() << std::endl;
#endif
}
j++;