From 2b92d738cdf298804558df13f4dbba4f0af6a17b Mon Sep 17 00:00:00 2001 From: Bborie Park Date: Fri, 3 Aug 2012 19:43:16 +0000 Subject: [PATCH] Added missing variant of ST_SetValues without nband parameter. git-svn-id: http://svn.osgeo.org/postgis/trunk@10158 b70326c6-7e19-0410-871a-916f4a2858ee --- doc/reference_raster.xml | 15 +++++++++++++++ raster/rt_pg/rtpostgis.sql.in.c | 22 +++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/doc/reference_raster.xml b/doc/reference_raster.xml index 3ff1a23d9..8e17439c0 100644 --- a/doc/reference_raster.xml +++ b/doc/reference_raster.xml @@ -4036,6 +4036,17 @@ GROUP BY (foo.geomval).val; boolean keepnodata=FALSE + + raster ST_SetValues + raster rast + integer columnx + integer rowy + integer width + integer height + double precision newvalue + boolean keepnodata=FALSE + + @@ -4053,6 +4064,10 @@ GROUP BY (foo.geomval).val; For variant 2, the specific pixels to be set are determined by the columnx, rowy pixel coordinates, width and height. If keepnodata is TRUE, those pixels whose values are NODATA will not be set with the corresponding value in newvalueset. See example Variant 2. + + Variant 3 is the same as Variant 2 with the exception that it assumes that the first band's pixels of rast will be set. + + diff --git a/raster/rt_pg/rtpostgis.sql.in.c b/raster/rt_pg/rtpostgis.sql.in.c index e3c5622bd..a64236584 100644 --- a/raster/rt_pg/rtpostgis.sql.in.c +++ b/raster/rt_pg/rtpostgis.sql.in.c @@ -2929,7 +2929,27 @@ CREATE OR REPLACE FUNCTION st_setvalues( RAISE EXCEPTION 'Values for width and height must be greater than zero'; RETURN NULL; END IF; - RETURN st_setvalues($1, $2, $3, $4, array_fill(newvalue::double precision, ARRAY[height, width]::int[]), NULL, $8); + RETURN st_setvalues($1, $2, $3, $4, array_fill($7, ARRAY[$6, $5]::int[]), NULL, $8); + END; + $$ + LANGUAGE 'plpgsql' IMMUTABLE; + +-- cannot be STRICT as newvalue can be NULL +CREATE OR REPLACE FUNCTION st_setvalues( + rast raster, + x integer, y integer, + width integer, height integer, + newvalue double precision, + keepnodata boolean DEFAULT FALSE +) + RETURNS raster AS + $$ + BEGIN + IF width <= 0 OR height <= 0 THEN + RAISE EXCEPTION 'Values for width and height must be greater than zero'; + RETURN NULL; + END IF; + RETURN st_setvalues($1, 1, $2, $3, array_fill($6, ARRAY[$5, $4]::int[]), NULL, $7); END; $$ LANGUAGE 'plpgsql' IMMUTABLE; -- 2.40.0