From 12ef68e834becc3cd33da333c5647e0f82eef983 Mon Sep 17 00:00:00 2001 From: Martin Dobias Date: Sat, 9 Jun 2012 16:00:18 +0200 Subject: [PATCH] Fix placement of curved labels when there is just one character --- src/core/pal/costcalculator.cpp | 3 +-- src/core/pal/feature.cpp | 3 +-- src/core/pal/pal.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/core/pal/costcalculator.cpp b/src/core/pal/costcalculator.cpp index fb3e2e03441b..e02d472788d0 100644 --- a/src/core/pal/costcalculator.cpp +++ b/src/core/pal/costcalculator.cpp @@ -159,7 +159,6 @@ namespace pal delete pCost; } - int CostCalculator::finalizeCandidatesCosts( Feats* feat, int max_p, RTree *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 diff --git a/src/core/pal/feature.cpp b/src/core/pal/feature.cpp index fe0529429ea4..547f203b12ae 100644 --- a/src/core/pal/feature.cpp +++ b/src/core/pal/feature.cpp @@ -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; diff --git a/src/core/pal/pal.cpp b/src/core/pal/pal.cpp index d95e5f6593a0..153f3966baf7 100644 --- a/src/core/pal/pal.cpp +++ b/src/core/pal/pal.cpp @@ -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++;