[mapserver-commits] r10127 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Thu Apr 29 10:02:32 EDT 2010


Author: assefa
Date: 2010-04-29 10:02:30 -0400 (Thu, 29 Apr 2010)
New Revision: 10127

Modified:
   trunk/mapserver/maptemplate.c
Log:
in shplabel tag processing, do not affect the original shape (#3241)

Modified: trunk/mapserver/maptemplate.c
===================================================================
--- trunk/mapserver/maptemplate.c	2010-04-28 21:56:02 UTC (rev 10126)
+++ trunk/mapserver/maptemplate.c	2010-04-29 14:02:30 UTC (rev 10127)
@@ -1439,7 +1439,7 @@
 }
 
 
-static int processShplabelTag(layerObj *layer, char **line, shapeObj *shape) 
+static int processShplabelTag(layerObj *layer, char **line, shapeObj *origshape) 
 {
     char *tag, *tagStart, *tagEnd;
     char *tagValue=NULL;
@@ -1458,6 +1458,7 @@
     int i,status;
     char number[64]; /* holds a single number in the extent */
     char numberFormat[16];
+    shapeObj *shape = NULL;
 
     if(!*line) {
     msSetError(MS_WEBERR, "Invalid line pointer.", "processShplabelTag()");
@@ -1472,13 +1473,20 @@
     if( !tagStart )
       return MS_SUCCESS;
 
-    if(!shape || shape->numlines <= 0) { /* I suppose we need to make sure the part has vertices (need shape checker?) */
+    if(!origshape || origshape->numlines <= 0) { /* I suppose we need to make sure the part has vertices (need shape checker?) */
       msSetError(MS_WEBERR, "Null or empty shape.", "processShplabelTag()");
       return(MS_FAILURE);
     }
 
+    
     while (tagStart) 
     {
+        if (shape)
+          msFreeShape(shape);
+        shape = (shapeObj *) malloc(sizeof(shapeObj));
+        msInitShape(shape);
+        msCopyShape(origshape, shape);
+
         projectionString = NULL;
         format = "$x,$y";
         tagOffset = tagStart - *line;
@@ -1504,6 +1512,8 @@
               if(strcasecmp(argValue,"true") == 0) use_label_settings = MS_TRUE;
         }
 
+        labelPos.x = -1;
+        labelPos.y = -1;
         msInitShape(&tShape);
 
         tShape.type = MS_SHAPE_LINE;
@@ -1603,8 +1613,13 @@
 
             if (shape->numlines > 0)
             {
-              if (msPolygonLabelPoint(shape, &labelPos, -1) == MS_SUCCESS)
-                labelposvalid = MS_TRUE;
+                if (msPolygonLabelPoint(shape, &labelPos, -1) == MS_SUCCESS)
+                {
+                    if (labelPos.x == -1 && labelPos.y == -1)
+                      labelposvalid = MS_FALSE;
+                    else
+                      labelposvalid = MS_TRUE;
+                }
             }
         }
         if (labelposvalid == MS_TRUE)
@@ -1767,6 +1782,8 @@
          else
            tagStart = NULL; 
     }
+    if (shape)
+      msFreeShape(shape);
 
     return(MS_SUCCESS);
 }



More information about the mapserver-commits mailing list