[postgis-devel] [PostGIS] #1938: [raster] Refactor ST_AddBand to add multiple new bands in one call

PostGIS trac at osgeo.org
Fri Jul 27 09:10:29 PDT 2012


#1938: [raster] Refactor ST_AddBand to add multiple new bands in one call
-------------------------+--------------------------------------------------
 Reporter:  dustymugs    |       Owner:  dustymugs    
     Type:  enhancement  |      Status:  new          
 Priority:  medium       |   Milestone:  PostGIS 2.1.0
Component:  raster       |     Version:  trunk        
 Keywords:               |  
-------------------------+--------------------------------------------------
 Currently, the basic ST_AddBand() looks like...

 {{{
 ST_AddBand(
         rast raster,
         index int,
         pixeltype text,
         initialvalue float8 DEFAULT 0.,
         nodataval float8 DEFAULT NULL

 ) -> raster
 }}}

 But the problem is that to add multiple new bands, you have to call
 ST_AddBand many times.  And if the raster has huge dimensions (e.g. 1000 x
 1000) or many bands, the deserializing and serializing of the raster takes
 longer and longer as you add more bands.

 Instead, ST_AddBand should have the ability to add multiple new bands at
 once.  This will require a new data type...

 {{{
 CREATE TYPE addbandarg AS (
         index int,
         pixeltype text,
         initialvalue float8,
         nodataval float8
 );
 }}}

 And a new "main" function...

 {{{
 ST_AddBand(
         rast raster,
         addbandargset addbandarg[]
 ) -> raster
 }}}

 The original "main" ST_AddBand() function (first code above) will now call
 the new "main" function.

 Usage example:

 {{{
 SELECT
         St_Value(rast, 1, 3, 3),
         St_Value(rast, 2, 3, 3)
 FROM (
         SELECT
                 ST_AddBand(
                         ST_MakeEmptyRaster(10, 10, 10, 10, 2, 2, 0, 0, 0),
                         ARRAY[
                                 ROW(1, '64BF', 1234.567, NULL),
                                 ROW(2, '8BUI', 255, NULL)
                         ]::addbandarg[]
                 ) AS rast
 ) foo;
 }}}

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/1938>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list