[mapserver-commits] r12642 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Fri Oct 7 14:03:07 EDT 2011


Author: aboudreault
Date: 2011-10-07 11:03:06 -0700 (Fri, 07 Oct 2011)
New Revision: 12642

Modified:
   trunk/mapserver/mapfile.c
   trunk/mapserver/mapserver.h
Log:
damn... use pointers...

Modified: trunk/mapserver/mapfile.c
===================================================================
--- trunk/mapserver/mapfile.c	2011-10-07 17:33:08 UTC (rev 12641)
+++ trunk/mapserver/mapfile.c	2011-10-07 18:03:06 UTC (rev 12642)
@@ -616,8 +616,10 @@
   fprintf(stream, "%s [%s]\n", name, binding->item);
 }
 
-static void writeColor(FILE *stream, int indent, const char *name, colorObj defaultColor, colorObj *color) {
-  if(MS_COMPARE_COLOR(defaultColor, *color)) return; /* if defaultColor has the same value than the color, return.*/
+static void writeColor(FILE *stream, int indent, const char *name, colorObj *defaultColor, colorObj *color) {
+    if (!defaultColor && !MS_VALID_COLOR(*color)) return;
+    else if(defaultColor && MS_COMPARE_COLOR(*defaultColor, *color)) return; /* if defaultColor has the same value than the color, return.*/
+  
   writeIndent(stream, ++indent);
 #if ALPHACOLOR_ENABLED
   fprintf(stream, "%s %d %d %d\n", name, color->red, color->green, color->blue, color->alpha);
@@ -1961,7 +1963,7 @@
     writeAttributeBinding(stream, indent, "COLOR", &(label->bindings[MS_LABEL_BINDING_COLOR]));
   else {
     MS_INIT_COLOR(c,0,0,0,255);
-    writeColor(stream, indent, "COLOR", c, &(label->color));
+    writeColor(stream, indent, "COLOR", &c, &(label->color));
   }
 
   writeString(stream, indent, "ENCODING", NULL, label->encoding);
@@ -1976,10 +1978,7 @@
     
   if(label->numbindings > 0 && label->bindings[MS_LABEL_BINDING_OUTLINECOLOR].item)
     writeAttributeBinding(stream, indent, "OUTLINECOLOR", &(label->bindings[MS_LABEL_BINDING_OUTLINECOLOR]));
-  else {
-    MS_INIT_COLOR(c,-1,-1,-1,255);
-    writeColor(stream, indent, "OUTLINECOLOR", c, &(label->outlinecolor));
-  }
+  else  writeColor(stream, indent, "OUTLINECOLOR", NULL, &(label->outlinecolor));
 
   writeNumber(stream, indent, "OUTLINEWIDTH", 1, label->outlinewidth);
   writeKeyword(stream, indent, "PARTIALS", label->partials, 1, MS_FALSE, "FALSE");
@@ -1993,8 +1992,7 @@
   else writeNumber(stream, indent, "PRIORITY", MS_DEFAULT_LABEL_PRIORITY, label->priority);
 
   writeNumber(stream, indent, "REPEATDISTANCE", 0, label->repeatdistance);
-  MS_INIT_COLOR(c,-1,-1,-1,255);
-  writeColor(stream, indent, "SHADOWCOLOR", c, &(label->shadowcolor));
+  writeColor(stream, indent, "SHADOWCOLOR", NULL, &(label->shadowcolor));
   writeDimension(stream, indent, "SHADOWSIZE", label->shadowsizex, label->shadowsizey, label->bindings[MS_LABEL_BINDING_SHADOWSIZEX].item, label->bindings[MS_LABEL_BINDING_SHADOWSIZEY].item);
 
   writeNumber(stream, indent, "MAXOVERLAPANGLE", 22.5, label->maxoverlapangle);
@@ -2694,8 +2692,6 @@
 
 void writeStyle(FILE *stream, int indent, styleObj *style) {
 
-  colorObj c;
-
   indent++;
   writeBlockBegin(stream, indent, "STYLE");
 
@@ -2704,15 +2700,11 @@
   else writeNumberOrKeyword(stream, indent, "ANGLE", 360, style->angle, style->autoangle, 1, MS_TRUE, "AUTO");
 
   writeKeyword(stream, indent, "ANTIALIAS", style->antialias, 1, MS_TRUE, "TRUE");
-  MS_INIT_COLOR(c,-1,-1,-1,255);
-  writeColor(stream, indent, "BACKGROUNDCOLOR", c, &(style->backgroundcolor));
+  writeColor(stream, indent, "BACKGROUNDCOLOR", NULL, &(style->backgroundcolor));
 
   if(style->numbindings > 0 && style->bindings[MS_STYLE_BINDING_COLOR].item)
     writeAttributeBinding(stream, indent, "COLOR", &(style->bindings[MS_STYLE_BINDING_COLOR]));
-  else {
-    MS_INIT_COLOR(c,-1,-1,-1,255);
-    writeColor(stream, indent, "COLOR", c, &(style->color));
-  }
+  else writeColor(stream, indent, "COLOR", NULL, &(style->color));
   
   writeNumber(stream, indent, "GAP", 0, style->gap);
 
@@ -2759,10 +2751,7 @@
 
   if(style->numbindings > 0 && style->bindings[MS_STYLE_BINDING_OUTLINECOLOR].item)
     writeAttributeBinding(stream, indent, "OUTLINECOLOR", &(style->bindings[MS_STYLE_BINDING_OUTLINECOLOR]));
-  else {
-    MS_INIT_COLOR(c,-1,-1,-1,255);
-    writeColor(stream, indent, "OUTLINECOLOR", c, &(style->outlinecolor)); 
-  }
+  else  writeColor(stream, indent, "OUTLINECOLOR", NULL, &(style->outlinecolor)); 
 
   if(style->numbindings > 0 && style->bindings[MS_STYLE_BINDING_OUTLINEWIDTH].item)
     writeAttributeBinding(stream, indent, "OUTLINEWIDTH", &(style->bindings[MS_STYLE_BINDING_OUTLINEWIDTH]));
@@ -3989,7 +3978,6 @@
 {
   int i;
   featureListNodeObjPtr current=NULL;
-  colorObj c;
 
   if(layer->status == MS_DELETE)
     return;
@@ -4025,8 +4013,7 @@
   writeNumber(stream, indent, "MINSCALEDENOM", -1, layer->minscaledenom);
   writeNumber(stream, indent, "MINFEATURESIZE", -1, layer->minfeaturesize);
   writeString(stream, indent, "NAME", NULL, layer->name);
-  MS_INIT_COLOR(c,-1,-1,-1,255);
-  writeColor(stream, indent, "OFFSITE", c, &(layer->offsite));
+  writeColor(stream, indent, "OFFSITE", NULL, &(layer->offsite));
   writeString(stream, indent, "PLUGIN", NULL, layer->plugin_library_original);
   writeKeyword(stream, indent, "POSTLABELCACHE", layer->postlabelcache, 1, MS_TRUE, "TRUE");
   for(i=0; i<layer->numprocessing; i++)
@@ -4208,11 +4195,11 @@
   indent++;
   writeBlockBegin(stream, indent, "REFERENCE");
   MS_INIT_COLOR(c,255,0,0,255);
-  writeColor(stream, indent, "COLOR", c, &(ref->color));
+  writeColor(stream, indent, "COLOR", &c, &(ref->color));
   writeExtent(stream, indent, "EXTENT", ref->extent);
   writeString(stream, indent, "IMAGE", NULL, ref->image);
   MS_INIT_COLOR(c,0,0,0,255);
-  writeColor(stream, indent, "OUTLINECOLOR", c, &(ref->outlinecolor));
+  writeColor(stream, indent, "OUTLINECOLOR", &c, &(ref->outlinecolor));
   writeDimension(stream, indent, "SIZE", ref->width, ref->height, NULL, NULL);
   writeKeyword(stream, indent, "STATUS", ref->status, 2, MS_ON, "ON", MS_OFF, "OFF");
   writeNumberOrString(stream, indent, "MARKER", 0, ref->marker, ref->markername);
@@ -4544,13 +4531,12 @@
   indent++;
   writeBlockBegin(stream, indent, "LEGEND");
   MS_INIT_COLOR(c,255,255,255,255);
-  writeColor(stream, indent, "IMAGECOLOR", c, &(legend->imagecolor));
+  writeColor(stream, indent, "IMAGECOLOR", &c, &(legend->imagecolor));
   writeKeyword(stream, indent, "INTERLACE", legend->interlace, 2, MS_TRUE, "TRUE", MS_FALSE, "FALSE");
   writeDimension(stream, indent, "KEYSIZE", legend->keysizex, legend->keysizey, NULL, NULL);
   writeDimension(stream, indent, "KEYSPACING", legend->keyspacingx, legend->keyspacingy, NULL, NULL);
   writeLabel(stream, indent, &(legend->label));
-  MS_INIT_COLOR(c,-1,-1,-1,255);
-  writeColor(stream, indent, "OUTLINECOLOR", c, &(legend->outlinecolor));
+  writeColor(stream, indent, "OUTLINECOLOR", NULL, &(legend->outlinecolor));
   if(legend->status == MS_EMBED) writeKeyword(stream, indent, "POSITION", legend->position, 6, MS_LL, "LL", MS_UL, "UL", MS_UR, "UR", MS_LR, "LR", MS_UC, "UC", MS_LC, "LC");
   writeKeyword(stream, indent, "POSTLABELCACHE", legend->postlabelcache, 1, MS_TRUE, "TRUE");
   writeKeyword(stream, indent, "STATUS", legend->status, 3, MS_ON, "ON", MS_OFF, "OFF", MS_EMBED, "EMBED");
@@ -4691,17 +4677,14 @@
   indent++;
   writeBlockBegin(stream, indent, "SCALEBAR");
   writeKeyword(stream, indent, "ALIGN", scalebar->align, 2, MS_ALIGN_LEFT, "LEFT", MS_ALIGN_RIGHT, "RIGHT");
-  MS_INIT_COLOR(c,-1,-1,-1,255);
-  writeColor(stream, indent, "BACKGROUNDCOLOR", c, &(scalebar->backgroundcolor));
+  writeColor(stream, indent, "BACKGROUNDCOLOR", NULL, &(scalebar->backgroundcolor));
   MS_INIT_COLOR(c,0,0,0,255);
-  writeColor(stream, indent, "COLOR", c, &(scalebar->color));
-  MS_INIT_COLOR(c,-1,-1,-1,255);
-  writeColor(stream, indent, "IMAGECOLOR", c, &(scalebar->imagecolor));
+  writeColor(stream, indent, "COLOR", &c, &(scalebar->color));
+  writeColor(stream, indent, "IMAGECOLOR", NULL, &(scalebar->imagecolor));
   writeKeyword(stream, indent, "INTERLACE", scalebar->interlace, 2, MS_TRUE, "TRUE", MS_FALSE, "FALSE");
   writeNumber(stream, indent, "INTERVALS", -1, scalebar->intervals);
   writeLabel(stream, indent, &(scalebar->label));
-  MS_INIT_COLOR(c,-1,-1,-1,255);
-  writeColor(stream, indent, "OUTLINECOLOR", c, &(scalebar->outlinecolor));
+  writeColor(stream, indent, "OUTLINECOLOR", NULL, &(scalebar->outlinecolor));
   if(scalebar->status == MS_EMBED) writeKeyword(stream, indent, "POSITION", scalebar->position, 6, MS_LL, "LL", MS_UL, "UL", MS_UR, "UR", MS_LR, "LR", MS_UC, "UC", MS_LC, "LC");
   writeKeyword(stream, indent, "POSTLABELCACHE", scalebar->postlabelcache, 1, MS_TRUE, "TRUE");
   writeDimension(stream, indent, "SIZE", scalebar->width, scalebar->height, NULL, NULL);
@@ -4793,7 +4776,7 @@
   indent++;
   writeBlockBegin(stream, indent, "QUERYMAP");
   MS_INIT_COLOR(c,255,255,0,255);
-  writeColor(stream, indent, "COLOR",  c, &(querymap->color));
+  writeColor(stream, indent, "COLOR",  &c, &(querymap->color));
   writeDimension(stream, indent, "SIZE", querymap->width, querymap->height, NULL, NULL);
   writeKeyword(stream, indent, "STATUS", querymap->status, 2, MS_ON, "ON", MS_OFF, "OFF");
   writeKeyword(stream, indent, "STYLE", querymap->style, 3, MS_NORMAL, "NORMAL", MS_HILITE, "HILITE", MS_SELECTED, "SELECTED");
@@ -5283,7 +5266,7 @@
   writeExtent(stream, indent, "EXTENT", map->extent);
   writeString(stream, indent, "FONTSET", NULL, map->fontset.filename);
   MS_INIT_COLOR(c,255,255,255,255);
-  writeColor(stream, indent, "IMAGECOLOR", c, &(map->imagecolor));
+  writeColor(stream, indent, "IMAGECOLOR", &c, &(map->imagecolor));
   writeString(stream, indent, "IMAGETYPE", NULL, map->imagetype);
   writeKeyword(stream, indent, "INTERLACE", map->interlace, 2, MS_TRUE, "TRUE", MS_FALSE, "FALSE");
   writeNumber(stream, indent, "MAXSIZE", MS_MAXIMAGESIZE_DEFAULT, map->maxsize);

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2011-10-07 17:33:08 UTC (rev 12641)
+++ trunk/mapserver/mapserver.h	2011-10-07 18:03:06 UTC (rev 12642)
@@ -367,7 +367,7 @@
 
 #define MS_INIT_COLOR(color,r,g,b,a) { (color).red = r; (color).green = g; (color).blue = b; (color).pen = MS_PEN_UNSET; (color).alpha=a; }
 #define MS_VALID_COLOR(color) (((color).red==-1 || (color).green==-1 || (color).blue==-1)?MS_FALSE:MS_TRUE)
-#define MS_COMPARE_COLOR(color1, color2) (((color2).red==color1.red && (color2).green==color1.green && (color2).blue==color1.blue)?MS_TRUE:MS_FALSE)
+#define MS_COMPARE_COLOR(color1, color2) (((color2).red==(color1).red && (color2).green==(color1).green && (color2).blue==(color1).blue)?MS_TRUE:MS_FALSE)
 #define MS_TRANSPARENT_COLOR(color) (((color).alpha==0 || (color).red==-255 || (color).green==-255 || (color).blue==-255)?MS_TRUE:MS_FALSE)
 #define MS_COMPARE_COLORS(a,b) (((a).red!=(b).red || (a).green!=(b).green || (a).blue!=(b).blue)?MS_FALSE:MS_TRUE)
 #define MS_COLOR_GETRGB(color) (MS_VALID_COLOR(color)?((color).red *0x10000 + (color).green *0x100 + (color).blue):-1)



More information about the mapserver-commits mailing list