[postgis-devel] [wktraster] Core tests failure for r5841
Mateusz Loskot
mateusz at loskot.net
Thu Jan 13 16:27:10 PST 2011
Pierre,
Sorry, I forgot.
I think there is no need to trunc()
--
Mateusz Ĺoskot, http://mateusz.loskot.net
(Sent from my mobile)
----- Reply message -----
From: "Pierre Racine" <Pierre.Racine at sbf.ulaval.ca>
Date: Thu, Jan 13, 2011 23:56
Subject: [postgis-devel] [wktraster] Core tests failure for r5841
To: "Mateusz Loskot" <mateusz at loskot.net>
Cc: "PostGIS Development Discussion" <postgis-devel at postgis.refractions.net>, "strk" <strk at keybit.net>
Ok. good. Nobody answered the question about if we need to trunc before clamping...
>-----Original Message-----
>From: Mateusz Loskot [mailto:mateusz at loskot.net]
>Sent: 13 janvier 2011 18:54
>To: Pierre Racine
>Cc: PostGIS Development Discussion; strk
>Subject: Re: [postgis-devel] [wktraster] Core tests failure for r5841
>
>On 13/01/11 18:49, Pierre Racine wrote:
>>> This is one of number of places where the problem exists.
>>> Others are rt_band_set_pixel, rt_band_set_nodata, and generally
>>> in any place where double is implicitly or explicitly squeezed in
>>> integral types.
>>
>> I agree the solution should be apply for rt_band_set_pixel and rt_band_set_nodata.
>>
>> Does everybody is happy with my code snippet implementing MIN/MAX?
>
>Pierre,
>
>The idea is good. Though, I would suggest to follow Sandro's suggestion
>to wrap it with reusable macros / functions. Spreading such branching
>and spreading in number of places yet injected in switch case statement
>will make the code an epic poetry, unnecessarily.
>
>Following <stdint.h> type names we operate in the code, we could have
>
>clamp_int16
>clamp_uint16
>clamp_int32
>clamp_uint32
>...
>
>If we are happy to use C99/POSIX, then we can simplify the branching
>
>int16_t clamp_int16(double value)
>{
> return (int16_t)fmin(fmax((value), SHRT_MIN), SHRT_MAX);
>}
>
>uint16_t clamp_uint16(double value)
>{
> return (uint16_t)fmin(fmax((value), USHRT_MIN), USHRT_MAX);
>}
>
>Then, in code the intentions are explicit and clear:
>
> case PT_16BSI:
> {
> int16_t *ptr = mem;
>
> for (i = 0; i < numval; i++)
> ptr[i] = clamp_int16_t(initialvalue);
> checkvalint = ptr[0];
> break;
> }
>
>
>Best regards,
>--
>Mateusz Loskot, http://mateusz.loskot.net
>Charter Member of OSGeo, http://osgeo.org
>Member of ACCU, http://accu.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20110114/027026cd/attachment.html>
More information about the postgis-devel
mailing list