Index: map.h
===================================================================
RCS file: /data2/cvsroot/mapserver/map.h,v
retrieving revision 1.402
diff -r1.402 map.h
640a641,648
>   /* Stuff to handle Gradient Styles */
>   colorObj mincolor;
>   colorObj maxcolor;
>   double minvalue;
>   double maxvalue;
>   char *gradientitem;
>   int gradientitemindex;
>   
1583a1592,1594
>   /*Gradient Support*/
> MS_DLL_EXPORT int msMapGradient(styleObj *style, shapeObj *shape);
> 
1910a1922,1924
> #define MAX(a,b)      ((a>b) ? a : b)
> #define MIN(a,b)      ((a<b) ? a : b)
> 
Index: mapcopy.c
===================================================================
RCS file: /data2/cvsroot/mapserver/mapcopy.c,v
retrieving revision 1.36
diff -r1.36 mapcopy.c
385a386,387
> 
> 
388a391,399
>     /* Added to support Gradients (bug 1305)*/
>     MS_COPYCOLOR(&(dst->maxcolor), &(src->maxcolor));
>     MS_COPYCOLOR(&(dst->mincolor), &(src->mincolor));
>     MS_COPYSTELEM(minvalue);
>     MS_COPYSTELEM(maxvalue);
>     MS_COPYSTELEM(gradientitemindex);
>     if (src->gradientitem) MS_COPYSTRING(dst->gradientitem, src->gradientitem);
>     
> 
Index: mapdraw.c
===================================================================
RCS file: /data2/cvsroot/mapserver/mapdraw.c,v
retrieving revision 1.88
diff -r1.88 mapdraw.c
1296a1297,1305
> /* Before we do anything else, we will check for a gradientitem.
>    If its there, we need to change the style's color to map
>    the gradient to the shape */
>   for(s=0; s<layer->class[c].numstyles; s++)
>     {
>       if (layer->class[c].styles[s].gradientitem !=  NULL)
> 	msMapGradient(&(layer->class[c].styles[s]), shape);
>     }
>   
1940a1950,1983
> /**
>  * take the value from the shape and use it to change the 
>  * color in the style to match the gradient map
>  */
> int msMapGradient(styleObj *style, shapeObj *shape)
> {
>   double fieldVal;
>   double range;
>   double scaledVal;
>   char* fieldStr;
> 
>   /*first, get the value of the gradientitem, which should*/
>   /*evaluate to a double*/
>   fieldStr = shape->values[style->gradientitemindex];
>   if (fieldStr == NULL) /*if there's not value, bail*/
>     {
>       return MS_FAILURE;
>     }
>   fieldVal = 0.0;
> 
>   fieldVal = atof(fieldStr); /*faith that it's ok -- */
>   /*should switch to strtod*/
>   range = style->maxvalue - style->minvalue;
>   scaledVal = (fieldVal - style->minvalue)/range;
>   
>   /*At this point, we know where on the gradient we need to be*/
>   /*However, we don't know how to map it yet, since RGB(A) can */
>   /*Go up or down*/
>   style->color.red = (int)(MAX(0,(MIN(255, (style->mincolor.red + ((style->maxcolor.red - style->mincolor.red) * scaledVal))))));
>   style->color.green = (int)(MAX(0,(MIN(255,(style->mincolor.green + ((style->maxcolor.green - style->mincolor.green) * scaledVal))))));
>   style->color.blue = (int)(MAX(0,(MIN(255,(style->mincolor.blue + ((style->maxcolor.blue - style->mincolor.blue) * scaledVal))))));
>   style->color.pen = MS_PEN_UNSET; /*so it will recalculate pen*/
> 
>   /*( "msMapGradient(): %i %i %i", style->color.red , style->color.green, style->color.blue);*/
1941a1985,1990
> #if ALPHACOLOR_ENABLED
>   /*NO ALPHA GRADIENT YET  style->color.alpha = style->mincolor.alpha + ((style->maxcolor.alpha - style->mincolor.alpha) * scaledVal);*/
> #endif
> 
>   return MS_SUCCESS;
> }
Index: mapfile.c
===================================================================
RCS file: /data2/cvsroot/mapserver/mapfile.c,v
retrieving revision 1.294
diff -r1.294 mapfile.c
1598c1598,1605
<   style->symbol = 0; /* there is always a default symbol */
---
>   /* New Gradient fields*/
>   MS_INIT_COLOR(style->mincolor, -1,-1,-1);
>   MS_INIT_COLOR(style->maxcolor, -1,-1,-1);
>   style->minvalue = 0.0;
>   style->maxvalue = 1.0;
>   style->gradientitem = NULL;
>   /* End Gradient fields*/
>   style->symbol = 0; /* there is always a default symbol*/
1621a1629,1645
>   /* New Gradient fields*/
>     case (MINCOLOR):
>       if(loadColor(&(style->mincolor)) != MS_SUCCESS) return(MS_FAILURE);
>       break;
>     case (MAXCOLOR):
>       if(loadColor(&(style->maxcolor)) != MS_SUCCESS) return(MS_FAILURE);
>       break;
>     case(MINVALUE):
>       if(getDouble(&(style->minvalue)) == -1) return(-1);
>       break;
>     case(MAXVALUE):
>       if(getDouble(&(style->maxvalue)) == -1) return(-1);
>       break;
>     case(GRADIENTITEM):
>       if(getString(&style->gradientitem) == MS_FAILURE) return(-1);
>       break;
>   /* End Gradient fields*/
1641a1666,1671
>     case (ALPHAMINCOLOR):
>       if(loadColorWithAlpha(&(style->mincolor)) != MS_SUCCESS) return(MS_FAILURE);
>       break;
>     case (ALPHAMAXCOLOR):
>       if(loadColorWithAlpha(&(style->maxcolor)) != MS_SUCCESS) return(MS_FAILURE);
>       break;
1719c1749,1759
<   if(style->maxsize != MS_MAXSYMBOLSIZE) fprintf(stream, "        MAXSIZE %d\n", style->maxsize);
---
>   /* Gradient fields*/
>   writeColor(&(style->mincolor), stream, "MINCOLOR", "        ");
>   writeColor(&(style->maxcolor), stream, "MAXCOLOR", "        ");
>   if(style->gradientitem) 
>     {
>       fprintf(stream, "        GRADIENTITEM %s\n", style->gradientitem);
>       /* No way to tell if minvalue/maxvalue have been set, so tag along w/gradientitem */
>       fprintf(stream, "        MINVALUE %lf\n", style->minvalue);
>       fprintf(stream, "        MAXVALUE %lf\n", style->maxvalue);
>     }
>   /*End Gradient Fields */
Index: mapfile.h
===================================================================
RCS file: /data2/cvsroot/mapserver/mapfile.h,v
retrieving revision 1.45
diff -r1.45 mapfile.h
210a211,219
>  /* Gradient support */
> #define MINCOLOR 1170
> #define MAXCOLOR 1171
> #define ALPHAMINCOLOR 1172
> #define ALPHAMAXCOLOR 1173
> #define MINVALUE 1174
> #define MAXVALUE 1175
> #define GRADIENTITEM 1176
> 
Index: maplayer.c
===================================================================
RCS file: /data2/cvsroot/mapserver/maplayer.c,v
retrieving revision 1.102
diff -r1.102 maplayer.c
872a873
> 	if(layer->class[i].styles[j].gradientitem) nt++;
972a974
> 	  if(layer->class[i].styles[j].gradientitem) layer->class[i].styles[j].gradientitemindex = string2list(layer->items, &(layer->numitems), layer->class[i].styles[j].gradientitem); 
Index: maplexer.l
===================================================================
RCS file: /data2/cvsroot/mapserver/maplexer.l,v
retrieving revision 1.89
diff -r1.89 maplexer.l
122a123,130
> <INITIAL,OBJECT_STRING>mincolor 	       { return(MINCOLOR); }
> <INITIAL,OBJECT_STRING>maxcolor 	       { return(MAXCOLOR); }
> <INITIAL,OBJECT_STRING>alphamincolor	       { return(ALPHAMAXCOLOR); }
> <INITIAL,OBJECT_STRING>alphamaxcolor 	       { return(ALPHAMAXCOLOR); }
> <INITIAL,OBJECT_STRING>minvalue                { return(MINVALUE); }
> <INITIAL,OBJECT_STRING>maxvalue                { return(MAXVALUE); }
> <INITIAL,OBJECT_STRING>gradientitem            { return(GRADIENTITEM); }
> 

