]> granicus.if.org Git - postgis/commitdiff
Fix for ticket #1569. ST_Clip variants defaulting to band 1 should default to NULL...
authorPierre Racine <Pierre.Racine@sbf.ulaval.ca>
Fri, 10 Feb 2012 22:36:14 +0000 (22:36 +0000)
committerPierre Racine <Pierre.Racine@sbf.ulaval.ca>
Fri, 10 Feb 2012 22:36:14 +0000 (22:36 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9152 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rtpostgis.sql.in.c

index fd7472df0fd4553ce5bbb1258307814c643b3755..21bebbda43ca1a955f9c73e41ba2058a1be229b3 100644 (file)
@@ -3469,7 +3469,7 @@ CREATE AGGREGATE ST_Union(raster, integer, text) (
 --
 -- rast   - raster to be clipped
 -- band   - limit the result to only one band
--- geom   - geometry defining the she to clip the raster
+-- geom   - geometry defining the shape to clip the raster
 -- nodata - define (if there is none defined) or replace the raster nodata value with this value
 -- trimraster - limit the extent of the result to the extent of the geometry
 -- Todo:
@@ -3489,7 +3489,7 @@ CREATE OR REPLACE FUNCTION st_clip(rast raster, band int, geom geometry, nodata
                sourceraster raster := rast;
                newrast raster;
                geomrast raster;
-               numband int := ST_Numbands(rast);
+               numband int;
                bandstart int;
                bandend int;
                newextent text;
@@ -3503,6 +3503,7 @@ CREATE OR REPLACE FUNCTION st_clip(rast raster, band int, geom geometry, nodata
                IF geom IS NULL THEN
                        RETURN rast;
                END IF;
+               numband := ST_Numbands(rast);
                IF band IS NULL THEN
                        bandstart := 1;
                        bandend := numband;
@@ -3541,10 +3542,10 @@ CREATE OR REPLACE FUNCTION st_clip(rast raster, band int, geom geometry, nodata
        END;
        $$ LANGUAGE 'plpgsql' STABLE;
 
--- Variant defaulting to band 1
+-- Variant defaulting to all bands
 CREATE OR REPLACE FUNCTION st_clip(rast raster, geom geometry, nodata float8 DEFAULT NULL, trimraster boolean DEFAULT FALSE)
        RETURNS raster AS
-       $$ SELECT ST_Clip($1, 1, $2, $3, $4) $$
+       $$ SELECT ST_Clip($1, NULL, $2, $3, $4) $$
        LANGUAGE 'SQL' STABLE;
 
 -- Variant defaulting nodata to the one of the raster or the min possible value
@@ -3553,10 +3554,10 @@ CREATE OR REPLACE FUNCTION st_clip(rast raster, band int, geom geometry, trimras
        $$ SELECT ST_Clip($1, $2, $3, null, $4) $$
        LANGUAGE 'SQL' STABLE;
 
--- Variant defaulting nodata to the one of the raster or the min possible value
+-- Variant defaulting nodata to the one of the raster or the min possible value and returning all bands
 CREATE OR REPLACE FUNCTION st_clip(rast raster, geom geometry, trimraster boolean)
        RETURNS raster AS
-       $$ SELECT ST_Clip($1, 1, $2, null, $3) $$
+       $$ SELECT ST_Clip($1, NULL, $2, null, $3) $$
        LANGUAGE 'SQL' STABLE;
 
 ------------------------------------------------------------------------------