From: David Zwarg Date: Wed, 30 Nov 2011 16:45:54 +0000 (+0000) Subject: Updated tests for 'dog-ate-my-homework' test. Expanded comments and elaborated on... X-Git-Tag: 2.0.0alpha1~604 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b770bde1473e627b2793d5688e546468ed3833c;p=postgis Updated tests for 'dog-ate-my-homework' test. Expanded comments and elaborated on complex conditionals in ST_MapAlgebraFctNgb git-svn-id: http://svn.osgeo.org/postgis/trunk@8261 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/rt_pg/rt_pg.c b/raster/rt_pg/rt_pg.c index 77d4f4904..1f8452704 100644 --- a/raster/rt_pg/rt_pg.c +++ b/raster/rt_pg/rt_pg.c @@ -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); diff --git a/raster/test/regress/rt_mapalgebrafctngb.sql b/raster/test/regress/rt_mapalgebrafctngb.sql index c65096529..ec59d8486 100644 --- a/raster/test/regress/rt_mapalgebrafctngb.sql +++ b/raster/test/regress/rt_mapalgebrafctngb.sql @@ -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; diff --git a/raster/test/regress/rt_mapalgebrafctngb_expected b/raster/test/regress/rt_mapalgebrafctngb_expected index 700c414d7..f6969b12d 100644 --- a/raster/test/regress/rt_mapalgebrafctngb_expected +++ b/raster/test/regress/rt_mapalgebrafctngb_expected @@ -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