[mapserver-commits] r11063 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Fri Mar 4 00:40:14 EST 2011


Author: sdlime
Date: 2011-03-03 21:40:14 -0800 (Thu, 03 Mar 2011)
New Revision: 11063

Modified:
   trunk/mapserver/mapfile.c
   trunk/mapserver/mapserver.h
   trunk/mapserver/maputil.c
Log:
Added label positon binding. (#3612)

Modified: trunk/mapserver/mapfile.c
===================================================================
--- trunk/mapserver/mapfile.c	2011-03-03 23:36:23 UTC (rev 11062)
+++ trunk/mapserver/mapfile.c	2011-03-04 05:40:14 UTC (rev 11063)
@@ -1747,8 +1747,14 @@
       if((label->partials = getSymbol(2, MS_TRUE,MS_FALSE)) == -1) return(-1);
       break;
     case(POSITION):
-      if((label->position = getSymbol(10, MS_UL,MS_UC,MS_UR,MS_CL,MS_CC,MS_CR,MS_LL,MS_LC,MS_LR,MS_AUTO)) == -1) 
-	return(-1);
+      if((label->position = getSymbol(11, MS_UL,MS_UC,MS_UR,MS_CL,MS_CC,MS_CR,MS_LL,MS_LC,MS_LR,MS_AUTO,MS_BINDING)) == -1)
+        return(-1);
+      if(label->position == MS_BINDING) {
+        if(label->bindings[MS_LABEL_BINDING_POSITION].item != NULL)
+	  msFree(label->bindings[MS_LABEL_BINDING_POSITION].item);
+	  label->bindings[MS_LABEL_BINDING_POSITION].item = strdup(msyytext);
+	  label->numbindings++;
+	}
       break;
     case(PRIORITY):
       if((symbol = getSymbol(2, MS_NUMBER,MS_BINDING)) == -1) return(-1);
@@ -1901,8 +1907,11 @@
 
   writeNumber(stream, indent, "OUTLINEWIDTH", 1, label->outlinewidth);
   writeKeyword(stream, indent, "PARTIALS", label->partials, 1, MS_FALSE, "FALSE");
-  writeKeyword(stream, indent, "POSITION", label->position, 10, MS_UL, "UL", MS_UC, "UC", MS_UR, "UR", MS_CL, "CL", MS_CC, "CC", MS_CR, "CR", MS_LL, "LL", MS_LC, "LC", MS_LR, "LR", MS_AUTO, "AUTO");
 
+  if(label->numbindings > 0 && label->bindings[MS_LABEL_BINDING_POSITION].item)
+     writeAttributeBinding(stream, indent, "POSITION", &(label->bindings[MS_LABEL_BINDING_POSITION]));
+  else writeKeyword(stream, indent, "POSITION", label->position, 10, MS_UL, "UL", MS_UC, "UC", MS_UR, "UR", MS_CL, "CL", MS_CC, "CC", MS_CR, "CR", MS_LL, "LL", MS_LC, "LC", MS_LR, "LR", MS_AUTO, "AUTO");
+
   if(label->numbindings > 0 && label->bindings[MS_LABEL_BINDING_PRIORITY].item)
     writeAttributeBinding(stream, indent, "PRIORITY", &(label->bindings[MS_LABEL_BINDING_PRIORITY]));
   else writeNumber(stream, indent, "PRIORITY", MS_DEFAULT_LABEL_PRIORITY, label->priority);

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2011-03-03 23:36:23 UTC (rev 11062)
+++ trunk/mapserver/mapserver.h	2011-03-04 05:40:14 UTC (rev 11063)
@@ -503,8 +503,8 @@
 /* Define supported bindings here (only covers existing bindings at first). Not accessible directly using MapScript. */
 #define MS_STYLE_BINDING_LENGTH 8
 enum MS_STYLE_BINDING_ENUM { MS_STYLE_BINDING_SIZE, MS_STYLE_BINDING_WIDTH, MS_STYLE_BINDING_ANGLE, MS_STYLE_BINDING_COLOR, MS_STYLE_BINDING_OUTLINECOLOR, MS_STYLE_BINDING_SYMBOL, MS_STYLE_BINDING_OUTLINEWIDTH, MS_STYLE_BINDING_OPACITY };
-#define MS_LABEL_BINDING_LENGTH 6
-enum MS_LABEL_BINDING_ENUM { MS_LABEL_BINDING_SIZE, MS_LABEL_BINDING_ANGLE, MS_LABEL_BINDING_COLOR, MS_LABEL_BINDING_OUTLINECOLOR, MS_LABEL_BINDING_FONT, MS_LABEL_BINDING_PRIORITY };
+#define MS_LABEL_BINDING_LENGTH 7
+enum MS_LABEL_BINDING_ENUM { MS_LABEL_BINDING_SIZE, MS_LABEL_BINDING_ANGLE, MS_LABEL_BINDING_COLOR, MS_LABEL_BINDING_OUTLINECOLOR, MS_LABEL_BINDING_FONT, MS_LABEL_BINDING_PRIORITY, MS_LABEL_BINDING_POSITION };
 
   /************************************************************************/
   /*                         attributeBindingObj                          */

Modified: trunk/mapserver/maputil.c
===================================================================
--- trunk/mapserver/maputil.c	2011-03-03 23:36:23 UTC (rev 11062)
+++ trunk/mapserver/maputil.c	2011-03-04 05:40:14 UTC (rev 11063)
@@ -203,6 +203,36 @@
         label->priority = MS_DEFAULT_LABEL_PRIORITY;
         bindIntegerAttribute(&label->priority, shape->values[label->bindings[MS_LABEL_BINDING_PRIORITY].index]);
       }
+
+      if(label->bindings[MS_LABEL_BINDING_POSITION].index != -1) {
+        int tmpPosition;
+        bindIntegerAttribute(&tmpPosition, shape->values[label->bindings[MS_LABEL_BINDING_POSITION].index]);
+        if(tmpPosition != 0) { /* is this test sufficient */
+          label->position = tmpPosition;
+        } else { /* Integer binding failed, look for strings like cc,ul,lr etc */
+          if(strlen(shape->values[label->bindings[MS_LABEL_BINDING_POSITION].index]) == 2) {
+            char *vp = shape->values[label->bindings[MS_LABEL_BINDING_POSITION].index];
+            if(!strncasecmp(vp,"ul",2))
+              label->position = MS_UL;     
+            else if(!strncasecmp(vp,"lr",2))
+              label->position = MS_LR;     
+            else if(!strncasecmp(vp,"ur",2))
+              label->position = MS_UR;     
+            else if(!strncasecmp(vp,"ll",2))
+              label->position = MS_LL;     
+            else if(!strncasecmp(vp,"cr",2))
+              label->position = MS_CR;     
+            else if(!strncasecmp(vp,"cl",2))
+              label->position = MS_CL;     
+	    else if(!strncasecmp(vp,"uc",2))
+              label->position = MS_UC;     
+            else if(!strncasecmp(vp,"lc",2))
+              label->position = MS_LC;     
+            else if(!strncasecmp(vp,"cc",2))
+              label->position = MS_CC;     
+          }       
+        }
+      }
     }
   } /* next classObj */
 



More information about the mapserver-commits mailing list