Skip to content

Commit

Permalink
Fix placement of curved labels when there is just one character
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Jun 9, 2012
1 parent ee2f1bd commit 12ef68e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/core/pal/costcalculator.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/core/pal/feature.cpp
Expand Up @@ -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 );
Expand All @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions src/core/pal/pal.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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 );
Expand All @@ -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++ )
Expand Down Expand Up @@ -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++;
Expand Down

0 comments on commit 12ef68e

Please sign in to comment.