[mapserver-commits] r7935 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Mon Sep 29 22:58:37 EDT 2008


Author: sdlime
Date: 2008-09-29 22:58:37 -0400 (Mon, 29 Sep 2008)
New Revision: 7935

Modified:
   trunk/mapserver/mapfile.c
   trunk/mapserver/mapserver.h
   trunk/mapserver/maputil.c
Log:
Style->width can take an attribute binding now.

Modified: trunk/mapserver/mapfile.c
===================================================================
--- trunk/mapserver/mapfile.c	2008-09-30 02:57:06 UTC (rev 7934)
+++ trunk/mapserver/mapfile.c	2008-09-30 02:58:37 UTC (rev 7935)
@@ -1864,11 +1864,10 @@
       break;
     case(SIZE):
       if((symbol = getSymbol(2, MS_NUMBER,MS_BINDING)) == -1) return(MS_FAILURE);
-
       if(symbol == MS_NUMBER)
         style->size = (double) msyynumber;
       else {
- 	      style->bindings[MS_STYLE_BINDING_SIZE].item = strdup(msyytext);
+ 	style->bindings[MS_STYLE_BINDING_SIZE].item = strdup(msyytext);
         style->numbindings++;
       }
       break;
@@ -1886,10 +1885,12 @@
       }
       break;
     case(WIDTH):
-      if(getDouble(&(style->width)) == -1) return(MS_FAILURE);
-      if(!(style->width > 0)) {
-        msSetError(MS_MISCERR, "Invalid WIDTH, must be greater than 0." , "loadStyle()");
-        return(MS_FAILURE);
+      if((symbol = getSymbol(2, MS_NUMBER,MS_BINDING)) == -1) return(MS_FAILURE);
+      if(symbol == MS_NUMBER)
+        style->width = (double) msyynumber;
+      else {
+        style->bindings[MS_STYLE_BINDING_WIDTH].item = strdup(msyytext);
+        style->numbindings++;
       }
       break;
     default:
@@ -1976,16 +1977,19 @@
 
   if(style->numbindings > 0 && style->bindings[MS_STYLE_BINDING_SYMBOL].item)
      fprintf(stream, "        SYMBOL [%s]\n", style->bindings[MS_STYLE_BINDING_SYMBOL].item);
-  else
-  {
+  else {
     if(style->symbolname)
       fprintf(stream, "        SYMBOL \"%s\"\n", style->symbolname);
     else
       fprintf(stream, "        SYMBOL %d\n", style->symbol);
   }
-  if(style->width > 1) fprintf(stream, "        WIDTH %g\n", style->width);
-  if (style->offsetx != 0 || style->offsety != 0)  fprintf(stream, "        OFFSET %d %d\n", style->offsetx, style->offsety);
 
+  if(style->numbindings > 0 && style->bindings[MS_STYLE_BINDING_WIDTH].item)
+    fprintf(stream, "        WIDTH [%s]\n", style->bindings[MS_STYLE_BINDING_WIDTH].item);
+  else if(style->width > 0) fprintf(stream, "        WIDTH %g\n", style->width);
+
+  if(style->offsetx != 0 || style->offsety != 0)  fprintf(stream, "        OFFSET %d %d\n", style->offsetx, style->offsety);
+
   if(style->rangeitem) {
     fprintf(stream, "        RANGEITEM \"%s\"\n", style->rangeitem);
     writeColorRange(&(style->mincolor),&(style->maxcolor), stream, "COLORRANGE", "        ");

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2008-09-30 02:57:06 UTC (rev 7934)
+++ trunk/mapserver/mapserver.h	2008-09-30 02:58:37 UTC (rev 7935)
@@ -551,8 +551,8 @@
 } queryMapObj;
 
 /* Define supported bindings here (only covers existing bindings at first). Not accessible directly using MapScript. */
-#define MS_STYLE_BINDING_LENGTH 5
-enum MS_STYLE_BINDING_ENUM { MS_STYLE_BINDING_SIZE, MS_STYLE_BINDING_ANGLE, MS_STYLE_BINDING_COLOR, MS_STYLE_BINDING_OUTLINECOLOR, MS_STYLE_BINDING_SYMBOL};
+#define MS_STYLE_BINDING_LENGTH 6
+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};
 #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};
 

Modified: trunk/mapserver/maputil.c
===================================================================
--- trunk/mapserver/maputil.c	2008-09-30 02:57:06 UTC (rev 7934)
+++ trunk/mapserver/maputil.c	2008-09-30 02:58:37 UTC (rev 7935)
@@ -150,6 +150,11 @@
           bindDoubleAttribute(&style->size, shape->values[style->bindings[MS_STYLE_BINDING_SIZE].index]);
         }
 
+        if(style->bindings[MS_STYLE_BINDING_WIDTH].index != -1) {
+          style->width = 1;
+          bindDoubleAttribute(&style->width, shape->values[style->bindings[MS_STYLE_BINDING_WIDTH].index]);
+        }
+
         if(style->bindings[MS_STYLE_BINDING_COLOR].index != -1 && (querymapMode != MS_TRUE)) {
           MS_INIT_COLOR(style->color, -1,-1,-1);
           bindColorAttribute(&style->color, shape->values[style->bindings[MS_STYLE_BINDING_COLOR].index]);



More information about the mapserver-commits mailing list