Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
pal: fixed calculation of distance from point to label. This fixes th…
…e problem with points not acting as obstacles.

git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11047 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Jul 12, 2009
1 parent bd52f90 commit 6d00c9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/core/pal/labelposition.cpp
Expand Up @@ -403,25 +403,24 @@ namespace pal
my[i] = ( y[i] + y[j] ) / 2.0;
}


if ( vabs( cross_product( mx[0], my[0], my[2], my[2], xp, yp ) / h ) < w / 2 )
if ( vabs( cross_product( mx[0], my[0], mx[2], my[2], xp, yp ) / h ) < w / 2 )
{
dist = cross_product( x[0], y[0], x[1], y[1], xp, yp ) / w;
dist = cross_product( x[1], y[1], x[0], y[0], xp, yp ) / w;
if ( vabs( dist ) < vabs( dist_min ) )
dist_min = dist;

dist = cross_product( x[2], y[2], x[3], y[3], xp, yp ) / w;
dist = cross_product( x[3], y[3], x[2], y[2], xp, yp ) / w;
if ( vabs( dist ) < vabs( dist_min ) )
dist_min = dist;
}

if ( vabs( cross_product( mx[1], my[1], my[3], my[3], xp, yp ) / w ) < h / 2 )
if ( vabs( cross_product( mx[1], my[1], mx[3], my[3], xp, yp ) / w ) < h / 2 )
{
dist = cross_product( x[1], y[1], x[2], y[2], xp, yp ) / h;
dist = cross_product( x[2], y[2], x[1], y[1], xp, yp ) / h;
if ( vabs( dist ) < vabs( dist_min ) )
dist_min = dist;

dist = cross_product( x[3], y[3], x[0], y[0], xp, yp ) / h;
dist = cross_product( x[0], y[0], x[3], y[3], xp, yp ) / h;
if ( vabs( dist ) < vabs( dist_min ) )
dist_min = dist;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/labelposition.h
Expand Up @@ -220,7 +220,7 @@ namespace pal
// for polygon cost calculation
static bool polygonObstacleCallback( PointSet *feat, void *ctx );

/** get distance from this label to a point */
/** get distance from this label to a point. If point lies inside, returns negative number. */
double getDistanceToPoint( double xp, double yp );

/** returns true if this label crosses the specified line */
Expand Down

0 comments on commit 6d00c9a

Please sign in to comment.