Skip to content
Permalink
Browse files

pal: fixed calculation of cost for polygon candidates when using feat…

…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
wonder committed Jul 11, 2009
1 parent 166b183 commit bd52f909aab6214ca375c1049761e25cbc7b5531
Showing with 13 additions and 9 deletions.
  1. +13 −7 src/core/pal/costcalculator.cpp
  2. +0 −2 src/core/pal/costcalculator.h
@@ -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
@@ -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;
}
}

@@ -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 );
}

@@ -38,8 +38,6 @@ namespace pal
double rpy[8];
bool ok[8];

double dLp[3];

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

0 comments on commit bd52f90

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