Skip to content
Permalink
Browse files

Fix label orientation with line dependent position (#3643)

  • Loading branch information
wonder-sk committed Nov 8, 2011
1 parent 641bd67 commit c37b63a83f9d72223f375a490c6555f0c9c2a015
Showing with 13 additions and 9 deletions.
  1. +13 −9 src/core/pal/feature.cpp
@@ -486,7 +486,6 @@ namespace pal
unsigned long flags = f->layer->getArrangementFlags();
if ( flags == 0 )
flags = FLAG_ON_LINE; // default flag
bool reversed = false;

//LinkedList<PointSet*> *shapes_final;

@@ -597,15 +596,20 @@ namespace pal
#endif
if ( f->layer->arrangement == P_LINE )
{
//if ( flags & FLAG_MAP_ORIENTATION ) // see bug #3643
reversed = ( alpha > M_PI / 2 || alpha <= -M_PI / 2 );

if (( !reversed && ( flags & FLAG_ABOVE_LINE ) ) || ( reversed && ( flags & FLAG_BELOW_LINE ) ) )
positions->push_back( new LabelPosition( i, bx + cos( beta ) *distlabel , by + sin( beta ) *distlabel, xrm, yrm, alpha, cost, this, reversed ) ); // Line
if (( !reversed && ( flags & FLAG_BELOW_LINE ) ) || ( reversed && ( flags & FLAG_ABOVE_LINE ) ) )
positions->push_back( new LabelPosition( i, bx - cos( beta ) *( distlabel + yrm ) , by - sin( beta ) *( distlabel + yrm ), xrm, yrm, alpha, cost, this, reversed ) ); // Line
// find out whether the line direction for this candidate is from right to left
bool isRightToLeft = ( alpha > M_PI / 2 || alpha <= -M_PI / 2 );
// meaning of above/below may be reversed if using line position dependent orientation
// and the line has right-to-left direction
bool reversed = (( flags & FLAG_MAP_ORIENTATION ) ? isRightToLeft : false );
bool aboveLine = ( !reversed && ( flags & FLAG_ABOVE_LINE ) ) || ( reversed && ( flags & FLAG_BELOW_LINE ) );
bool belowLine = ( !reversed && ( flags & FLAG_BELOW_LINE ) ) || ( reversed && ( flags & FLAG_ABOVE_LINE ) );

if ( aboveLine )
positions->push_back( new LabelPosition( i, bx + cos( beta ) *distlabel , by + sin( beta ) *distlabel, xrm, yrm, alpha, cost, this, isRightToLeft ) ); // Line
if ( belowLine )
positions->push_back( new LabelPosition( i, bx - cos( beta ) *( distlabel + yrm ) , by - sin( beta ) *( distlabel + yrm ), xrm, yrm, alpha, cost, this, isRightToLeft ) ); // Line
if ( flags & FLAG_ON_LINE )
positions->push_back( new LabelPosition( i, bx - yrm*cos( beta ) / 2, by - yrm*sin( beta ) / 2, xrm, yrm, alpha, cost, this, reversed ) ); // Line
positions->push_back( new LabelPosition( i, bx - yrm*cos( beta ) / 2, by - yrm*sin( beta ) / 2, xrm, yrm, alpha, cost, this, isRightToLeft ) ); // Line
}
else if ( f->layer->arrangement == P_HORIZ )
{

0 comments on commit c37b63a

Please sign in to comment.
You can’t perform that action at this time.