Commit 7b9283b8 authored by Darafei Praliaskouski's avatar Darafei Praliaskouski

Fix raster regression on Raspberry Pi.

A signed NODATA value was assigned to unsigned variable.
On Intel that was reversible, on ARM and PPC it replaced all negatives with 0.

Thanks to Alina Dolgikh for supporting me: https://www.patreon.com/komzpa

Closes #4102
Closes https://github.com/postgis/postgis/pull/276


git-svn-id: http://svn.osgeo.org/postgis/trunk@16661 b70326c6-7e19-0410-871a-916f4a2858ee
parent e0905c13
Pipeline #26271829 passed with stage
in 22 minutes and 8 seconds
......@@ -151,13 +151,13 @@ rt_pixtype_get_min_value(rt_pixtype pixtype) {
return (double) rt_util_clamp_to_1BB((double) CHAR_MIN);
}
case PT_2BUI: {
return (double) rt_util_clamp_to_2BUI((double) CHAR_MIN);
return 0;
}
case PT_4BUI: {
return (double) rt_util_clamp_to_4BUI((double) CHAR_MIN);
return 0;
}
case PT_8BUI: {
return (double) rt_util_clamp_to_8BUI((double) CHAR_MIN);
return 0;
}
case PT_8BSI: {
return (double) rt_util_clamp_to_8BSI((double) SCHAR_MIN);
......@@ -166,13 +166,13 @@ rt_pixtype_get_min_value(rt_pixtype pixtype) {
return (double) rt_util_clamp_to_16BSI((double) SHRT_MIN);
}
case PT_16BUI: {
return (double) rt_util_clamp_to_16BUI((double) SHRT_MIN);
return 0;
}
case PT_32BSI: {
return (double) rt_util_clamp_to_32BSI((double) INT_MIN);
}
case PT_32BUI: {
return (double) rt_util_clamp_to_32BUI((double) INT_MIN);
return 0;
}
case PT_32BF: {
return (double) -FLT_MAX;
......
......@@ -629,14 +629,24 @@ rt_raster_serialize(rt_raster raster) {
ptr += 1;
break;
}
case PT_16BSI:
case PT_16BSI: {
int16_t v = band->nodataval;
memcpy(ptr, &v, 2);
ptr += 2;
break;
}
case PT_16BUI: {
uint16_t v = band->nodataval;
memcpy(ptr, &v, 2);
ptr += 2;
break;
}
case PT_32BSI:
case PT_32BSI: {
int32_t v = band->nodataval;
memcpy(ptr, &v, 4);
ptr += 4;
break;
}
case PT_32BUI: {
uint32_t v = band->nodataval;
memcpy(ptr, &v, 4);
......
......@@ -592,14 +592,24 @@ rt_raster_to_wkb(rt_raster raster, int outasin, uint32_t *wkbsize) {
ptr += 1;
break;
}
case PT_16BSI:
case PT_16BSI: {
int16_t v = band->nodataval;
memcpy(ptr, &v, 2);
ptr += 2;
break;
}
case PT_16BUI: {
uint16_t v = band->nodataval;
memcpy(ptr, &v, 2);
ptr += 2;
break;
}
case PT_32BSI:
case PT_32BSI: {
int32_t v = band->nodataval;
memcpy(ptr, &v, 4);
ptr += 4;
break;
}
case PT_32BUI: {
uint32_t v = band->nodataval;
memcpy(ptr, &v, 4);
......
......@@ -117,3 +117,7 @@ SET client_min_messages TO DEFAULT;
#3055 ST_Clip() on a raster without band crashes the server
******************************************************************************/
SELECT ST_SummaryStats(ST_Clip(ST_MakeEmptyRaster(42, 42, 0, 0, 1.0, 1.0, 0, 0, 4269), ST_MakeEnvelope(0, 0, 20, 20, 4269)));
-- #4102 negative nodata values don't apply on Raspberry Pi
SELECT '#4102.1', ST_BandNoDataValue(ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 1, -1, 0, 0, 0), 1, '16BSI', 0, -10), 1) AS rast;
SELECT '#4102.2', ST_BandNoDataValue(ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 1, -1, 0, 0, 0), 1, '32BSI', 0, -10), 1) AS rast;
......@@ -14,3 +14,5 @@ test_raster_scale_small|rast||1
ERROR: new row for relation "test_raster_scale_small" violates check constraint "enforce_scaley_rast"
NOTICE: Input raster is empty or has no bands. Returning empty raster
NOTICE: Invalid band index (must use 1-based). Returning NULL
#4102.1|-10
#4102.2|-10
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment