Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix #6170
  • Loading branch information
jef-n committed Aug 8, 2012
1 parent e552707 commit 928da6e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
34 changes: 18 additions & 16 deletions src/core/pal/costcalculator.cpp 100644 → 100755
Expand Up @@ -37,10 +37,12 @@ namespace pal
int n = 0;
double dist;
double distlabel = lp->feature->getLabelDistance();
/*unit_convert( double( lp->feature->distlabel ),
pal::PIXEL,
pal->map_unit,
pal->dpi, scale, 1 );*/
#if 0
unit_convert( double( lp->feature->distlabel ),
pal::PIXEL,
pal->map_unit,
pal->dpi, scale, 1 );
#endif

switch ( feat->getGeosType() )
{
Expand Down Expand Up @@ -230,7 +232,7 @@ namespace pal
*/

double alpha = lp->getAlpha();
for ( i = 0; i < 8; i++, alpha += M_PI / 4 )
for ( i = 0; i < 8; i++, alpha += M_PI_4 )
{
dist[i] = DBL_MAX;
ok[i] = false;
Expand Down Expand Up @@ -261,14 +263,12 @@ namespace pal
{
double beta = atan2( pset->y[0] - py, pset->x[0] - px ) - lp->getAlpha();

while ( beta < 0 )
while ( beta < 0.0 )
{
beta += 2 * M_PI;
}

double a45 = M_PI / 4;

int i = ( int )( beta / a45 );
int i = ( int ) floor( beta / M_PI_4 ) % 8;

for ( int j = 0; j < 2; j++, i = ( i + 1 ) % 8 )
{
Expand All @@ -287,7 +287,7 @@ namespace pal
}
else
{
std::cout << "this shouldn't occurs !!!" << std::endl;
std::cout << "this shouldn't occur!!!" << std::endl;
}
}
}
Expand Down Expand Up @@ -334,14 +334,14 @@ namespace pal

for ( i = 0; i < 8; i++ )
{
/*
#if 0
if ( i == 0 || i == 4 ) // horizontal directions
dist[i] -= lp->w / 2;
else if (i == 2 || i == 6 ) // vertical directions
else if ( i == 2 || i == 6 ) // vertical directions
dist[i] -= lp->h / 2;
else // other directions
dist[i] -= ( lp->w / 2 ) / cos( M_PI / 4 );
*/
dist[i] -= ( lp->w / 2 ) / cos( M_PI_4 );
#endif

if ( !ok[i] || dist[i] < EPSILON )
{
Expand All @@ -356,8 +356,10 @@ namespace pal
c = min( dist[2], dist[6] );
d = min( dist[3], dist[7] );

//if (a!=EPSILON || b!=EPSILON || c!=EPSILON || d!=EPSILON)
// std::cout << "res " << (a*b*c*d) << " " << a << " " << b << " " << c << " " << d << std::endl;
#if 0
if ( a != EPSILON || b != EPSILON || c != EPSILON || d != EPSILON )
std::cout << "res " << ( a*b*c*d ) << " " << a << " " << b << " " << c << " " << d << std::endl;
#endif
return ( a*b*c*d );
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/feature.cpp
Expand Up @@ -1053,7 +1053,7 @@ namespace pal

if (( box->length * box->width ) > ( xmax - xmin ) *( ymax - ymin ) *5 )
{
std::cout << "Very Large BBOX (should never occurs : bug-report please)" << std::endl;
std::cout << "Very Large BBOX (should never occur : bug-report please)" << std::endl;
std::cout << " Box size: " << box->length << "/" << box->width << std::endl;
std::cout << " Alpha: " << alpha << " " << alpha * 180 / M_PI << std::endl;
std::cout << " Dx;Dy: " << dx << " " << dy << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions src/core/pal/pal.h
Expand Up @@ -302,7 +302,7 @@ namespace pal
* @param scale map scale is 1:scale
* @param bbox map extent
* @param stats A PalStat object (can be NULL)
* @param displayAll if true, all feature will be labelled evan though overlaps occurs
* @param displayAll if true, all feature will be labelled even though overlaps occur
*
* @return A list of label to display on map
*/
Expand All @@ -320,7 +320,7 @@ namespace pal
* @param scale map scale is '1:scale'
* @param bbox map extent
* @param stat will be filled with labelling process statistics, can be NULL
* @param displayAll if true, all feature will be labelled evan though overlaps occurs
* @param displayAll if true, all feature will be labelled even though overlaps occur
*
* @todo UnknownLayer will be ignored ? should throw exception or not ???
*
Expand Down

0 comments on commit 928da6e

Please sign in to comment.