[QGIS Commit] r11047 - branches/symbology-ng-branch/src/core/pal

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Jul 11 20:13:11 EDT 2009


Author: wonder
Date: 2009-07-11 20:13:10 -0400 (Sat, 11 Jul 2009)
New Revision: 11047

Modified:
   branches/symbology-ng-branch/src/core/pal/labelposition.cpp
   branches/symbology-ng-branch/src/core/pal/labelposition.h
Log:
pal: fixed calculation of distance from point to label. This fixes the problem with points not acting as obstacles.


Modified: branches/symbology-ng-branch/src/core/pal/labelposition.cpp
===================================================================
--- branches/symbology-ng-branch/src/core/pal/labelposition.cpp	2009-07-11 22:10:41 UTC (rev 11046)
+++ branches/symbology-ng-branch/src/core/pal/labelposition.cpp	2009-07-12 00:13:10 UTC (rev 11047)
@@ -403,25 +403,24 @@
       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;
     }

Modified: branches/symbology-ng-branch/src/core/pal/labelposition.h
===================================================================
--- branches/symbology-ng-branch/src/core/pal/labelposition.h	2009-07-11 22:10:41 UTC (rev 11046)
+++ branches/symbology-ng-branch/src/core/pal/labelposition.h	2009-07-12 00:13:10 UTC (rev 11047)
@@ -220,7 +220,7 @@
       // 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 */



More information about the QGIS-commit mailing list