Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#3211 closed defect (fixed)

[PATCH] Clamp output values to the bounds of the output buffer

Reported by: Even Rouault Owned by: dron
Priority: normal Milestone:
Component: Algorithms Version: unspecified
Severity: normal Keywords:
Cc:

Description

Andrey,

attached you'll find a patch for GDALGridCreate() that clamps the value of the dfValue returned by pfnGDALGridMethod() to the validity range of the output type. I'm not sure if this is really needed in real-word situations but I could get out of range output being casted to improper values in the following scenario.

For example, if you have the following test.csv :

WKT,z
POINT(0 0),-32768
POINT(2 2),32767

And you try :

gdal_grid -ot Int16 -a range test.csv grid.tif -l test -zfield z

the expected value is 32767-(-32768)=65535. Without the patch you'd get -32768. With the patch, you get 32767.

Attachments (1)

gdal_grid_out_of_range.patch (2.9 KB ) - added by Even Rouault 14 years ago.

Download all attachments as: .zip

Change History (3)

by Even Rouault, 14 years ago

comment:1 by dron, 14 years ago

Resolution: fixed
Status: newclosed

Even,

Thanks for the patch, clamping is certainly required here. I have applied the slightly modified patch with r18040.

Best regards, Andrey

comment:2 by dron, 14 years ago

After a bit of thinking on this issue I've used a different approach utilizing the GDALCopyWords() function. See the r18041.

Best regards, Andrey.

Note: See TracTickets for help on using tickets.