File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -2939,20 +2939,39 @@ namespace pal
2939
2939
//#undef _DEBUG_FULL_
2940
2940
#endif
2941
2941
2942
+ bool Problem::compareLabelArea ( pal::LabelPosition* l1, pal::LabelPosition* l2 )
2943
+ {
2944
+ return l1->getWidth () * l1->getHeight () > l2->getWidth () * l2->getHeight ();
2945
+ }
2946
+
2942
2947
std::list<LabelPosition*> * Problem::getSolution ( bool returnInactive )
2943
2948
{
2944
2949
2945
2950
int i;
2946
2951
std::list<LabelPosition*> *solList = new std::list<LabelPosition*>();
2947
2952
2948
2953
if ( nbft == 0 )
2954
+ {
2949
2955
return solList;
2956
+ }
2950
2957
2951
2958
for ( i = 0 ; i < nbft; i++ )
2959
+ {
2952
2960
if ( sol->s [i] != -1 )
2961
+ {
2953
2962
solList->push_back ( labelpositions[sol->s [i]] ); // active labels
2963
+ }
2954
2964
else if ( returnInactive )
2965
+ {
2955
2966
solList->push_back ( labelpositions[featStartId[i]] ); // unplaced label
2967
+ }
2968
+ }
2969
+
2970
+ // if features collide, order by size, so smaller ones appear on top
2971
+ if ( returnInactive )
2972
+ {
2973
+ solList->sort ( compareLabelArea );
2974
+ }
2956
2975
2957
2976
return solList;
2958
2977
}
Original file line number Diff line number Diff line change @@ -225,6 +225,8 @@ namespace pal
225
225
void init_sol_empty ();
226
226
void init_sol_falp ();
227
227
228
+ static bool compareLabelArea ( pal::LabelPosition* l1, pal::LabelPosition* l2 );
229
+
228
230
#ifdef _EXPORT_MAP_
229
231
void drawLabels ( std::ofstream &svgmap );
230
232
#endif
You can’t perform that action at this time.
0 commit comments