[mapserver-commits] r13082 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Tue Feb 7 18:41:28 EST 2012


Author: tbonfort
Date: 2012-02-07 15:41:28 -0800 (Tue, 07 Feb 2012)
New Revision: 13082

Modified:
   trunk/mapserver/mapdraw.c
   trunk/mapserver/mapprimitive.c
Log:
- fix a valgrind error when checking for maxoverlap follow angles
- don't send shapes with 0 lines further down the rendering chain (#4178)



Modified: trunk/mapserver/mapdraw.c
===================================================================
--- trunk/mapserver/mapdraw.c	2012-02-07 23:32:44 UTC (rev 13081)
+++ trunk/mapserver/mapdraw.c	2012-02-07 23:41:28 UTC (rev 13082)
@@ -2045,14 +2045,24 @@
         return(MS_SUCCESS);
       }
       msTransformShape(shape, map->extent, map->cellsize, image);
-      if(hasGeomTransform)
-        msTransformShape(&nonClippedShape, map->extent, map->cellsize, image);
+      if(shape->numlines == 0) {
+         if(hasGeomTransform)
+            msFreeShape(&nonClippedShape);   
+         return(MS_SUCCESS);
+      }
+      if(hasGeomTransform) {
+         msTransformShape(&nonClippedShape, map->extent, map->cellsize, image);
+         if(nonClippedShape.numlines == 0) {
+            msFreeShape(&nonClippedShape);   
+            return(MS_SUCCESS);
+         }
+      }
     } else {
       msOffsetShapeRelativeTo(shape, layer);
+      if(hasGeomTransform)
+         msOffsetShapeRelativeTo(&nonClippedShape, layer);
     }
     
-    if(hasGeomTransform)
-      msOffsetShapeRelativeTo(&nonClippedShape, layer);
 	
     /*RFC48: loop through the styles, and pass off to the type-specific
     function if the style has an appropriate type*/

Modified: trunk/mapserver/mapprimitive.c
===================================================================
--- trunk/mapserver/mapprimitive.c	2012-02-07 23:32:44 UTC (rev 13081)
+++ trunk/mapserver/mapprimitive.c	2012-02-07 23:41:28 UTC (rev 13082)
@@ -927,6 +927,9 @@
         ok = 1;
     }
     if(!ok) {
+       for(i=0;i<shape->numlines;i++) {
+          free(shape->line[i].point);
+       }
        shape->numlines = 0 ;
     }
 }
@@ -1751,12 +1754,13 @@
   segment_index = max_line_index = 0;
   total_length = max_line_length = 0.0;
 
+
   labelpaths = (labelPathObj **) msSmallMalloc(sizeof(labelPathObj *) * labelpaths_size);
   (*regular_lines) = (int *) msSmallMalloc(sizeof(int) * regular_lines_size);
 
   msPolylineComputeLineSegments(p, &segment_lengths, &line_lengths, &max_line_index, &max_line_length, &segment_index, &total_length);
  
-  if (label->repeatdistance > 0)
+  if(label->repeatdistance > 0)
     for(i=0; i<p->numlines; i++) {
       msPolylineLabelPathLineString(map,img, p,min_length, fontset, string, label, scalefactor, i, segment_lengths, line_lengths[i], total_length, 
                                     &labelpaths_index, &labelpaths_size, &labelpaths, regular_lines, &regular_lines_index, &regular_lines_size);
@@ -1764,7 +1768,7 @@
   else
     msPolylineLabelPathLineString(map, img, p,min_length, fontset, string, label, scalefactor, max_line_index, segment_lengths, line_lengths[max_line_index], total_length, 
                                   &labelpaths_index, &labelpaths_size, &labelpaths, regular_lines, &regular_lines_index, &regular_lines_size);
-
+  
   /* freeing memory: allocated by msPolylineComputeLineSegments */
   if ( segment_lengths ) {
     for ( i = 0; i < p->numlines; i++ )
@@ -2084,13 +2088,15 @@
 
             theta = -atan2(dy,dx);
 
-            /* If the difference between the last char angle and the current one 
-              is greater than the MAXOVERLAPANGLE value (set at 80% of 180deg by default)
-              , bail the label */
-            anglediff = fabs(theta - labelpath->angles[k-2]);
-            anglediff = MS_MIN(anglediff, MS_2PI - anglediff);
-            if ( maxoverlapangle > 0 && (k > 2 && anglediff > maxoverlapangle) ) {
-                goto LABEL_FAILURE;
+            if ( maxoverlapangle > 0 && k > 1) {
+               /* If the difference between the last char angle and the current one 
+                  is greater than the MAXOVERLAPANGLE value (set at 80% of 180deg by default)
+                  , bail the label */
+               anglediff = fabs(theta - labelpath->angles[k-2]);
+               anglediff = MS_MIN(anglediff, MS_2PI - anglediff);
+               if(anglediff > maxoverlapangle ) {
+                  goto LABEL_FAILURE;
+               }
             }
       
             /* msDebug("s: %c (x,y): (%0.2f,%0.2f) t: %0.2f\n", string[k-1], labelpath->path.point[k-1].x, labelpath->path.point[k-1].y, theta); */



More information about the mapserver-commits mailing list