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

svn at osgeo.org svn at osgeo.org
Mon Feb 6 09:35:34 EST 2012


Author: sdlime
Date: 2012-02-06 06:35:33 -0800 (Mon, 06 Feb 2012)
New Revision: 13051

Modified:
   sandbox/sdlime/rfc-77/mapfile.c
   sandbox/sdlime/rfc-77/maplayer.c
   sandbox/sdlime/rfc-77/maputil.c
Log:
Label TEXT attribute is working...

Modified: sandbox/sdlime/rfc-77/mapfile.c
===================================================================
--- sandbox/sdlime/rfc-77/mapfile.c	2012-02-06 14:20:13 UTC (rev 13050)
+++ sandbox/sdlime/rfc-77/mapfile.c	2012-02-06 14:35:33 UTC (rev 13051)
@@ -68,6 +68,7 @@
 static int loadStyle(styleObj *style);
 static void writeStyle(FILE* stream, int indent, styleObj *style);
 static int resolveSymbolNames(mapObj *map);
+static int loadExpression(expressionObj *exp);
 static void writeExpression(FILE *stream, int indent, const char *name, expressionObj *exp);
 
 /************************************************************************/
@@ -1683,7 +1684,7 @@
     msFree(label->bindings[i].item);
 
   freeExpression(&(label->expression));
-  freeExpression(&(label->text)); // RFC TODO: writeLabel()
+  freeExpression(&(label->text));
 
   /* free book keeping vars associated with the label cache */
   msFree(label->annotext);
@@ -1903,6 +1904,17 @@
         label->styles[label->numstyles]->_geomtransform.type = MS_GEOMTRANSFORM_LABELPOINT; /* set a default, a marker? */
       label->numstyles++;
       break;
+    case(TEXT):
+      if(loadExpression(&(label->text)) == -1) return(-1); /* loadExpression() cleans up previously allocated expression */
+      if(msyysource == MS_URL_TOKENS) {
+        msSetError(MS_MISCERR, "URL-based TEXT configuration not supported for labels." , "loadLabel()");
+        return(-1);
+      }
+      if((label->text.type != MS_STRING) && (label->text.type != MS_EXPRESSION)) {
+	msSetError(MS_MISCERR, "Text expressions support constant or tagged replacement strings." , "loadLabel()");
+	return(-1);
+      }
+      break;
     case(TYPE):
       if((label->type = getSymbol(2, MS_TRUETYPE,MS_BITMAP)) == -1) return(-1);
       break;    

Modified: sandbox/sdlime/rfc-77/maplayer.c
===================================================================
--- sandbox/sdlime/rfc-77/maplayer.c	2012-02-06 14:20:13 UTC (rev 13050)
+++ sandbox/sdlime/rfc-77/maplayer.c	2012-02-06 14:35:33 UTC (rev 13051)
@@ -520,6 +520,10 @@
       }
 
       /* RFC 77: will need to support expression and text attributes here... */
+      if(layer->class[i]->labels[l]->expression.type == MS_EXPRESSION)
+        nt += msCountChars(layer->class[i]->expression.string, '[');
+      if(layer->class[i]->labels[l]->text.type == MS_EXPRESSION || (layer->class[i]->labels[l]->text.string && strchr(layer->class[i]->labels[l]->text.string,'[') != NULL && strchr(layer->class[i]->labels[l]->text.string,']') != NULL))
+        nt += msCountChars(layer->class[i]->labels[l]->text.string, '[');
     }
 
     if(layer->class[i]->text.type == MS_EXPRESSION || (layer->class[i]->text.string && strchr(layer->class[i]->text.string,'[') != NULL && strchr(layer->class[i]->text.string,']') != NULL))
@@ -578,6 +582,13 @@
         }
         for(k=0; k<MS_LABEL_BINDING_LENGTH; k++)
           if(layer->class[i]->labels[l]->bindings[k].item) layer->class[i]->labels[l]->bindings[k].index = string2list(layer->items, &(layer->numitems), layer->class[i]->labels[l]->bindings[k].item);
+
+        /* label expression */
+        if(layer->class[i]->labels[l]->expression.type == MS_EXPRESSION)  msTokenizeExpression(&(layer->class[i]->labels[l]->expression), layer->items, &(layer->numitems));
+
+        /* label text */
+        if(layer->class[i]->labels[l]->text.type == MS_EXPRESSION || (layer->class[i]->labels[l]->text.string && strchr(layer->class[i]->labels[l]->text.string,'[') != NULL && strchr(layer->class[i]->labels[l]->text.string,']') != NULL))
+          msTokenizeExpression(&(layer->class[i]->labels[l]->text), layer->items, &(layer->numitems));
       }
 
       /* class text */

Modified: sandbox/sdlime/rfc-77/maputil.c
===================================================================
--- sandbox/sdlime/rfc-77/maputil.c	2012-02-06 14:20:13 UTC (rev 13050)
+++ sandbox/sdlime/rfc-77/maputil.c	2012-02-06 14:35:33 UTC (rev 13051)
@@ -644,15 +644,16 @@
   i = shape->classindex;
   for(j=0; j<layer->class[i]->numlabels; j++) {
 
+    layer->class[i]->labels[j]->status = MS_ON;
     /* RFC 77 TODO: will evaluate label scale limits here... */
     /* RFC 77 TODO: will evaluate label expressions here... */
 
     msFree(layer->class[i]->labels[j]->annotext);
     layer->class[i]->labels[j]->annotext = NULL;
 
-    if(layer->class[i]->labels[j]->text.string) { /* RFC 77 TODO: will check for a label text value first, then class text and finally try labelitem */      
+    if(layer->class[i]->labels[j]->text.string) {    
       layer->class[i]->labels[j]->annotext = evalTextExpression(&(layer->class[i]->labels[j]->text), shape);
-    } if(layer->class[i]->text.string) {
+    } else if(layer->class[i]->text.string) {
       layer->class[i]->labels[j]->annotext = evalTextExpression(&(layer->class[i]->text), shape);
     } else {
       if (shape->values && layer->labelitemindex >= 0)



More information about the mapserver-commits mailing list