Skip to content

Commit b77d606

Browse files
wonder-skmach0
authored andcommittedDec 19, 2011
Fix label orientation with line dependent position (#3643)
1 parent 4a3f213 commit b77d606

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed
 

‎src/core/pal/feature.cpp

+13-9
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ namespace pal
483483
unsigned long flags = f->layer->getArrangementFlags();
484484
if ( flags == 0 )
485485
flags = FLAG_ON_LINE; // default flag
486-
bool reversed = false;
487486

488487
//LinkedList<PointSet*> *shapes_final;
489488

@@ -594,15 +593,20 @@ namespace pal
594593
#endif
595594
if ( f->layer->arrangement == P_LINE )
596595
{
597-
//if ( flags & FLAG_MAP_ORIENTATION ) // see bug #3643
598-
reversed = ( alpha > M_PI / 2 || alpha <= -M_PI / 2 );
599-
600-
if (( !reversed && ( flags & FLAG_ABOVE_LINE ) ) || ( reversed && ( flags & FLAG_BELOW_LINE ) ) )
601-
positions->push_back( new LabelPosition( i, bx + cos( beta ) *distlabel , by + sin( beta ) *distlabel, xrm, yrm, alpha, cost, this, reversed ) ); // Line
602-
if (( !reversed && ( flags & FLAG_BELOW_LINE ) ) || ( reversed && ( flags & FLAG_ABOVE_LINE ) ) )
603-
positions->push_back( new LabelPosition( i, bx - cos( beta ) *( distlabel + yrm ) , by - sin( beta ) *( distlabel + yrm ), xrm, yrm, alpha, cost, this, reversed ) ); // Line
596+
// find out whether the line direction for this candidate is from right to left
597+
bool isRightToLeft = ( alpha > M_PI / 2 || alpha <= -M_PI / 2 );
598+
// meaning of above/below may be reversed if using line position dependent orientation
599+
// and the line has right-to-left direction
600+
bool reversed = (( flags & FLAG_MAP_ORIENTATION ) ? isRightToLeft : false );
601+
bool aboveLine = ( !reversed && ( flags & FLAG_ABOVE_LINE ) ) || ( reversed && ( flags & FLAG_BELOW_LINE ) );
602+
bool belowLine = ( !reversed && ( flags & FLAG_BELOW_LINE ) ) || ( reversed && ( flags & FLAG_ABOVE_LINE ) );
603+
604+
if ( aboveLine )
605+
positions->push_back( new LabelPosition( i, bx + cos( beta ) *distlabel , by + sin( beta ) *distlabel, xrm, yrm, alpha, cost, this, isRightToLeft ) ); // Line
606+
if ( belowLine )
607+
positions->push_back( new LabelPosition( i, bx - cos( beta ) *( distlabel + yrm ) , by - sin( beta ) *( distlabel + yrm ), xrm, yrm, alpha, cost, this, isRightToLeft ) ); // Line
604608
if ( flags & FLAG_ON_LINE )
605-
positions->push_back( new LabelPosition( i, bx - yrm*cos( beta ) / 2, by - yrm*sin( beta ) / 2, xrm, yrm, alpha, cost, this, reversed ) ); // Line
609+
positions->push_back( new LabelPosition( i, bx - yrm*cos( beta ) / 2, by - yrm*sin( beta ) / 2, xrm, yrm, alpha, cost, this, isRightToLeft ) ); // Line
606610
}
607611
else if ( f->layer->arrangement == P_HORIZ )
608612
{

0 commit comments

Comments
 (0)
Please sign in to comment.