Index: map.h
===================================================================
RCS file: /data2/cvsroot/mapserver/map.h,v
retrieving revision 1.403
diff -U5 -r1.403 map.h
--- map.h	15 Apr 2005 17:10:36 -0000	1.403
+++ map.h	21 Apr 2005 16:26:39 -0000
@@ -639,11 +639,11 @@
 typedef struct {
   colorObj color;
   colorObj backgroundcolor;
   colorObj outlinecolor;
 
-  /* Stuff to handle Gradient Styles */
+  /* Stuff to handle Gradient /Styles */
   colorObj mincolor;
   colorObj maxcolor;
   double minvalue;
   double maxvalue;
   char *gradientitem;
@@ -1592,10 +1592,11 @@
 MS_DLL_EXPORT int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, int style);
 MS_DLL_EXPORT int msDrawPoint(mapObj *map, layerObj *layer, pointObj *point, imageObj *image, int classindex, char *labeltext);
 
   /*Gradient Support*/
 MS_DLL_EXPORT int msMapGradient(styleObj *style, shapeObj *shape);
+MS_DLL_EXPORT int msValueToGradient(styleObj *style, double fieldVal);
 
 MS_DLL_EXPORT void msCircleDrawLineSymbol(symbolSetObj *symbolset, imageObj *image, pointObj *p, double r, styleObj *style, double scalefactor);
 MS_DLL_EXPORT void msCircleDrawShadeSymbol(symbolSetObj *symbolset, imageObj *image, pointObj *p, double r, styleObj *style, double scalefactor);
 MS_DLL_EXPORT void msDrawMarkerSymbol(symbolSetObj *symbolset,imageObj *image, pointObj *p, styleObj *style, double scalefactor);
 MS_DLL_EXPORT void msDrawLineSymbol(symbolSetObj *symbolset, imageObj *image, shapeObj *p, styleObj *style, double scalefactor);
Index: mapdraw.c
===================================================================
RCS file: /data2/cvsroot/mapserver/mapdraw.c,v
retrieving revision 1.89
diff -U5 -r1.89 mapdraw.c
--- mapdraw.c	15 Apr 2005 17:10:36 -0000	1.89
+++ mapdraw.c	21 Apr 2005 16:26:39 -0000
@@ -1955,24 +1955,32 @@
  * 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 -- */
+  return msValueToGradient(style, fieldVal);
+}
+
+/**
+ * Allow direct mapping of a value so that mapscript can use the 
+ * Gradients
+ */
+int msValueToGradient(styleObj *style, double fieldVal)
+{
+  double range;
+  double scaledVal;
   /*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*/

