Skip to content
Permalink
Browse files

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
wonder committed Jul 12, 2009
1 parent bd52f90 commit 6d00c9a197950dcd4fb7b6dc9d8b0f2359466ec1
Showing with 7 additions and 8 deletions.
  1. +6 −7 src/core/pal/labelposition.cpp
  2. +1 −1 src/core/pal/labelposition.h
@@ -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;
}
@@ -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 */

0 comments on commit 6d00c9a

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