Skip to content

Commit

Permalink
pal: fixed calculation of cost for polygon candidates when using feat…
Browse files Browse the repository at this point in the history
…ures with lat/lon coordinates.

(distances smaller than 0.1 units were considered as numeric errors)


git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11046 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Jul 11, 2009
1 parent 166b183 commit bd52f90
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 13 additions & 7 deletions src/core/pal/costcalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,6 @@ namespace pal

px = ( lp->x[0] + lp->x[2] ) / 2.0;
py = ( lp->y[0] + lp->y[2] ) / 2.0;
dLp[0] = lp->w / 2;
dLp[1] = lp->h / 2;
dLp[2] = dLp[0] / cos( M_PI / 4 );

/*
3 2 1
Expand Down Expand Up @@ -323,10 +320,18 @@ namespace pal

for ( i = 0;i < 8;i++ )
{
dist[i] -= (( i % 2 ) ? dLp[2] : (( i == 0 || i == 4 ) ? dLp[0] : dLp[1] ) );
if ( !ok[i] || dist[i] < 0.1 )
/*
if ( i == 0 || i == 4 ) // horizontal directions
dist[i] -= lp->w / 2;
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 );
*/

if ( !ok[i] || dist[i] < EPSILON )
{
dist[i] = 0.1;
dist[i] = EPSILON;
}
}

Expand All @@ -337,7 +342,8 @@ namespace pal
c = min( dist[2], dist[6] );
d = min( dist[3], dist[7] );

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

Expand Down
2 changes: 0 additions & 2 deletions src/core/pal/costcalculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ namespace pal
double rpy[8];
bool ok[8];

double dLp[3];

void updatePoint( PointSet *pset );
double updateLinePoly( PointSet *pset );
public:
Expand Down

0 comments on commit bd52f90

Please sign in to comment.