]> granicus.if.org Git - postgis/commitdiff
Added additional tests for ST_MapAlgebraFctNgb, changed string compare on nodatamode...
authorDavid Zwarg <dzwarg@azavea.com>
Wed, 30 Nov 2011 14:51:33 +0000 (14:51 +0000)
committerDavid Zwarg <dzwarg@azavea.com>
Wed, 30 Nov 2011 14:51:33 +0000 (14:51 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8260 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rt_pg.c
raster/test/regress/rt_mapalgebrafctngb.sql
raster/test/regress/rt_mapalgebrafctngb_expected

index da5712b301f84e242171e0aae93e2784607ad8de..77d4f49040a0bd05c31cf69d4c219c473bf8670a 100644 (file)
@@ -9478,7 +9478,7 @@ Datum RASTER_mapAlgebraFctNgb(PG_FUNCTION_ARGS)
 
     if (strcmp(strFromText, "VALUE") == 0)
         valuereplace = true;
-    else if (strcmp(strFromText, "IGNORE") < 0 && strcmp(strFromText, "NULL") < 0) {
+    else if (strcmp(strFromText, "IGNORE") != 0 && strcmp(strFromText, "NULL") != 0) {
         // if the text is not "IGNORE" or "NULL", it may be a numerical value
         if (sscanf(strFromText, "%d", &intReplace) <= 0 && sscanf(strFromText, "%f", &fltReplace) <= 0) {
             // the value is NOT an integer NOR a floating point
index 9cb0731987a5f3914a560d54d594d324f54654de..c650965293b30d2e47905fb577904c166fd160a8 100644 (file)
@@ -91,6 +91,22 @@ SELECT
   ) = 0
  FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 2, 2, NULL) AS rast;
 
+-- Test value nodatamode. Should return null and 128.
+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
+  ) = 128
+ FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 2, 2, NULL) AS rast;
+
+-- Test value nodatamode. Should return null and null.
+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
+  ) IS NULL
+ FROM ST_SetValue(ST_TestRasterNgb(3, 3, 1), 2, 2, NULL) AS rast;
+
 -- Test ST_Sum user function. Should be 1 and 9.
 SELECT 
   ST_Value(rast, 2, 2) = 1, 
index 1994669518667e15848233ba25be2e16b5ccfe9b..700c414d7e51e01f14aa57cf1b0190f4034fff39 100644 (file)
@@ -18,6 +18,9 @@ t|t
 t|t
 t|t
 t|t
+NOTICE:  Neighborhood NODATA mode is not recognized. Must be one of 'value', 'ignore', 'NULL', or a numeric value. Returning new raster with the original band
+t|t
+t|t
 t|t
 t|t
 t|t