[postgis-tickets] r16661 - Fix raster regression on Raspberry Pi.
Darafei
komzpa at gmail.com
Sun Jul 22 05:17:50 PDT 2018
Author: komzpa
Date: 2018-07-22 17:17:50 -0700 (Sun, 22 Jul 2018)
New Revision: 16661
Modified:
trunk/raster/rt_core/rt_pixel.c
trunk/raster/rt_core/rt_serialize.c
trunk/raster/rt_core/rt_wkb.c
trunk/raster/test/regress/tickets.sql
trunk/raster/test/regress/tickets_expected
Log:
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
Modified: trunk/raster/rt_core/rt_pixel.c
===================================================================
--- trunk/raster/rt_core/rt_pixel.c 2018-07-22 12:22:27 UTC (rev 16660)
+++ trunk/raster/rt_core/rt_pixel.c 2018-07-23 00:17:50 UTC (rev 16661)
@@ -151,13 +151,13 @@
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 @@
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;
Modified: trunk/raster/rt_core/rt_serialize.c
===================================================================
--- trunk/raster/rt_core/rt_serialize.c 2018-07-22 12:22:27 UTC (rev 16660)
+++ trunk/raster/rt_core/rt_serialize.c 2018-07-23 00:17:50 UTC (rev 16661)
@@ -629,7 +629,12 @@
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);
@@ -636,7 +641,12 @@
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);
Modified: trunk/raster/rt_core/rt_wkb.c
===================================================================
--- trunk/raster/rt_core/rt_wkb.c 2018-07-22 12:22:27 UTC (rev 16660)
+++ trunk/raster/rt_core/rt_wkb.c 2018-07-23 00:17:50 UTC (rev 16661)
@@ -592,7 +592,12 @@
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);
@@ -599,7 +604,12 @@
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);
Modified: trunk/raster/test/regress/tickets.sql
===================================================================
--- trunk/raster/test/regress/tickets.sql 2018-07-22 12:22:27 UTC (rev 16660)
+++ trunk/raster/test/regress/tickets.sql 2018-07-23 00:17:50 UTC (rev 16661)
@@ -117,3 +117,7 @@
#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;
Modified: trunk/raster/test/regress/tickets_expected
===================================================================
--- trunk/raster/test/regress/tickets_expected 2018-07-22 12:22:27 UTC (rev 16660)
+++ trunk/raster/test/regress/tickets_expected 2018-07-23 00:17:50 UTC (rev 16661)
@@ -14,3 +14,5 @@
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
More information about the postgis-tickets
mailing list