[mapserver-commits] r12741 - branches/branch-6-0/mapserver

svn at osgeo.org svn at osgeo.org
Wed Nov 2 13:58:12 EDT 2011


Author: aboudreault
Date: 2011-11-02 10:58:12 -0700 (Wed, 02 Nov 2011)
New Revision: 12741

Modified:
   branches/branch-6-0/mapserver/HISTORY.TXT
   branches/branch-6-0/mapserver/mapfile.c
   branches/branch-6-0/mapserver/mapserver.h
Log:
Backport 6.0: Fixed Python Mapscript does not write COLOR to reference map (#4042) 

Modified: branches/branch-6-0/mapserver/HISTORY.TXT
===================================================================
--- branches/branch-6-0/mapserver/HISTORY.TXT	2011-11-02 17:47:24 UTC (rev 12740)
+++ branches/branch-6-0/mapserver/HISTORY.TXT	2011-11-02 17:58:12 UTC (rev 12741)
@@ -15,6 +15,8 @@
 Current Version (future 6.0.2, SVN branch-6-0):
 ---------------------------
 
+- Fixed Python Mapscript does not write COLOR to reference map (#4042)
+ 
 - Fixed cannot add a style to a label in PHP/SWIG Mapscript (#4038) 
 
 - Add missing support for outputFormat in WFS GetFeature POST XML requests (#4052)

Modified: branches/branch-6-0/mapserver/mapfile.c
===================================================================
--- branches/branch-6-0/mapserver/mapfile.c	2011-11-02 17:47:24 UTC (rev 12740)
+++ branches/branch-6-0/mapserver/mapfile.c	2011-11-02 17:58:12 UTC (rev 12741)
@@ -616,8 +616,10 @@
   fprintf(stream, "%s [%s]\n", name, binding->item);
 }
 
-static void writeColor(FILE *stream, int indent, const char *name, colorObj *color) {
-  if(!MS_VALID_COLOR(*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);
@@ -1923,6 +1925,7 @@
 static void writeLabel(FILE *stream, int indent, labelObj *label)
 {
   int i;
+  colorObj c;
 
   if(label->size == -1) return; /* there is no default label anymore */
 
@@ -1958,7 +1961,10 @@
 
   if(label->numbindings > 0 && label->bindings[MS_LABEL_BINDING_COLOR].item)
     writeAttributeBinding(stream, indent, "COLOR", &(label->bindings[MS_LABEL_BINDING_COLOR]));
-  else writeColor(stream, indent, "COLOR", &(label->color));
+  else {
+    MS_INIT_COLOR(c,0,0,0,255);
+    writeColor(stream, indent, "COLOR", &c, &(label->color));
+  }
 
   writeString(stream, indent, "ENCODING", NULL, label->encoding);
   writeKeyword(stream, indent, "FORCE", label->force, 1, MS_TRUE, "TRUE");
@@ -1972,7 +1978,7 @@
     
   if(label->numbindings > 0 && label->bindings[MS_LABEL_BINDING_OUTLINECOLOR].item)
     writeAttributeBinding(stream, indent, "OUTLINECOLOR", &(label->bindings[MS_LABEL_BINDING_OUTLINECOLOR]));
-  else writeColor(stream, indent, "OUTLINECOLOR", &(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");
@@ -1986,7 +1992,7 @@
   else writeNumber(stream, indent, "PRIORITY", MS_DEFAULT_LABEL_PRIORITY, label->priority);
 
   writeNumber(stream, indent, "REPEATDISTANCE", 0, label->repeatdistance);
-  writeColor(stream, indent, "SHADOWCOLOR", &(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);
@@ -2697,11 +2703,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");
-  writeColor(stream, indent, "BACKGROUNDCOLOR", &(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 writeColor(stream, indent, "COLOR", &(style->color));
+  else writeColor(stream, indent, "COLOR", NULL, &(style->color));
   
   writeNumber(stream, indent, "GAP", 0, style->gap);
 
@@ -2748,7 +2754,7 @@
 
   if(style->numbindings > 0 && style->bindings[MS_STYLE_BINDING_OUTLINECOLOR].item)
     writeAttributeBinding(stream, indent, "OUTLINECOLOR", &(style->bindings[MS_STYLE_BINDING_OUTLINECOLOR]));
-  else writeColor(stream, indent, "OUTLINECOLOR", &(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]));
@@ -4010,7 +4016,7 @@
   writeNumber(stream, indent, "MINSCALEDENOM", -1, layer->minscaledenom);
   writeNumber(stream, indent, "MINFEATURESIZE", -1, layer->minfeaturesize);
   writeString(stream, indent, "NAME", NULL, layer->name);
-  writeColor(stream, indent, "OFFSITE", &(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++)
@@ -4185,14 +4191,18 @@
 
 static void writeReferenceMap(FILE *stream, int indent, referenceMapObj *ref)
 {
+  colorObj c;
+
   if(!ref->image) return;
 
   indent++;
   writeBlockBegin(stream, indent, "REFERENCE");
-  writeColor(stream, indent, "COLOR", &(ref->color));
+  MS_INIT_COLOR(c,255,0,0,255);
+  writeColor(stream, indent, "COLOR", &c, &(ref->color));
   writeExtent(stream, indent, "EXTENT", ref->extent);
   writeString(stream, indent, "IMAGE", NULL, ref->image);
-  writeColor(stream, indent, "OUTLINECOLOR", &(ref->outlinecolor));
+  MS_INIT_COLOR(c,0,0,0,255);
+  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);
@@ -4519,14 +4529,17 @@
 
 static void writeLegend(FILE *stream, int indent, legendObj *legend)
 {
+  colorObj c;
+
   indent++;
   writeBlockBegin(stream, indent, "LEGEND");
-  writeColor(stream, indent, "IMAGECOLOR", &(legend->imagecolor));
+  MS_INIT_COLOR(c,255,255,255,255);
+  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));
-  writeColor(stream, indent, "OUTLINECOLOR", &(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");
@@ -4662,16 +4675,19 @@
 
 static void writeScalebar(FILE *stream, int indent, scalebarObj *scalebar)
 {
+  colorObj c;
+
   indent++;
   writeBlockBegin(stream, indent, "SCALEBAR");
   writeKeyword(stream, indent, "ALIGN", scalebar->align, 2, MS_ALIGN_LEFT, "LEFT", MS_ALIGN_RIGHT, "RIGHT");
-  writeColor(stream, indent, "BACKGROUNDCOLOR", &(scalebar->backgroundcolor));
-  writeColor(stream, indent, "COLOR", &(scalebar->color));
-  writeColor(stream, indent, "IMAGECOLOR", &(scalebar->imagecolor));
+  writeColor(stream, indent, "BACKGROUNDCOLOR", NULL, &(scalebar->backgroundcolor));
+  MS_INIT_COLOR(c,0,0,0,255);
+  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));
-  writeColor(stream, indent, "OUTLINECOLOR", &(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);
@@ -4758,9 +4774,12 @@
 
 static void writeQueryMap(FILE *stream, int indent, queryMapObj *querymap)
 {
+  colorObj c;
+
   indent++;
   writeBlockBegin(stream, indent, "QUERYMAP");
-  writeColor(stream, indent, "COLOR", &(querymap->color));
+  MS_INIT_COLOR(c,255,255,0,255);
+  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");
@@ -5224,6 +5243,7 @@
   int i, indent=0;
   FILE *stream;
   char szPath[MS_MAXPATHLEN];
+  colorObj c;
 
   if(!map) {
     msSetError(MS_MISCERR, "Map is undefined.", "msSaveMap()");
@@ -5248,7 +5268,8 @@
   writeNumber(stream, indent, "DEFRESOLUTION", 72.0, map->defresolution);
   writeExtent(stream, indent, "EXTENT", map->extent);
   writeString(stream, indent, "FONTSET", NULL, map->fontset.filename);
-  writeColor(stream, indent, "IMAGECOLOR", &(map->imagecolor));
+  MS_INIT_COLOR(c,255,255,255,255);
+  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: branches/branch-6-0/mapserver/mapserver.h
===================================================================
--- branches/branch-6-0/mapserver/mapserver.h	2011-11-02 17:47:24 UTC (rev 12740)
+++ branches/branch-6-0/mapserver/mapserver.h	2011-11-02 17:58:12 UTC (rev 12741)
@@ -367,6 +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_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