Hi,

can you please submit this via the Mapserver bugzilla?

Thanks in advance.

Best regards,
Bart

Rob Cermak schreef:
Hi,

We have a patch for the SLD rendering for the colormap.  It seems that it is
documented to take doubles, but all floats passed via SLD become ints through
use of atoi.

This patch only takes care of the ColorMap.  This allows color rendering of
float values.

http://ak.aoos.org/data/patch/mapserver_483_mapogcsld.patch

If some change could work into 4.10, that would be great.

Cheers,
Rob

--- mapogcsld.c.orig    2006-09-12 15:30:39.000000000 -0800
+++ mapogcsld.c 2006-09-12 15:32:24.000000000 -0800
@@ -2354,6 +2354,7 @@
     char szExpression[100];
     int nClassId = 0;
     double dfOpacity = 1.0;
+    char *pch, *pchPrevious;

     if (!psRoot || !psLayer)
       return;
@@ -2403,10 +2404,32 @@
                         sColor.blue = hex2int(pszPreviousColor+5);

                         /* ?? Test if pszPreviousQuality < pszQuantity */
-                        sprintf(szExpression,
-                                "([pixel] >= %d AND [pixel] < %d)",
-                                atoi(pszPreviousQuality),
-                                atoi(pszQuantity));
+
+                       /* pszQuantity and pszPreviousQuality may be integer or 
float */
+                       pchPrevious=strchr(pszPreviousQuality,'.');
+                       pch=strchr(pszQuantity,'.');
+                       if (pchPrevious==NULL && pch==NULL) {
+                         sprintf(szExpression,
+                                 "([pixel] >= %d AND [pixel] < %d)",
+                                 atoi(pszPreviousQuality),
+                                 atoi(pszQuantity));
+                       } else if (pchPrevious != NULL && pch==NULL) {
+                         sprintf(szExpression,
+                                 "([pixel] >= %f AND [pixel] < %d)",
+                                 atof(pszPreviousQuality),
+                                 atoi(pszQuantity));
+                       } else if (pchPrevious == NULL && pch != NULL) {
+                         sprintf(szExpression,
+                                 "([pixel] >= %d AND [pixel] < %f)",
+                                 atoi(pszPreviousQuality),
+                                 atof(pszQuantity));
+                       } else {
+                         sprintf(szExpression,
+                                 "([pixel] >= %f AND [pixel] < %f)",
+                                 atof(pszPreviousQuality),
+                                 atof(pszQuantity));
+                       }
+
                         if (psLayer->numclasses < MS_MAXCLASSES)
                         {
                             initClass(&(psLayer->class[psLayer->numclasses]));
@@ -2456,7 +2479,15 @@
                 sColor.red = hex2int(pszColor+1);
                 sColor.green= hex2int(pszColor+3);
                 sColor.blue = hex2int(pszColor+5);
-                sprintf(szExpression, "([pixel] = %d)", atoi(pszQuantity));
+
+               /* pszQuantity may be integer or float */
+               pch=strchr(pszQuantity,'.');
+               if (pch==NULL) {
+                 sprintf(szExpression, "([pixel] = %d)", atoi(pszQuantity));
+               } else {
+                 sprintf(szExpression, "([pixel] = %f)", atof(pszQuantity));
+               }
+
                 if (psLayer->numclasses < MS_MAXCLASSES)
                 {
                     initClass(&(psLayer->class[psLayer->numclasses]));


Rob


--
Bart van den Eijnden
OSGIS, Open Source GIS
http://www.osgis.nl

Reply via email to