]> granicus.if.org Git - postgis/commitdiff
-General review of ST_AddBand following ticket 871
authorPierre Racine <Pierre.Racine@sbf.ulaval.ca>
Wed, 23 Mar 2011 19:52:34 +0000 (19:52 +0000)
committerPierre Racine <Pierre.Racine@sbf.ulaval.ca>
Wed, 23 Mar 2011 19:52:34 +0000 (19:52 +0000)
-Moved some warning in the core
-Renamed the parameters to make more explicit which one is "to" and which one is "from"
-Fixed confusion in parameter order.
-Set many rtpostgis.sql.in.c functions to STRICT
-Removed check for null in RASTER_getPixelValue since st_value is now strict. More might follow.
-Removed (or moved) some documentation from rt_api.c already present in rt_api.h

git-svn-id: http://svn.osgeo.org/postgis/trunk@6960 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_core/rt_api.c
raster/rt_core/rt_api.h
raster/rt_pg/rt_pg.c
raster/rt_pg/rtpostgis.sql.in.c
raster/test/regress/rt_addband_expected
raster/test/regress/rt_pixelvalue_expected

index 0e908b1ffd1d81a956ba70eea33d7e9dd06117dc..198876c27b92963a7165b0f4215efbf1c4b620e9 100644 (file)
@@ -3580,70 +3580,65 @@ rt_raster_deserialize(rt_context ctx, void* serialized) {
     return rast;
 }
 
-/**
- * Return TRUE if the raster is empty. i.e. is NULL, width = 0 or height = 0
- * @param ctx: context for thread safety
- * @param raster: the raster to get info from
- * @return TRUE if the raster is empty, FALSE otherwise
- */
 int rt_raster_is_empty(rt_context ctx, rt_raster raster) {
     assert(NULL != ctx);
 
     return (NULL == raster || raster->height <= 0 || raster->width <= 0);
 }
 
-/**
- * Return TRUE if the raster do not have a band of this number.
- * @param ctx: context for thread safety
- * @param raster: the raster to get info from
- * @param nband: the band number.
- * @return TRUE if the raster do not have a band of this number, FALSE otherwise
- */
 int rt_raster_has_no_band(rt_context ctx, rt_raster raster, int nband) {
     assert(NULL != ctx);
 
     return (NULL == raster || raster->numBands < nband);
 }
 
-/**
- * Copy one band from one raster to another
- * @param ctx: context, for thread safety
- * @param raster1: raster to copy band to
- * @param raster2: raster to copy band from
- * @param nband1: band index of source raster
- * @param nband2: band index of destination raster
- * @return The band index of the second raster where the new band is copied.
- */
-int32_t rt_raster_copy_band(rt_context ctx, rt_raster raster1,
-        rt_raster raster2, int nband1, int nband2)
+int32_t rt_raster_copy_band(rt_context ctx, rt_raster torast,
+        rt_raster fromrast, int fromindex, int toindex)
 {
     rt_band newband = NULL;
     assert(NULL != ctx);
-    assert(NULL != raster1);
-    assert(NULL != raster2);
+    assert(NULL != torast);
+    assert(NULL != fromrast);
 
     /* Check raster dimensions */
-    if (raster1->height != raster2->height || raster1->width != raster2->width)
+    if (torast->height != fromrast->height || torast->width != fromrast->width)
     {
         ctx->err("rt_raster_copy_band: Attempting to add a band with different width or height");
         return -1;
     }
 
     /* Check bands limits */
-    if (nband1 < 0)
-        nband1 = 0;
-    else if (nband1 >= raster1->numBands)
-        nband1 = raster1->numBands - 1;
+    if (fromrast->numBands < 1)
+    {
+        ctx->warn("rt_raster_copy_band: Second raster has no band");
+        return -1;
+    }
+    else if (fromindex < 0)
+    {
+        ctx->warn("rt_raster_copy_band: Band index for second raster < 0. Defaulted to 1");
+        fromindex = 0;
+    }
+    else if (fromindex >= fromrast->numBands)
+    {
+        ctx->warn("rt_raster_copy_band: Band index for second raster > number of bands, truncated from %u to %u", fromindex - 1, fromrast->numBands);
+        fromindex = fromrast->numBands - 1;
+    }
 
-    if (nband2 < 0)
-        nband2 = 0;
-    else if (nband2 > raster2->numBands)
-        nband2 = raster2->numBands;
+    if (toindex < 0)
+    {
+        ctx->warn("rt_raster_copy_band: Band index for first raster < 0. Defaulted to 1");
+        toindex = 0;
+    }
+    else if (toindex > torast->numBands)
+    {
+        ctx->warn("rt_raster_copy_band: Band index for first raster > number of bands, truncated from %u to %u", toindex - 1, torast->numBands);
+        toindex = torast->numBands;
+    }
 
-    /* Get band from first raster */
-    newband = rt_raster_get_band(ctx, raster1, nband1);
+    /* Get band from source raster */
+    newband = rt_raster_get_band(ctx, fromrast, fromindex);
 
     /* Add band to the second raster */
-    return rt_raster_add_band(ctx, raster2, newband, nband2);
+    return rt_raster_add_band(ctx, torast, newband, toindex);
 }
 
index ecaa2b8caaafe359b7974aa5ff0220f4ee59ef52..13e8a50103e8df23ded161a9d4abb3abb39f4a01 100644 (file)
@@ -728,14 +728,14 @@ int rt_raster_has_no_band(rt_context ctx, rt_raster raster, int nband);
 /**
  * Copy one band from one raster to another
  * @param ctx: context, for thread safety
- * @param raster1: raster to copy band to
- * @param raster2: raster to copy band from
- * @param nband1: band index of destination raster
- * @param nband2: band index of source raster
- * @return The band index of the first raster where the new band is copied.
- */
-int32_t rt_raster_copy_band(rt_context ctx, rt_raster raster1,
-        rt_raster raster2, int nband1, int nband2);
+ * @param torast: raster to copy band to
+ * @param fromrast: raster to copy band from
+ * @param fromindex: index of band in source raster
+ * @param toindex: index of new band in destination raster
+ * @return The band index of the second raster where the new band is copied.
+ */
+int32_t rt_raster_copy_band(rt_context ctx, rt_raster torast,
+        rt_raster fromrast, int fromindex, int toindex);
 
 /*- utilities -------------------------------------------------------*/
 
index 6e156e6c3c19fe049eda8a10f41f5137d2b2f34a..7797b3049ffb9f94e90e972473d9dbbca50bded9 100644 (file)
@@ -339,7 +339,6 @@ Datum RASTER_in(PG_FUNCTION_ARGS)
 PG_FUNCTION_INFO_V1(RASTER_out);
 Datum RASTER_out(PG_FUNCTION_ARGS)
 {
-    elog(WARNING, "RASTER_out: Starting...");
     rt_pgraster *pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
     rt_raster raster = NULL;
     uint32_t hexwkbsize = 0;
@@ -1603,21 +1602,11 @@ Datum RASTER_getPixelValue(PG_FUNCTION_ARGS)
     }
     assert(0 <= (nband - 1));
 
-    /* Validate pixel coordinates are in range */
-    if (PG_ARGISNULL(2)) {
-        elog(NOTICE, "X coordinate can not be NULL when getting pixel value. Returning NULL");
-        PG_RETURN_NULL();
-    }
     x = PG_GETARG_INT32(2);
 
-    if (PG_ARGISNULL(3)) {
-        elog(NOTICE, "Y coordinate can not be NULL when getting pixel value. Returning NULL");
-        PG_RETURN_NULL();
-    }
     y = PG_GETARG_INT32(3);
 
-    if (!PG_ARGISNULL(4))
-        hasnodata = PG_GETARG_BOOL(4);
+    hasnodata = PG_GETARG_BOOL(4);
 
     POSTGIS_RT_DEBUGF(3, "Pixel coordinates (%d, %d)", x, y);
 
@@ -1696,7 +1685,7 @@ Datum RASTER_setPixelValue(PG_FUNCTION_ARGS)
     /* Set the pixel value */
     if (PG_ARGISNULL(4)) {
         if (!rt_band_get_hasnodata_flag(ctx, band)) {
-            elog(NOTICE, "Raster do not have a nodata value defined. Pixel value not set. Returning raster");
+            elog(NOTICE, "Raster do not have a nodata value defined. Nodata value not set. Returning raster");
         }
         else {
             pixvalue = rt_band_get_nodata(ctx, band);
@@ -1823,68 +1812,62 @@ PG_FUNCTION_INFO_V1(RASTER_copyband);
 Datum RASTER_copyband(PG_FUNCTION_ARGS)
 {
     rt_pgraster *pgraster = NULL;
-    rt_raster raster1 = NULL;
-    rt_raster raster2 = NULL;
-    int nband1 = 0;
-    int nband2 = 0;
-    int oldnumbands = 0;
-    int numbands = 0;
+    rt_raster torast = NULL;
+    rt_raster fromrast = NULL;
+    int toindex = 0;
+    int fromband = 0;
+    int oldtorastnumbands = 0;
+    int newtorastnumbands = 0;
     int index = 0;
-    int max = 0;
     rt_context ctx = NULL;
 
-    /* Get band numbers */
-    nband1 = PG_GETARG_UINT16(2);
-    nband2 = PG_GETARG_UINT16(3);
-
-    if (nband1 < 1 || nband2 < 1) {
-        elog(ERROR, "RASTER_copyband: Invalid band index (must be 1-based)");
+    /* Deserialize torast */
+    if (PG_ARGISNULL(0))
         PG_RETURN_NULL();
-    }
-
-    /* Check if raster1 has the given band */
-
-    /* Deserialize raster1 */
     pgraster = (rt_pgraster *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0));
     ctx = get_rt_context(fcinfo);
 
-    raster1 = rt_raster_deserialize(ctx, pgraster);
-    if ( ! raster1 ) {
-        elog(ERROR, "RASTER_copyband: Could not deserialize raster");
+    torast = rt_raster_deserialize(ctx, pgraster);
+    if ( ! torast ) {
+        elog(ERROR, "RASTER_copyband: Could not deserialize first raster");
         PG_RETURN_NULL();
     }
 
-    /* Make sure index (1 based) is in range */
-    max = rt_raster_get_num_bands(ctx, raster1);
-    if (nband1 > max) {
-        elog(WARNING, "RASTER_copyband: Band index number exceed possible values, truncated to "
-                "number of band (%u) + 1", max);
-        nband1 = max;
-    }
+    /* Deserialize fromrast */
+    if (!PG_ARGISNULL(1)) {
+        pgraster = (rt_pgraster *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(1));
+        ctx = get_rt_context(fcinfo);
 
-    /* Deserialize raster2 */
-    pgraster = (rt_pgraster *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(1));
-    ctx = get_rt_context(fcinfo);
+        fromrast = rt_raster_deserialize(ctx, pgraster);
+        if ( ! fromrast ) {
+            elog(ERROR, "RASTER_copyband: Could not deserialize second raster");
+            PG_RETURN_NULL();
+        }
 
-    raster2 = rt_raster_deserialize(ctx, pgraster);
-    if ( ! raster2 ) {
-        elog(ERROR, "RASTER_copyband: Could not deserialize raster");
-        PG_RETURN_NULL();
-    }
+        oldtorastnumbands = rt_raster_get_num_bands(ctx, torast);
+
+        if (PG_ARGISNULL(2))
+            fromband = 1;
+        else
+            fromband = PG_GETARG_UINT16(2);
 
-    /* Copy band from raster1 to raster2 */
-    oldnumbands = rt_raster_get_num_bands(ctx, raster2);
+        if (PG_ARGISNULL(3))
+            toindex = oldtorastnumbands + 1;
+        else
+            toindex = PG_GETARG_UINT16(2);
 
-    index = rt_raster_copy_band(ctx, raster1, raster2, nband1, nband2);
+        /* Copy band fromrast torast */
+        index = rt_raster_copy_band(ctx, torast, fromrast, fromband - 1, toindex - 1);
 
-    numbands = rt_raster_get_num_bands(ctx, raster2);
-    if (numbands == oldnumbands || index == -1) {
-        elog(ERROR, "RASTER_copyband: Could not add band to raster. Returning NULL");
-        PG_RETURN_NULL();
+        newtorastnumbands = rt_raster_get_num_bands(ctx, torast);
+        if (newtorastnumbands == oldtorastnumbands || index == -1) {
+            elog(NOTICE, "RASTER_copyband: Could not add band to raster. Returning original raster.");
+        }
     }
-
-    /* Serialize and return raster2 */
-    pgraster = rt_raster_serialize(ctx, raster2);
+    else
+        elog(NOTICE, "RASTER_copyband: Second raster is NULL. Returning original raster.");
+    /* Serialize and return torast */
+    pgraster = rt_raster_serialize(ctx, torast);
     if (!pgraster) PG_RETURN_NULL();
 
     SET_VARSIZE(pgraster, pgraster->size);
index 94fb2dfbf996ff5c7bf7d6c7d4b95bddbd15befe..e2043c49f1f44164213160d55094957864d7fc03 100644 (file)
@@ -155,7 +155,7 @@ CREATE OR REPLACE FUNCTION st_metadata(rast raster,
            st_srid($1),
            st_numbands($1)
     $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 -----------------------------------------------------------------------
 -- Constructors ST_MakeEmptyRaster and ST_AddBand
@@ -163,23 +163,24 @@ CREATE OR REPLACE FUNCTION st_metadata(rast raster,
 CREATE OR REPLACE FUNCTION st_makeemptyraster(width int, height int, upperleftx float8, upperlefty float8, scalex float8, scaley float8, skewx float8, skewy float8, srid int4)
     RETURNS RASTER
     AS 'MODULE_PATHNAME', 'RASTER_makeEmpty'
-    LANGUAGE 'C' IMMUTABLE;
+    LANGUAGE 'C' IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_makeemptyraster(width int, height int, upperleftx float8, upperlefty float8, scale float8)
     RETURNS raster
     AS 'select st_makeemptyraster($1, $2, $3, $4, $5, $5, 0, 0, -1)'
-    LANGUAGE 'SQL' IMMUTABLE;
+    LANGUAGE 'SQL' IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_makeemptyraster(width int, height int, upperleftx float8, upperlefty float8, scalex float8, scaley float8, skewx float8, skewy float8)
     RETURNS raster
     AS 'select st_makeemptyraster($1, $2, $3, $4, $5, $6, $7, $8, -1)'
-    LANGUAGE 'SQL' IMMUTABLE;
+    LANGUAGE 'SQL' IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_makeemptyraster(rast raster)
     RETURNS raster
     AS 'select st_makeemptyraster(st_width($1), st_height($1), st_upperleftx($1), st_upperlefty($1), st_scalex($1), st_scaley($1), st_skewx($1), st_skewy($1), st_srid($1))'
     LANGUAGE 'SQL' IMMUTABLE STRICT;
 
+-- This function can not be STRICT, because nodataval can be NULL indicating that no nodata value should be set
 CREATE OR REPLACE FUNCTION st_addband(rast raster, index int, pixeltype text, initialvalue float8, nodataval float8)
     RETURNS RASTER
     AS 'MODULE_PATHNAME', 'RASTER_addband'
@@ -187,48 +188,51 @@ CREATE OR REPLACE FUNCTION st_addband(rast raster, index int, pixeltype text, in
 
 CREATE OR REPLACE FUNCTION st_addband(rast raster, pixeltype text)
     RETURNS raster
-    AS 'select st_addband($1, NULL, $2, NULL, NULL)'
-    LANGUAGE 'SQL' IMMUTABLE;
+    AS 'select st_addband($1, 1, $2, 0, NULL)'
+    LANGUAGE 'SQL' IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_addband(rast raster, pixeltype text, initialvalue float8)
     RETURNS raster
-    AS 'select st_addband($1, NULL, $2, $3, NULL)'
-    LANGUAGE 'SQL' IMMUTABLE;
+    AS 'select st_addband($1, 1, $2, $3, NULL)'
+    LANGUAGE 'SQL' IMMUTABLE STRICT;
 
+-- This function can not be STRICT, because nodataval can be NULL indicating that no nodata value should be set
 CREATE OR REPLACE FUNCTION st_addband(rast raster, pixeltype text, initialvalue float8, nodataval float8)
     RETURNS raster
-    AS 'select st_addband($1, NULL, $2, $3, $4)'
+    AS 'select st_addband($1, 1, $2, $3, $4)'
     LANGUAGE 'SQL' IMMUTABLE;
 
 CREATE OR REPLACE FUNCTION st_addband(rast raster, index int, pixeltype text)
     RETURNS raster
-    AS 'select st_addband($1, $2, $3, NULL, NULL)'
-    LANGUAGE 'SQL' IMMUTABLE;
+    AS 'select st_addband($1, $2, $3, 0, NULL)'
+    LANGUAGE 'SQL' IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_addband(rast raster, index int, pixeltype text, initialvalue float8)
     RETURNS raster
     AS 'select st_addband($1, $2, $3, $4, NULL)'
-    LANGUAGE 'SQL' IMMUTABLE;
+    LANGUAGE 'SQL' IMMUTABLE STRICT;
 
-CREATE OR REPLACE FUNCTION st_addband(raster1 raster, raster2 raster, nband1 int, nband2 int)
+-- This function can not be STRICT, because torastindex can not be determined (could be st_numbands(raster) though)
+CREATE OR REPLACE FUNCTION st_addband(torast raster, fromrast raster, fromband int, torastindex int)
     RETURNS RASTER
     AS 'MODULE_PATHNAME', 'RASTER_copyband'
-    LANGUAGE 'C' IMMUTABLE STRICT;
-
-CREATE OR REPLACE FUNCTION st_addband(raster1 raster, raster2 raster, nband int)
-    RETURNS RASTER
-    AS 'select st_addband($1, $2, st_numbands($1), $3)'
-    LANGUAGE 'SQL' IMMUTABLE;
+    LANGUAGE 'C' IMMUTABLE;
 
-CREATE OR REPLACE FUNCTION st_addband(raster1 raster, raster2 raster)
-    RETURNS RASTER
-    AS 'select st_addband($1, $2, st_numbands($1), st_numbands($2) + 1)'
-    LANGUAGE 'SQL' IMMUTABLE;
+CREATE OR REPLACE FUNCTION st_addband(torast raster, fromrast raster, fromband int)
+    RETURNS raster
+    AS 'select st_addband($1, $2, $3, NULL)'
+    LANGUAGE 'SQL' IMMUTABLE STRICT;
 
+CREATE OR REPLACE FUNCTION st_addband(torast raster, fromrast raster)
+    RETURNS raster
+    AS 'select st_addband($1, $2, 1, NULL)'
+    LANGUAGE 'SQL' IMMUTABLE STRICT;
 
 -----------------------------------------------------------------------
 -- MapAlgebra
 -----------------------------------------------------------------------
+-- This function can not be STRICT, because nodatavalueexpr can be NULL (could be just '' though)
+-- or pixeltype can not be determined (could be st_bandpixeltype(raster, band) though)
 CREATE OR REPLACE FUNCTION st_mapalgebra(rast raster, band integer,
         expression text, nodatavalueexpr text, pixeltype text)
     RETURNS raster
@@ -239,32 +243,35 @@ CREATE OR REPLACE FUNCTION st_mapalgebra(rast raster, band integer,
         expression text)
     RETURNS raster
     AS $$ SELECT st_mapalgebra($1, $2, $3, NULL, NULL) $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_mapalgebra(rast raster, expression text,
         pixeltype text)
     RETURNS raster
     AS $$ SELECT st_mapalgebra($1, 1, $2, NULL, $3) $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_mapalgebra(rast raster, expression text)
     RETURNS raster
     AS $$ SELECT st_mapalgebra($1, 1, $2, NULL, NULL) $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
+-- This function can not be STRICT, because nodatavalueexpr can be NULL (could be just '' though)
 CREATE OR REPLACE FUNCTION st_mapalgebra(rast raster, band integer,
         expression text, nodatavalueexpr text)
     RETURNS raster
     AS $$ SELECT st_mapalgebra($1, $2, $3, $4, NULL) $$
     LANGUAGE SQL;
 
-
+-- This function can not be STRICT, because nodatavalueexpr can be NULL (could be just '' though)
+-- or pixeltype can not be determined (could be st_bandpixeltype(raster, band) though)
 CREATE OR REPLACE FUNCTION st_mapalgebra(rast raster, expression text,
         nodatavalueexpr text, pixeltype text)
     RETURNS raster
     AS $$ SELECT st_mapalgebra($1, 1, $2, $3, $4) $$
     LANGUAGE SQL;
 
+-- This function can not be STRICT, because nodatavalueexpr can be NULL (could be just '' though)
 CREATE OR REPLACE FUNCTION st_mapalgebra(rast raster, expression text,
         nodatavalueexpr text)
     RETURNS raster
@@ -288,7 +295,7 @@ CREATE OR REPLACE FUNCTION st_hasnoband(rast raster, nband int)
 CREATE OR REPLACE FUNCTION st_hasnoband(rast raster)
     RETURNS boolean
     AS 'select st_hasnoband($1, 1)'
-    LANGUAGE 'SQL' IMMUTABLE;
+    LANGUAGE 'SQL' IMMUTABLE STRICT;
 
 -----------------------------------------------------------------------
 -- Raster Band Accessors
@@ -302,7 +309,7 @@ CREATE OR REPLACE FUNCTION st_bandnodatavalue(rast raster, band integer)
 CREATE OR REPLACE FUNCTION st_bandnodatavalue(raster)
     RETURNS float4
     AS $$ SELECT st_bandnodatavalue($1, 1) $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_bandisnodata(rast raster, band integer,
         forceChecking boolean)
@@ -313,17 +320,17 @@ CREATE OR REPLACE FUNCTION st_bandisnodata(rast raster, band integer,
 CREATE OR REPLACE FUNCTION st_bandisnodata(rast raster, forceChecking boolean)
     RETURNS boolean
     AS $$ SELECT st_bandisnodata($1, 1, $2) $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_bandisnodata(rast raster, band integer)
     RETURNS boolean
     AS $$ SELECT st_bandisnodata($1, $2, FALSE) $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_bandisnodata(rast raster)
     RETURNS boolean
     AS $$ SELECT st_bandisnodata($1, 1, FALSE) $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_bandpath(rast raster, band integer)
     RETURNS text
@@ -333,7 +340,7 @@ CREATE OR REPLACE FUNCTION st_bandpath(rast raster, band integer)
 CREATE OR REPLACE FUNCTION st_bandpath(raster)
     RETURNS text
     AS $$ SELECT st_bandpath($1, 1) $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_bandpixeltype(rast raster, band integer)
     RETURNS text
@@ -343,7 +350,7 @@ CREATE OR REPLACE FUNCTION st_bandpixeltype(rast raster, band integer)
 CREATE OR REPLACE FUNCTION st_bandpixeltype(raster)
     RETURNS text
     AS $$ SELECT st_bandpixeltype($1, 1) $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_bandmetadata(rast raster,
                                            band int,
@@ -359,7 +366,7 @@ CREATE OR REPLACE FUNCTION st_bandmetadata(rast raster,
        st_bandpath($1, $2) IS NOT NULL,
        st_bandpath($1, $2)
     $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_bandmetadata(rast raster,
                                            OUT pixeltype text,
@@ -374,7 +381,7 @@ CREATE OR REPLACE FUNCTION st_bandmetadata(rast raster,
        st_bandpath($1, 1) IS NOT NULL,
        st_bandpath($1, 1)
     $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 -----------------------------------------------------------------------
 -- Raster Pixel Accessors
@@ -383,22 +390,22 @@ CREATE OR REPLACE FUNCTION st_bandmetadata(rast raster,
 CREATE OR REPLACE FUNCTION st_value(rast raster, band integer, x integer, y integer, hasnodata boolean)
     RETURNS float8
     AS 'MODULE_PATHNAME','RASTER_getPixelValue'
-    LANGUAGE 'C' IMMUTABLE;
+    LANGUAGE 'C' IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_value(rast raster, band integer, x integer, y integer)
     RETURNS float8
-    AS $$ SELECT st_value($1, $2, $3, $4, NULL) $$
-    LANGUAGE SQL;
+    AS $$ SELECT st_value($1, $2, $3, $4, TRUE) $$
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_value(rast raster, x integer, y integer, hasnodata boolean)
     RETURNS float8
     AS $$ SELECT st_value($1, 1, $2, $3, $4) $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_value(rast raster, x integer, y integer)
     RETURNS float8
-    AS $$ SELECT st_value($1, 1, $2, $3, NULL) $$
-    LANGUAGE SQL;
+    AS $$ SELECT st_value($1, 1, $2, $3, TRUE) $$
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_value(rast raster, band integer, pt geometry, hasnodata boolean)
     RETURNS float8 AS
@@ -421,22 +428,22 @@ CREATE OR REPLACE FUNCTION st_value(rast raster, band integer, pt geometry, hasn
                         hasnodata);
     END;
     $$
-    LANGUAGE 'plpgsql' IMMUTABLE;
+    LANGUAGE 'plpgsql' IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_value(rast raster, band integer, pt geometry)
     RETURNS float8
-    AS $$ SELECT st_value($1, $2, $3, NULL) $$
-    LANGUAGE SQL;
+    AS $$ SELECT st_value($1, $2, $3, TRUE) $$
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_value(rast raster, pt geometry, hasnodata boolean)
     RETURNS float8
     AS $$ SELECT st_value($1, 1, $2, $3) $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_value(rast raster, pt geometry)
     RETURNS float8
-    AS $$ SELECT st_value($1, 1, $2, NULL) $$
-    LANGUAGE SQL;
+    AS $$ SELECT st_value($1, 1, $2, TRUE) $$
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 -----------------------------------------------------------------------
 -- Raster Accessors ST_Georeference()
@@ -577,18 +584,20 @@ CREATE OR REPLACE FUNCTION st_setgeoreference(rast raster, georef text)
 -- Raster Band Editors
 -----------------------------------------------------------------------
 
--- The function can not be strict, because allows NULL as nodata
+-- This function can not be STRICT, because nodatavalue can be NULL indicating that no nodata value should be set
 CREATE OR REPLACE FUNCTION st_setbandnodatavalue(rast raster, band integer,
         nodatavalue float8, forceChecking boolean)
     RETURNS raster
     AS 'MODULE_PATHNAME','RASTER_setBandNoDataValue'
     LANGUAGE 'C' IMMUTABLE;
 
+-- This function can not be STRICT, because nodatavalue can be NULL indicating that no nodata value should be set
 CREATE OR REPLACE FUNCTION st_setbandnodatavalue(rast raster, band integer, nodatavalue float8)
     RETURNS raster
     AS $$ SELECT st_setbandnodatavalue($1, $2, $3, FALSE) $$
     LANGUAGE SQL;
 
+-- This function can not be STRICT, because nodatavalue can be NULL indicating that no nodata value should be set
 CREATE OR REPLACE FUNCTION st_setbandnodatavalue(rast raster, nodatavalue float8)
     RETURNS raster
     AS $$ SELECT st_setbandnodatavalue($1, 1, $2, FALSE) $$
@@ -602,22 +611,25 @@ CREATE OR REPLACE FUNCTION st_setbandisnodata(rast raster, band integer)
 CREATE OR REPLACE FUNCTION st_setbandisnodata(rast raster)
     RETURNS raster
     AS  $$ SELECT st_setbandisnodata($1, 1) $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 -----------------------------------------------------------------------
 -- Raster Pixel Editors
 -----------------------------------------------------------------------
 
+-- This function can not be STRICT, because newvalue can be NULL for nodata
 CREATE OR REPLACE FUNCTION st_setvalue(rast raster, band integer, x integer, y integer, newvalue float8)
     RETURNS raster
     AS 'MODULE_PATHNAME','RASTER_setPixelValue'
     LANGUAGE 'C' IMMUTABLE;
 
+-- This function can not be STRICT, because newvalue can be NULL for nodata
 CREATE OR REPLACE FUNCTION st_setvalue(rast raster, x integer, y integer, newvalue float8)
     RETURNS raster
     AS $$ SELECT st_setvalue($1, 1, $2, $3, $4) $$
     LANGUAGE SQL;
 
+-- This function can not be STRICT, because newvalue can be NULL for nodata
 CREATE OR REPLACE FUNCTION st_setvalue(rast raster, band integer, pt geometry, newvalue float8)
     RETURNS raster AS
     $$
@@ -641,6 +653,7 @@ CREATE OR REPLACE FUNCTION st_setvalue(rast raster, band integer, pt geometry, n
     $$
     LANGUAGE 'plpgsql' IMMUTABLE;
 
+-- This function can not be STRICT, because newvalue can be NULL for nodata
 CREATE OR REPLACE FUNCTION st_setvalue(rast raster, pt geometry, newvalue float8)
     RETURNS raster
     AS $$ SELECT st_setvalue($1, 1, $2, $3) $$
@@ -741,14 +754,14 @@ CREATE OR REPLACE FUNCTION st_pixelaspolygon(rast raster, band integer, x intege
                          );
     END;
     $$
-    LANGUAGE 'plpgsql';
+    LANGUAGE 'plpgsql' IMMUTABLE STRICT;
 
 CREATE OR REPLACE FUNCTION st_pixelaspolygon(rast raster, x integer, y integer)
     RETURNS geometry AS
     $$
         SELECT st_pixelaspolygon($1, 1, $2, $3)
     $$
-    LANGUAGE SQL;
+    LANGUAGE SQL IMMUTABLE STRICT;
 
 
 -----------------------------------------------------------------------
@@ -1339,41 +1352,49 @@ CREATE OR REPLACE FUNCTION _st_intersects(geomin geometry, rast raster, band int
     LANGUAGE 'plpgsql' IMMUTABLE STRICT;
 
 
+-- This function can not be STRICT
 CREATE OR REPLACE FUNCTION st_intersects(geometry, raster, integer)
     RETURNS boolean AS
     $$ SELECT $1 && $2 AND _st_intersects($1, $2, $3, TRUE);
     $$ LANGUAGE 'SQL' IMMUTABLE;
 
+-- This function can not be STRICT
 CREATE OR REPLACE FUNCTION st_intersects(raster, integer, geometry)
     RETURNS boolean AS
     $$ SELECT st_intersects($3, $1, $2);
     $$ LANGUAGE 'SQL' IMMUTABLE;
 
+-- This function can not be STRICT
 CREATE OR REPLACE FUNCTION st_intersects(geometry, raster)
     RETURNS boolean AS
     $$ SELECT st_intersects($1, $2, 1);
     $$ LANGUAGE 'SQL' IMMUTABLE;
 
+-- This function can not be STRICT
 CREATE OR REPLACE FUNCTION st_intersects(raster, geometry)
     RETURNS boolean AS
     $$ SELECT st_intersects($2, $1, 1);
     $$ LANGUAGE 'SQL' IMMUTABLE;
 
+-- This function can not be STRICT
 CREATE OR REPLACE FUNCTION st_intersects(geometry, raster, integer, boolean)
     RETURNS boolean AS
     $$ SELECT $1 && $2 AND _st_intersects($1, $2, $3, $4);
     $$ LANGUAGE 'SQL' IMMUTABLE;
 
+-- This function can not be STRICT
 CREATE OR REPLACE FUNCTION st_intersects(raster, integer, boolean, geometry)
     RETURNS boolean AS
     $$ SELECT st_intersects($4, $1, $2, $3);
     $$ LANGUAGE 'SQL' IMMUTABLE;
 
+-- This function can not be STRICT
 CREATE OR REPLACE FUNCTION st_intersects(geometry, raster, boolean)
     RETURNS boolean AS
     $$ SELECT st_intersects($1, $2, 1, $3);
     $$ LANGUAGE 'SQL' IMMUTABLE;
 
+-- This function can not be STRICT
 CREATE OR REPLACE FUNCTION st_intersects(raster, boolean, geometry)
     RETURNS boolean AS
     $$ SELECT st_intersects($3, $1, 1, $2);
index 40dabcbfa1539161107a23b217378c9c1b637f51..ae0ebd3f689620caad50aa14d837a0b8f6de88fc 100644 (file)
@@ -129,6 +129,12 @@ WARNING:  Initial pixel value for 32BF band got converted from 210000.464564 to
 1234.567
 210000.464564365
 1234.46456436475
+WARNING:  rt_raster_copy_band: Second raster has no band
+NOTICE:  RASTER_copyband: Could not add band to raster. Returning original raster.
 1234.5678
+WARNING:  rt_raster_copy_band: Second raster has no band
+NOTICE:  RASTER_copyband: Could not add band to raster. Returning original raster.
 1234.5678
+WARNING:  rt_raster_copy_band: Second raster has no band
+NOTICE:  RASTER_copyband: Could not add band to raster. Returning original raster.
 1234.5678
index 0c7865c387d655b87733cfd62f65f2be3c70d9b8..115edda4bfd2435769c4e57c1b592e247d7f2a06 100644 (file)
@@ -1,12 +1,4 @@
-NOTICE:  Y coordinate can not be NULL when getting pixel value. Returning NULL
-NOTICE:  Y coordinate can not be NULL when getting pixel value. Returning NULL
-NOTICE:  Y coordinate can not be NULL when getting pixel value. Returning NULL
-NOTICE:  Y coordinate can not be NULL when getting pixel value. Returning NULL
-NOTICE:  X coordinate can not be NULL when getting pixel value. Returning NULL
-NOTICE:  X coordinate can not be NULL when getting pixel value. Returning NULL
-NOTICE:  X coordinate can not be NULL when getting pixel value. Returning NULL
-NOTICE:  X coordinate can not be NULL when getting pixel value. Returning NULL
-NOTICE:  Raster do not have a nodata value defined. Pixel value not set. Returning raster
-NOTICE:  Raster do not have a nodata value defined. Pixel value not set. Returning raster
-NOTICE:  Raster do not have a nodata value defined. Pixel value not set. Returning raster
-NOTICE:  Raster do not have a nodata value defined. Pixel value not set. Returning raster
+NOTICE:  Raster do not have a nodata value defined. Nodata value not set. Returning raster
+NOTICE:  Raster do not have a nodata value defined. Nodata value not set. Returning raster
+NOTICE:  Raster do not have a nodata value defined. Nodata value not set. Returning raster
+NOTICE:  Raster do not have a nodata value defined. Nodata value not set. Returning raster