[mapserver-commits] r13006 - sandbox/sdlime/rfc-77

svn at osgeo.org svn at osgeo.org
Sat Jan 21 17:14:35 EST 2012


Author: sdlime
Date: 2012-01-21 14:14:35 -0800 (Sat, 21 Jan 2012)
New Revision: 13006

Modified:
   sandbox/sdlime/rfc-77/mapdraw.c
Log:
Deal with label polygons more efficiently in POSITION AUTO use case.

Modified: sandbox/sdlime/rfc-77/mapdraw.c
===================================================================
--- sandbox/sdlime/rfc-77/mapdraw.c	2012-01-21 20:11:29 UTC (rev 13005)
+++ sandbox/sdlime/rfc-77/mapdraw.c	2012-01-21 22:14:35 UTC (rev 13006)
@@ -2351,7 +2351,6 @@
             msDrawTextLine(image, cachePtr->text, labelPtr, cachePtr->labelpath, &(map->fontset), layerPtr->scalefactor); /* Draw the curved label */
 
           } else { /* point-based label */
-            int labelStatus; /* per label status tracking */
             int drawLabelText=MS_TRUE; // unused
             shapeObj *poly=NULL; /* hold label polygon for one label, cachePtr->poly holds label polygon for the whole group */
 
@@ -2478,18 +2477,17 @@
                   npositions = 8;
                 }
    
-                for(i=0; i<npositions; i++) {
-                  msFreeShape(poly);                  
-   
+                if(label_marker_width > 0 && label_marker_height > 0)
+                  msRectToPolygon(label_marker_rect, poly); /* save marker bounding polygon */
+
+                for(i=0; i<npositions; i++) {   
                   labelPtr->annopoint = get_metrics(&(cachePtr->point), positions[i], r, (marker_offset_x + label_offset_x), (marker_offset_y + label_offset_y), labelPtr->angle, label_buffer, poly);
-                  // if(label_marker_width > 0 && label_marker_height > 0)
-                  //   msRectToPolygon(label_marker_rect, poly); /* save marker bounding polygon (TODO: could do conversion once) */
 
                   /* first, compare poly against cachePtr->poly (group poly) if not the first label in the group */
                   if((ll != 0) && intersectLabelPolygons(poly, cachePtr->poly) == MS_TRUE) continue; /* next position */
 
                   /* second, add poly to cachePtr->poly */
-                  msCopyShape(poly, cachePtr->poly);
+                  msCopyShape(poly, cachePtr->poly); // RFC 77 - HMMM, this isn't right (need to save existing cache->poly value in case there's a collision)...
 
                   /* finally, compare against image bounds, rendered labels and markers (sets cachePtr->status) */
                   msTestLabelCacheCollisions(&(map->labelcache), labelPtr, image->width, image->height, (map_edge_buffer-label_buffer), cachePtr, priority, l, label_mindistance, (r.maxx-r.minx));
@@ -2499,6 +2497,11 @@
                     if(drawLabelPoly)
                       get_metrics_line(&(cachePtr->point), positions[i], r, (marker_offset_x + label_offset_x), (marker_offset_y + label_offset_y), labelPtr->angle, 1, labelPoly.line);
                     break; /* ...out of position loop */
+                  } else { 
+                    /* reset some things */
+                    msShapeDeleteLine(cachePtr->poly, cachePtr->poly->numlines-1);
+                    if(poly->numlines == 2) msShapeDeleteLine(cachePtr->poly, cachePtr->poly->numlines-1); /* marker too */
+                    msShapeDeleteLine(poly, poly->numlines-1);
                   }
                 } /* next position */
 
@@ -2525,7 +2528,7 @@
                 //   msRectToPolygon(label_marker_rect, poly); /* save marker bounding polygon, part of overlap tests */
 
                 fprintf(stderr, "    before: %d, %d, %d\n", ll, cachePtr->numlabels-1, cachePtr->status);
-                if(labelPtr->force) {
+                if(labelPtr->force == MS_TRUE) {
                   msCopyShape(poly, cachePtr->poly);
                   cachePtr->status = MS_TRUE;
                 } else {
@@ -2537,7 +2540,6 @@
                   msTestLabelCacheCollisions(&(map->labelcache), labelPtr, image->width, image->height, (map_edge_buffer-label_buffer), cachePtr, priority, l, label_mindistance, (r.maxx-r.minx));
                 }
               } /* end else */
-
               fprintf(stderr, "    after: %d, %d, %d\n", ll, cachePtr->numlabels-1, cachePtr->status);
 
               if(!cachePtr->status)



More information about the mapserver-commits mailing list