]> granicus.if.org Git - postgis/commitdiff
Updated tests for 'dog-ate-my-homework' test. Expanded comments and elaborated on...
authorDavid Zwarg <dzwarg@azavea.com>
Wed, 30 Nov 2011 16:45:54 +0000 (16:45 +0000)
committerDavid Zwarg <dzwarg@azavea.com>
Wed, 30 Nov 2011 16:45:54 +0000 (16:45 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8261 b70326c6-7e19-0410-871a-916f4a2858ee

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

index 77d4f49040a0bd05c31cf69d4c219c473bf8670a..1f8452704aa5d93a626b54ea1486b773c09de6b2 100644 (file)
@@ -9558,7 +9558,8 @@ Datum RASTER_mapAlgebraFctNgb(PG_FUNCTION_ARGS)
                                 /* Replace the NODATA value with the currently processing pixel. */
                                 neighborData[nIndex] = Float8GetDatum((double)rpix);
                                 neighborNulls[nIndex] = false;
-                                /* do not increment nNullItems */
+                                /* do not increment nNullItems, since the user requested that the  */
+                                /* neighborhood replace NODATA values with the central pixel value */
                             }
                             else {
                                 neighborData[nIndex] = PointerGetDatum(NULL);
@@ -9582,7 +9583,9 @@ Datum RASTER_mapAlgebraFctNgb(PG_FUNCTION_ARGS)
              * We compute a value only for the withdata value neighborhood since the
              * nodata value has already been set by the first optimization
              **/
-            if (!nNodataOnly && !(nNullSkip && nNullItems > 0) && !(valuereplace && nNullItems > 0)) {
+            if (!(nNodataOnly ||                     /* neighborhood only contains NODATA -- OR -- */
+                (nNullSkip && nNullItems > 0) ||     /* neighborhood should skip any NODATA cells, and a NODATA cell was detected -- OR -- */
+                (valuereplace && nNullItems > 0))) { /* neighborhood should replace NODATA cells with the central pixel value, and a NODATA cell was detected */
                 POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: (%dx%d), %dx%d neighborhood",
                     x, y, winwidth, winheight);
 
index c650965293b30d2e47905fb577904c166fd160a8..ec59d8486950f57bc340ad2ccd8ca670d19ba60e 100644 (file)
@@ -222,3 +222,12 @@ SELECT
     ST_MapAlgebraFctNgb(rast, 1, NULL, 1, 1, 'ST_Nullage(float[][], text, text[])'::regprocedure, 'NULL', NULL), 2, 2
   ) IS NULL
  FROM ST_TestRasterNgb(3, 3, 2) AS rast;
+
+-- 'dog ate my homework' test
+-- raster initialized to one NODATA value, then a literal value passed in as the 'nodatamode' parameter.
+-- 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
+  ) = 200
+FROM ST_SetValue(ST_SetBandNoDataValue(ST_TestRasterNgb(3, 3, 10), 0), 2, 2, 0) AS rast;
index 700c414d7e51e01f14aa57cf1b0190f4034fff39..f6969b12d42e0c20ea870cb57ad6b26e45610984 100644 (file)
@@ -63,3 +63,4 @@ NOTICE:  SRID value -1 converted to the officially unknown SRID value 0
 NOTICE:  SRID value -1 converted to the officially unknown SRID value 0
 t|t|t
 t|t
+t