From: Bborie Park Date: Thu, 26 May 2011 21:35:33 +0000 (+0000) Subject: Added default parameter for ST_Band and reduced function count by 1. X-Git-Tag: 2.0.0alpha1~1555 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=56f19b364ee6d3a95e69112711c1140483907713;p=postgis Added default parameter for ST_Band and reduced function count by 1. Added additional regression tests for ST_Band. git-svn-id: http://svn.osgeo.org/postgis/trunk@7259 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/rt_pg/rtpostgis.sql.in.c b/raster/rt_pg/rtpostgis.sql.in.c index ba8641be3..a80d6d037 100644 --- a/raster/rt_pg/rtpostgis.sql.in.c +++ b/raster/rt_pg/rtpostgis.sql.in.c @@ -233,7 +233,7 @@ CREATE OR REPLACE FUNCTION st_addband(torast raster, fromrast raster) ----------------------------------------------------------------------- -- Constructor ST_Band ----------------------------------------------------------------------- -CREATE OR REPLACE FUNCTION st_band(rast raster, nbands int[]) +CREATE OR REPLACE FUNCTION st_band(rast raster, nbands int[] default ARRAY[1]) RETURNS RASTER AS 'MODULE_PATHNAME', 'RASTER_band' LANGUAGE 'C' IMMUTABLE STRICT; @@ -253,11 +253,6 @@ CREATE OR REPLACE FUNCTION st_band(rast raster, nbands text, delimiter char) AS $$ SELECT st_band($1, regexp_split_to_array(regexp_replace($2, '[[:space:]]', '', 'g'), $3)::int[]) $$ LANGUAGE 'SQL' IMMUTABLE STRICT; -CREATE OR REPLACE FUNCTION st_band(rast raster) - RETURNS RASTER - AS $$ SELECT st_band($1, ARRAY[1]) $$ - LANGUAGE 'SQL' IMMUTABLE STRICT; - ----------------------------------------------------------------------- -- ST_SummaryStats and ST_ApproxSummaryStats ----------------------------------------------------------------------- diff --git a/raster/test/regress/rt_band.sql b/raster/test/regress/rt_band.sql index 3f4825a26..c3d7b90a0 100644 --- a/raster/test/regress/rt_band.sql +++ b/raster/test/regress/rt_band.sql @@ -165,6 +165,50 @@ SELECT ST_Value( ARRAY[1,1] ), 2, 3, 3); +SELECT ST_Value( + ST_Band( + ST_AddBand( + ST_AddBand( + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0,-1) + , 1, '64BF', 1234.5678, NULL + ) + , '64BF', 987.654321, NULL + ) + , '64BF', 9876.54321, NULL + ), + '1,1' + ), +2, 3, 3); +SELECT ST_Value( + ST_Band( + ST_AddBand( + ST_AddBand( + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0,-1) + , 1, '64BF', 1234.5678, NULL + ) + , '64BF', 987.654321, NULL + ) + , '64BF', 9876.54321, NULL + ), + '1;1', ';' + ), +2, 3, 3); +SELECT ST_Value( + ST_Band( + ST_AddBand( + ST_AddBand( + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0,-1) + , 1, '64BF', 1234.5678, NULL + ) + , '64BF', 987.654321, NULL + ) + , '64BF', 9876.54321, NULL + ) + ), +1, 3, 3); SELECT ST_NumBands( ST_Band( ST_AddBand( diff --git a/raster/test/regress/rt_band_expected b/raster/test/regress/rt_band_expected index ed11fccf2..bac65ae09 100644 --- a/raster/test/regress/rt_band_expected +++ b/raster/test/regress/rt_band_expected @@ -12,6 +12,9 @@ 9876.54321 987.654321 1234.5678 +1234.5678 +1234.5678 +1234.5678 4 3 2