patch for SLD (vs. 4.8.3)

Yewondwossen Assefa assefa at DMSOLUTIONS.CA
Fri Sep 15 06:48:55 EDT 2006


Hi,

  I have added a bug 1914 
(http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=1914). I will commit 
the chanhes before the 4.10.0 release.

Thanks

Rob Cermak wrote:
> 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


-- 
----------------------------------------------------------------
Assefa Yewondwossen
Software Analyst

Email: assefa at dmsolutions.ca
http://www.dmsolutions.ca/

Phone: (613) 565-5056 (ext 14)
Fax:   (613) 565-0925
----------------------------------------------------------------



More information about the mapserver-users mailing list