[mapserver-commits] r13170 - sandbox/tb-labels

svn at osgeo.org svn at osgeo.org
Thu Feb 23 14:19:18 EST 2012


Author: tbonfort
Date: 2012-02-23 11:19:17 -0800 (Thu, 23 Feb 2012)
New Revision: 13170

Modified:
   sandbox/tb-labels/mapdraw.c
   sandbox/tb-labels/maplabel.c
Log:
avoid intersecting leader lines, try horizontal and vertical leader lines last as they are less aesthetic


Modified: sandbox/tb-labels/mapdraw.c
===================================================================
--- sandbox/tb-labels/mapdraw.c	2012-02-23 19:03:13 UTC (rev 13169)
+++ sandbox/tb-labels/mapdraw.c	2012-02-23 19:19:17 UTC (rev 13170)
@@ -2444,28 +2444,37 @@
             for(i=1;i<=steps;i++) {
 
                
-                 /* test the 4 cardinal points on the ring */
 
-                 /* (points marked "0" are the ones being tested)
-                 
-                    XXX0XXX
-                    XXXXXXX
-                    XXXXXXX
-                    0XX.XX0
-                    XXXXXXX
-                    XXXXXXX
-                    XXX0XXX
- 
-                  * (x0+i*gridtep,y0), pos cr
 
-                  * (x0-i*gridstep,y0), pos cl
-                  * (x0,y0-i*gridstep), pos uc
-                  * (x0,y0+i*gridstep), pos lc
-                  */ 
-               otest(i*gridstepsc,0);
-               otest(-i*gridstepsc,0);
-               otest(0,-i*gridstepsc);
-               otest(0,i*gridstepsc);
+               /* test the intermediate points on the ring */
+
+               /* (points marked "0" are the ones being tested)
+
+                  X00X00X
+                  0XXXXX0
+                  0XXXXX0
+                  XXX.XXX
+                  0XXXXX0
+                  0XXXXX0
+                  X00X00X
+               */
+               int j;
+               for(j=1;j<i-1;j++) {
+                  /* test the right positions */
+                  otest(i*gridstepsc,j * gridstepsc);
+                  otest(i*gridstepsc,- j * gridstepsc);
+                  /* test the left positions */
+                  otest(- i*gridstepsc,j * gridstepsc);
+                  otest(- i*gridstepsc,- j * gridstepsc);
+                  /* test the top positions */
+                  otest(j*gridstepsc,- i * gridstepsc);
+                  otest(- j *gridstepsc,- i * gridstepsc);
+                  /* test the bottom positions */
+                  otest(j*gridstepsc,i * gridstepsc);
+                  otest(- j *gridstepsc,i * gridstepsc);
+               }
+               if(j<(i-1)) break;
+
                otest(i*gridstepsc,i*gridstepsc);
                otest(-i*gridstepsc,-i*gridstepsc);
                otest(i*gridstepsc,-i*gridstepsc);
@@ -2504,6 +2513,29 @@
                     (x0-i*gridstep, y0+i*gridstep), pos ll
 
                  */
+                 
+               /* test the 4 cardinal points on the ring */
+
+                 /* (points marked "0" are the ones being tested)
+                 
+                    XXX0XXX
+                    XXXXXXX
+                    XXXXXXX
+                    0XX.XX0
+                    XXXXXXX
+                    XXXXXXX
+                    XXX0XXX
+ 
+                  * (x0+i*gridtep,y0), pos cr
+
+                  * (x0-i*gridstep,y0), pos cl
+                  * (x0,y0-i*gridstep), pos uc
+                  * (x0,y0+i*gridstep), pos lc
+                  */ 
+               otest(i*gridstepsc,0);
+               otest(-i*gridstepsc,0);
+               otest(0,-i*gridstepsc);
+               otest(0,i*gridstepsc);
             }
             if(cachePtr->status) {
                shapeObj labelLeader; /* label polygon (bounding box, possibly rotated) */

Modified: sandbox/tb-labels/maplabel.c
===================================================================
--- sandbox/tb-labels/maplabel.c	2012-02-23 19:03:13 UTC (rev 13169)
+++ sandbox/tb-labels/maplabel.c	2012-02-23 19:19:17 UTC (rev 13170)
@@ -747,6 +747,13 @@
            if(msRectOverlap(cachePtr->leaderbbox, &(curCachePtr->poly->bounds))) {
               return MS_FALSE;
            }
+           if(curCachePtr->leaderline) {
+              /* check intersection of leader lines ? */
+              if(msRectOverlap(curCachePtr->leaderbbox, cachePtr->leaderbbox)) {
+                 return MS_FALSE;
+              }
+
+           }
         }
       }
     } /* i */



More information about the mapserver-commits mailing list