[mapserver-commits] r9307 - in trunk/mapserver: . mapscript/php3

svn at osgeo.org svn at osgeo.org
Tue Sep 15 10:41:34 EDT 2009


Author: assefa
Date: 2009-09-15 10:41:33 -0400 (Tue, 15 Sep 2009)
New Revision: 9307

Modified:
   trunk/mapserver/mapfile.c
   trunk/mapserver/mapscript/php3/php_mapscript.c
   trunk/mapserver/mapserver.h
   trunk/mapserver/maputil.c
Log:
add few additional style bindings #3125

Modified: trunk/mapserver/mapfile.c
===================================================================
--- trunk/mapserver/mapfile.c	2009-09-15 14:32:44 UTC (rev 9306)
+++ trunk/mapserver/mapfile.c	2009-09-15 14:41:33 UTC (rev 9307)
@@ -2053,7 +2053,15 @@
       if(getDouble(&(style->offsety)) == -1) return(MS_FAILURE);
       break;
     case(OPACITY):
-      if(getInteger(&(style->opacity)) == -1) return(MS_FAILURE);
+      if((symbol = getSymbol(2, MS_NUMBER,MS_BINDING)) == -1) return(MS_FAILURE);
+      if(symbol == MS_NUMBER)
+        style->opacity = (int) msyynumber;
+      else {
+        if (style->bindings[MS_STYLE_BINDING_OPACITY].item != NULL)
+          msFree(style->bindings[MS_STYLE_BINDING_OPACITY].item);
+        style->bindings[MS_STYLE_BINDING_OPACITY].item = strdup(msyytext);
+        style->numbindings++;
+      }
       break;
     case(OUTLINECOLOR):
       if(loadColor(&(style->outlinecolor), &(style->bindings[MS_STYLE_BINDING_OUTLINECOLOR])) != MS_SUCCESS) return(MS_FAILURE);
@@ -2095,11 +2103,20 @@
         return(-1);
       break;
     case(OUTLINEWIDTH):
-      if(getDouble(&(style->outlinewidth)) == -1) return(MS_FAILURE);
-      if(style->outlinewidth < 0) {
-          msSetError(MS_MISCERR, "Invalid WIDTH, must be greater than 0" , "loadStyle()");
+      if((symbol = getSymbol(2, MS_NUMBER,MS_BINDING)) == -1) return(MS_FAILURE);
+      if(symbol == MS_NUMBER) {
+        style->outlinewidth = (double) msyynumber;
+        if(style->outlinewidth < 0) {
+          msSetError(MS_MISCERR, "Invalid OUTLINEWIDTH, must be greater than 0" , "loadStyle()");
           return(MS_FAILURE);
+        }
       }
+      else {
+        if (style->bindings[MS_STYLE_BINDING_OUTLINEWIDTH].item != NULL)
+          msFree(style->bindings[MS_STYLE_BINDING_OUTLINEWIDTH].item);
+        style->bindings[MS_STYLE_BINDING_OUTLINEWIDTH].item = strdup(msyytext);
+        style->numbindings++;
+      }
       break;
     case(SIZE):
       if((symbol = getSymbol(2, MS_NUMBER,MS_BINDING)) == -1) return(MS_FAILURE);
@@ -2220,9 +2237,12 @@
   if(style->minsize != MS_MINSYMBOLSIZE) fprintf(stream, "        MINSIZE %g\n", style->minsize);
   if(style->maxwidth != MS_MAXSYMBOLWIDTH) fprintf(stream, "        MAXWIDTH %g\n", style->maxwidth);
   if(style->minwidth != MS_MINSYMBOLWIDTH) fprintf(stream, "        MINWIDTH %g\n", style->minwidth);  
-  if(style->opacity != 100) fprintf(stream, "        OPACITY %d\n", style->opacity);
-  if(style->outlinewidth > 0) fprintf(stream, "        OUTLINEWIDTH %g\n", style->outlinewidth);
-  
+  if(style->numbindings > 0 && style->bindings[MS_STYLE_BINDING_OPACITY].item)
+    fprintf(stream, "        OPACITY [%s]\n", style->bindings[MS_STYLE_BINDING_OPACITY].item);
+  else if(style->opacity != 100) fprintf(stream, "        OPACITY %d\n", style->opacity);
+  if(style->numbindings > 0 && style->bindings[MS_STYLE_BINDING_OUTLINEWIDTH].item)
+    fprintf(stream, "        OUTLINEWIDTH [%s]\n", style->bindings[MS_STYLE_BINDING_OUTLINEWIDTH].item);
+  else if(style->outlinewidth > 0) fprintf(stream, "        OUTLINEWIDTH %g\n", style->outlinewidth);
   if(style->numbindings > 0 && style->bindings[MS_STYLE_BINDING_OUTLINECOLOR].item)
       fprintf(stream, "        OUTLINECOLOR [%s]\n", style->bindings[MS_STYLE_BINDING_OUTLINECOLOR].item);
   else writeColor(&(style->outlinecolor), stream, "OUTLINECOLOR", "        "); 

Modified: trunk/mapserver/mapscript/php3/php_mapscript.c
===================================================================
--- trunk/mapserver/mapscript/php3/php_mapscript.c	2009-09-15 14:32:44 UTC (rev 9306)
+++ trunk/mapserver/mapscript/php3/php_mapscript.c	2009-09-15 14:41:33 UTC (rev 9307)
@@ -1328,6 +1328,8 @@
     REGISTER_LONG_CONSTANT("MS_STYLE_BINDING_COLOR", MS_STYLE_BINDING_COLOR, const_flag);
     REGISTER_LONG_CONSTANT("MS_STYLE_BINDING_OUTLINECOLOR", MS_STYLE_BINDING_OUTLINECOLOR, const_flag);
     REGISTER_LONG_CONSTANT("MS_STYLE_BINDING_SYMBOL", MS_STYLE_BINDING_SYMBOL, const_flag);
+    REGISTER_LONG_CONSTANT("MS_STYLE_BINDING_OUTLINEWIDTH", MS_STYLE_BINDING_OUTLINEWIDTH, const_flag);
+    REGISTER_LONG_CONSTANT("MS_STYLE_BINDING_OPACITY", MS_STYLE_BINDING_OPACITY, const_flag);
       
     REGISTER_LONG_CONSTANT("MS_LABEL_BINDING_SIZE",  MS_LABEL_BINDING_SIZE, const_flag);
     REGISTER_LONG_CONSTANT("MS_LABEL_BINDING_ANGLE", MS_LABEL_BINDING_ANGLE, const_flag);

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2009-09-15 14:32:44 UTC (rev 9306)
+++ trunk/mapserver/mapserver.h	2009-09-15 14:41:33 UTC (rev 9307)
@@ -617,8 +617,8 @@
 } queryMapObj;
 
 /* Define supported bindings here (only covers existing bindings at first). Not accessible directly using MapScript. */
-#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_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};
 

Modified: trunk/mapserver/maputil.c
===================================================================
--- trunk/mapserver/maputil.c	2009-09-15 14:32:44 UTC (rev 9306)
+++ trunk/mapserver/maputil.c	2009-09-15 14:41:33 UTC (rev 9307)
@@ -165,6 +165,16 @@
           MS_INIT_COLOR(style->outlinecolor, -1,-1,-1);
           bindColorAttribute(&style->outlinecolor, shape->values[style->bindings[MS_STYLE_BINDING_OUTLINECOLOR].index]);
         }
+
+        if(style->bindings[MS_STYLE_BINDING_OUTLINEWIDTH].index != -1) {
+          style->outlinewidth = 1;
+          bindDoubleAttribute(&style->outlinewidth, shape->values[style->bindings[MS_STYLE_BINDING_OUTLINEWIDTH].index]);
+        }
+
+        if(style->bindings[MS_STYLE_BINDING_OPACITY].index != -1) {
+          style->opacity = 100;
+          bindIntegerAttribute(&style->opacity, shape->values[style->bindings[MS_STYLE_BINDING_OPACITY].index]);
+        }
       }
     } /* next styleObj */
 



More information about the mapserver-commits mailing list