-- Tests
-- Test NULL Raster. Should be true.
-SELECT ST_MapAlgebraFctNgb(NULL, 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL) IS NULL FROM ST_TestRasterNgb(0, 0, -1) rast;
+SELECT ST_MapAlgebraFctNgb(NULL, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL) IS NULL FROM ST_TestRasterNgb(0, 0, -1) rast;
-- Test empty Raster. Should be true.
-SELECT ST_IsEmpty(ST_MapAlgebraFctNgb(ST_MakeEmptyRaster(0, 10, 0, 0, 1, 1, 1, 1, -1), 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL));
+SELECT ST_IsEmpty(ST_MapAlgebraFctNgb(ST_MakeEmptyRaster(0, 10, 0, 0, 1, 1, 1, 1, -1), 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL));
-- 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));
+SELECT ST_HasNoBand(ST_MapAlgebraFctNgb(ST_MakeEmptyRaster(10, 10, 0, 0, 1, 1, 1, 1, -1), 1, NULL, 1, 1, 'ST_Sum4ma(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
+ rast, 1, NULL, 5, 5, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL
), 2, 2) = 1
FROM ST_TestRasterNgb(3, 3, 1) AS rast;
ST_Value(rast, 2, 2) = 1,
ST_Value(
ST_MapAlgebraFctNgb(
- rast, 1, NULL, -1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL
+ rast, 1, NULL, -1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL
), 2, 2) = 1
FROM ST_TestRasterNgb(3, 3, 1) AS rast;
ST_Value(rast, 2, 2) = 1,
ST_Value(
ST_MapAlgebraFctNgb(
- rast, 1, NULL, 1, -1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL
+ rast, 1, NULL, 1, -1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL
), 2, 2) = 1
FROM ST_TestRasterNgb(3, 3, 1) AS rast;
ST_Value(rast, 2, 2) IS NULL,
ST_Value(
ST_MapAlgebraFctNgb(
- ST_SetBandNoDataValue(rast, NULL), 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL
+ ST_SetBandNoDataValue(rast, NULL), 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL
), 2, 2) = 7
FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 2, 2, NULL) AS rast;
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
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL), 2, 2
) IS NULL
FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 2, 2, NULL) AS rast;
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
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, NULL, NULL), 2, 2
) = 8
FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 2, 2, NULL) AS rast;
SELECT
ST_Value(rast, 2, 2) IS NULL,
ST_Value(
- ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'ignore', NULL), 2, 2
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'ignore', NULL), 2, 2
) = 8
FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 2, 2, NULL) AS rast;
SELECT
ST_Value(rast, 2, 2) IS NULL,
ST_Value(
- ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'value', NULL), 2, 2
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'value', NULL), 2, 2
) IS NULL
FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 2, 2, NULL) AS rast;
SELECT
ST_Value(rast, 1, 1) IS NULL,
ST_Value(
- ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'value', NULL), 2, 2
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'value', NULL), 2, 2
) = 9
FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 1, 1, NULL) AS rast;
SELECT
ST_Value(rast, 2, 2) IS NULL,
ST_Value(
- ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, '-8', NULL), 2, 2
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, '-8', NULL), 2, 2
) = 0
FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 2, 2, NULL) AS rast;
SELECT
ST_Value(rast, 2, 2) IS NULL,
ST_Value(
- ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, '120', NULL), 2, 2
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, '120', NULL), 2, 2
) = 128
FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 2, 2, NULL) AS rast;
SELECT
ST_Value(rast, 2, 2) IS NULL,
ST_Value(
- ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'abcd', NULL), 2, 2
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'abcd', NULL), 2, 2
) IS NULL
FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 2, 2, NULL) AS rast;
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
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL), 2, 2
) = 9
FROM ST_TestRasterNgb(3, 3, 1) AS rast;
SELECT
ST_Value(rast, 2, 2) IS NULL,
ST_Value(
- ST_MapAlgebraFctNgb(ST_SetBandNoDataValue(rast, NULL), 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL), 2, 2
+ ST_MapAlgebraFctNgb(ST_SetBandNoDataValue(rast, NULL), 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL), 2, 2
) = -1
FROM ST_SetValue(ST_TestRasterNgb(3, 3, 0), 2, 2, NULL) AS rast;
SELECT
ST_Value(rast, 2, 2) = 2,
ST_Value(
- ST_MapAlgebraFctNgb(rast, 1, '4BUI', 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL), 2, 2
+ ST_MapAlgebraFctNgb(rast, 1, '4BUI', 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL), 2, 2
) = 15
FROM ST_SetBandNoDataValue(ST_TestRasterNgb(3, 3, 2), 1, NULL) AS rast;
SELECT
ST_Value(rast, 2, 2) = 2,
ST_Value(
- ST_MapAlgebraFctNgb(rast, 1, '4BUId', 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL), 2, 2
+ ST_MapAlgebraFctNgb(rast, 1, '4BUId', 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL), 2, 2
) = 18
FROM ST_TestRasterNgb(3, 3, 2) AS rast;
SELECT
ST_Value(rast, 2, 2) = 1,
ST_Value(
- ST_MapAlgebraFctNgb(rast, 1, '2BUI', 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL), 2, 2
+ ST_MapAlgebraFctNgb(rast, 1, '2BUI', 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL), 2, 2
) = 3
FROM ST_SetBandNoDataValue(ST_TestRasterNgb(3, 3, 1), 1, NULL) AS rast;
COUNT(*) = 1
FROM (SELECT
(ST_DumpAsPolygons(
- ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL)
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL)
)).*
FROM ST_TestRasterNgb(5, 5, 1) AS rast) AS foo;
ST_Area(geom) = 8, val = 9
FROM (SELECT
(ST_DumpAsPolygons(
- ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL)
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL)
)).*
FROM ST_SetValue(ST_TestRasterNgb(5, 5, 1), 1, 1, NULL) AS rast) AS foo;
(ST_Area(geom) = 1 AND val = 8) OR (ST_Area(geom) = 8 AND val = 9)
FROM (SELECT
(ST_DumpAsPolygons(
- ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'ignore', NULL)
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'ignore', NULL)
)).*
FROM ST_SetValue(ST_TestRasterNgb(5, 5, 1), 1, 1, NULL) AS rast) AS foo;
ST_Area(ST_BuildArea(ST_InteriorRingN(geom, 1))) = 9
FROM (SELECT
(ST_DumpAsPolygons(
- ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL)
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL)
)).*
FROM ST_SetValue(ST_TestRasterNgb(7, 7, 1), 4, 4, NULL) AS rast) AS foo;
FROM (SELECT
(ST_DumpAsPolygons(
ST_MapAlgebraFctNgb(
- ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'ignore', NULL), 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'ignore', NULL
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'ignore', NULL), 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'ignore', NULL
)
)).*
FROM ST_TestRasterNgb(5, 5, 1) AS rast) AS foo;
FROM (SELECT
(ST_DumpAsPolygons(
ST_MapAlgebraFctNgb(
- ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL), 1, NULL, 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, 'NULL', NULL
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL), 1, NULL, 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, 'NULL', NULL
)
)).*
FROM ST_TestRasterNgb(5, 5, 1) AS rast) AS foo;
-- expect that the cells processed by the neighborhoods would be replaced by the 'nodatamode' parameter value, and not NODATA.
SELECT
ST_Value(
- ST_MapAlgebraFctNgb(rast, 1, '8BUI', 1, 1, 'ST_Sum(float[][], text, text[])'::regprocedure, '120', NULL), 2, 2
+ ST_MapAlgebraFctNgb(rast, 1, '8BUI', 1, 1, 'ST_Sum4ma(float[][], text, text[])'::regprocedure, '120', NULL), 2, 2
) = 200
FROM ST_SetValue(ST_SetBandNoDataValue(ST_TestRasterNgb(3, 3, 10), 0), 2, 2, 0) AS rast;
--- /dev/null
+-- test st_max4ma, uniform values
+SELECT
+ ST_Value(rast, 2, 2) = 1,
+ ST_Value(
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'st_max4ma(float[][], text, text[])'::regprocedure, NULL, NULL), 2, 2
+ ) = 1
+ FROM ST_TestRasterNgb(3, 3, 1) AS rast;
+
+-- test st_max4ma, obvious max value
+SELECT
+ ST_Value(rast, 2, 2) = 1,
+ ST_Value(
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'st_max4ma(float[][], text, text[])'::regprocedure, NULL, NULL), 2, 2
+ ) = 11
+ FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 1, 1, 11) AS rast;
+
+-- test st_max4ma, value substitution
+SELECT
+ ST_Value(rast, 2, 2) = 1,
+ ST_Value(
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'st_max4ma(float[][], text, text[])'::regprocedure, '22', NULL), 2, 2
+ ) = 22
+ FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 3, 3, NULL) AS rast;
+
+-- test st_min4ma, uniform values
+SELECT
+ ST_Value(rast, 2, 2) = 1,
+ ST_Value(
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'st_min4ma(float[][], text, text[])'::regprocedure, NULL, NULL), 2, 2
+ ) = 1
+ FROM ST_TestRasterNgb(3, 3, 1) AS rast;
+
+-- test st_min4ma, obvious min value
+SELECT
+ ST_Value(rast, 2, 2) = 11,
+ ST_Value(
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'st_min4ma(float[][], text, text[])'::regprocedure, NULL, NULL), 2, 2
+ ) = 1
+ FROM ST_SetValue(ST_TestRasterNgb(3, 3, 11), 1, 1, 1) AS rast;
+
+-- test st_min4ma, value substitution
+SELECT
+ ST_Value(rast, 2, 2) = 22,
+ ST_Value(
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'st_min4ma(float[][], text, text[])'::regprocedure, '2', NULL), 2, 2
+ ) = 2
+ FROM ST_SetValue(ST_TestRasterNgb(3, 3, 22), 3, 3, NULL) AS rast;
+
+-- test st_sum4ma happens in rt_mapalgebrafctngb.sql
+
+-- test st_mean4ma, uniform values
+SELECT
+ ST_Value(rast, 2, 2) = 1,
+ ST_Value(
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'st_mean4ma(float[][], text, text[])'::regprocedure, NULL, NULL), 2, 2
+ ) = 1
+ FROM ST_TestRasterNgb(3, 3, 1) AS rast;
+
+-- test st_mean4ma, obvious min value
+SELECT
+ ST_Value(rast, 2, 2) = 10,
+ ST_Value(
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'st_mean4ma(float[][], text, text[])'::regprocedure, NULL, NULL), 2, 2
+ ) = 9
+ FROM ST_SetValue(ST_TestRasterNgb(3, 3, 10), 1, 1, 1) AS rast;
+
+-- test st_mean4ma, value substitution
+SELECT
+ ST_Value(rast, 2, 2) = 10,
+ ST_Value(
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'st_mean4ma(float[][], text, text[])'::regprocedure, '1', NULL), 2, 2
+ ) = 9
+ FROM ST_SetValue(ST_TestRasterNgb(3, 3, 10), 3, 3, NULL) AS rast;
+
+-- test st_range4ma, uniform values
+SELECT
+ ST_Value(rast, 2, 2) = 1,
+ ST_Value(
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'st_range4ma(float[][], text, text[])'::regprocedure, NULL, NULL), 2, 2
+ ) = 0
+ FROM ST_TestRasterNgb(3, 3, 1) AS rast;
+
+-- test st_range4ma, obvious min value
+SELECT
+ ST_Value(rast, 2, 2) = 10,
+ ST_Value(
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'st_range4ma(float[][], text, text[])'::regprocedure, NULL, NULL), 2, 2
+ ) = 9
+ FROM ST_SetValue(ST_TestRasterNgb(3, 3, 10), 1, 1, 1) AS rast;
+
+-- test st_range4ma, value substitution
+SELECT
+ ST_Value(rast, 2, 2) = 10,
+ ST_Value(
+ ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'st_range4ma(float[][], text, text[])'::regprocedure, '1', NULL), 2, 2
+ ) = 9
+ FROM ST_SetValue(ST_TestRasterNgb(3, 3, 10), 3, 3, NULL) AS rast;
+