/* Get the type of NODATA behavior for the neighborhoods. */
if (PG_ARGISNULL(6)) {
- elog(NOTICE, "Neighborhood NODATA behavior is not specified. Returning new "
- "raster with the original band");
-
- /* Serialize created raster */
- pgraster = rt_raster_serialize(newrast);
- if (NULL == pgraster) {
- elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster. "
- "Returning NULL");
-
- PG_RETURN_NULL();
- }
-
- SET_VARSIZE(pgraster, pgraster->size);
-
- rt_raster_destroy(raster);
- rt_raster_destroy(newrast);
-
- PG_RETURN_POINTER(pgraster);
+ elog(NOTICE, "Neighborhood NODATA behavior defaulting to 'ignore'");
+ txtNodataMode = cstring_to_text("ignore");
+ }
+ else {
+ txtNodataMode = PG_GETARG_TEXT_P(6);
}
-
- txtNodataMode = PG_GETARG_TEXT_P(6);
txtCallbackParam = (text*)palloc(VARSIZE(txtNodataMode));
SET_VARSIZE(txtCallbackParam, VARSIZE(txtNodataMode));
-- Test has no band raster. Should be true
SELECT ST_HasNoBand(ST_MapAlgebraFctNgb(ST_MakeEmptyRaster(10, 10, 0, 0, 1, 1, 1, 1, -1), 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL));
+-- Test huge neighborhood. Original raster returned.
+SELECT
+ ST_Value(rast, 2, 2) = 1,
+ ST_Value(ST_MapAlgebraFctNgb(
+ rast, 1, NULL, 5, 5, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL
+ ), 2, 2) = 1
+ FROM ST_TestRasterNgb(3, 3, 1) AS rast;
+
+-- Test negative width neighborhood. Original raster returned.
+SELECT
+ ST_Value(rast, 2, 2) = 1,
+ ST_Value(
+ ST_MapAlgebraFctNgb(
+ rast, 1, NULL, -1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL
+ ), 2, 2) = 1
+ FROM ST_TestRasterNgb(3, 3, 1) AS rast;
+
+-- Test negative height neighborhood. Original raster returned.
+SELECT
+ ST_Value(rast, 2, 2) = 1,
+ ST_Value(
+ ST_MapAlgebraFctNgb(
+ rast, 1, NULL, 1, -1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL
+ ), 2, 2) = 1
+ FROM ST_TestRasterNgb(3, 3, 1) AS rast;
+
-- Test has no nodata value. Should return null and 7.
SELECT
ST_Value(rast, 2, 2) IS NULL,
) IS NULL
FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 2, 2, NULL) AS rast;
+---- Test default nodatamode (ignore). Should return null and 8.
+SELECT
+ ST_Value(rast, 2, 2) IS NULL,
+ ST_Value(
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, NULL, NULL), 2, 2
+ ) = 8
+ FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 2, 2, NULL) AS rast;
+
---- Test ignore nodatamode. Should return null and 8.
SELECT
ST_Value(rast, 2, 2) IS NULL,