#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)
Change History (3)
by , 14 years ago
Attachment: | gdal_grid_out_of_range.patch added |
---|
comment:1 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 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.
Even,
Thanks for the patch, clamping is certainly required here. I have applied the slightly modified patch with r18040.
Best regards, Andrey