]> granicus.if.org Git - postgis/commitdiff
Where appropriate, functions in rt_core now use standardized function
authorBborie Park <bkpark at ucdavis.edu>
Sun, 25 Nov 2012 21:55:42 +0000 (21:55 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Sun, 25 Nov 2012 21:55:42 +0000 (21:55 +0000)
return states.

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

raster/rt_core/rt_api.c
raster/rt_core/rt_api.h
raster/rt_pg/rt_pg.c
raster/test/core/testapi.c
raster/test/core/testwkb.c

index 8302ba0a738f01254c18ad34279fc0dabb8e8b05..c2badcc649b3c55b4667b4d96f83c13179a1476c 100644 (file)
@@ -1096,63 +1096,69 @@ rt_pixtype_get_min_value(rt_pixtype pixtype) {
  * @param pixtype : the pixel type to clamp the provided values
  * @param val : value to compare to reference value
  * @param refval : reference value to be compared with
+ * @param isequal : non-zero if clamped values are equal, 0 otherwise
  *
- * @return 1 if clamped values are equal, 0 if not equal, -1 if error
+ * @return ES_NONE on success, ES_ERROR on error
  */
-int rt_pixtype_compare_clamped_values(rt_pixtype pixtype, double val, double refval) {
-       int rtn = 0;
+rt_errorstate rt_pixtype_compare_clamped_values(
+       rt_pixtype pixtype,
+       double val, double refval,
+       int *isequal
+) {
+       assert(isequal != NULL);
+       *isequal = 0;
 
        switch (pixtype) {
                case PT_1BB:
                        if (rt_util_clamp_to_1BB(val) == rt_util_clamp_to_1BB(refval))
-                               rtn = 1;
+                               *isequal = 1;
                        break;
                case PT_2BUI:
                        if (rt_util_clamp_to_2BUI(val) == rt_util_clamp_to_2BUI(refval))
-                               rtn = 1;
+                               *isequal = 1;
                        break;
                case PT_4BUI:
                        if (rt_util_clamp_to_4BUI(val) == rt_util_clamp_to_4BUI(refval))
-                               rtn = 1;
+                               *isequal = 1;
                        break;
                case PT_8BSI:
                        if (rt_util_clamp_to_8BSI(val) == rt_util_clamp_to_8BSI(refval))
-                               rtn = 1;
+                               *isequal = 1;
                        break;
                case PT_8BUI:
                        if (rt_util_clamp_to_8BUI(val) == rt_util_clamp_to_8BUI(refval))
-                               rtn = 1;
+                               *isequal = 1;
                        break;
                case PT_16BSI:
                        if (rt_util_clamp_to_16BSI(val) == rt_util_clamp_to_16BSI(refval))
-                               rtn = 1;
+                               *isequal = 1;
                        break;
                case PT_16BUI:
                        if (rt_util_clamp_to_16BUI(val) == rt_util_clamp_to_16BUI(refval))
-                               rtn = 1;
+                               *isequal = 1;
                        break;
                case PT_32BSI:
                        if (rt_util_clamp_to_32BSI(val) == rt_util_clamp_to_32BSI(refval))
-                               rtn = 1;
+                               *isequal = 1;
                        break;
                case PT_32BUI:
                        if (rt_util_clamp_to_32BUI(val) == rt_util_clamp_to_32BUI(refval))
-                               rtn = 1;
+                               *isequal = 1;
                        break;
                case PT_32BF:
                        if (FLT_EQ(rt_util_clamp_to_32F(val), rt_util_clamp_to_32F(refval)))
-                               rtn = 1;
+                               *isequal = 1;
                        break;
                case PT_64BF:
                        if (FLT_EQ(val, refval))
-                               rtn = 1;
+                               *isequal = 1;
                        break;
                default:
                        rterror("rt_pixtype_compare_clamped_values: Unknown pixeltype %d", pixtype);
-                       rtn = -1;
+                       return ES_ERROR;
        }
 
-       return rtn;
+       return ES_NONE;
 }
 
 /*- rt_pixel ----------------------------------------------------------*/
@@ -1175,9 +1181,9 @@ int rt_pixtype_compare_clamped_values(rt_pixtype pixtype, double val, double ref
  * @param dimx : size of value and nodata along the X axis
  * @param dimy : size of value and nodata along the Y axis
  *
- * @return 0 on error, otherwise 1
+ * @return ES_NONE on success, ES_ERROR on error
  */
-int rt_pixel_set_to_array(
+rt_errorstate rt_pixel_set_to_array(
        rt_pixel npixel, int count,
        int x, int y,
        uint16_t distancex, uint16_t distancey,
@@ -1208,7 +1214,7 @@ int rt_pixel_set_to_array(
 
        if (values == NULL || nodatas == NULL) {
                rterror("rt_pixel_set_to_array: Unable to allocate memory for 2D array");
-               return 0;
+               return ES_ERROR;
        }
 
        /* initialize X axis */
@@ -1236,7 +1242,7 @@ int rt_pixel_set_to_array(
                        rtdealloc(values);
                        rtdealloc(nodatas);
                        
-                       return 0;
+                       return ES_ERROR;
                }
 
                /* set values to 0 */
@@ -1275,7 +1281,7 @@ int rt_pixel_set_to_array(
        if (dimy != NULL)
                *dimy = dim[1];
 
-       return 1;
+       return ES_NONE;
 }
 
 /*- rt_band ----------------------------------------------------------*/
@@ -1323,7 +1329,7 @@ rt_band_new_inline(
        band->offline = 0;
        band->width = width;
        band->height = height;
-       band->hasnodata = hasnodata;
+       band->hasnodata = hasnodata ? 1 : 0;
        band->isnodata = FALSE; /* we don't know what is in data, so must be FALSE */
        band->nodataval = 0;
        band->data.mem = data;
@@ -1333,7 +1339,7 @@ rt_band_new_inline(
        RASTER_DEBUGF(3, "Created rt_band with dimensions %d x %d", band->width, band->height);
 
        /* properly set nodataval as it may need to be constrained to the data type */
-       if (hasnodata && rt_band_set_nodata(band, nodataval) < 0) {
+       if (hasnodata && rt_band_set_nodata(band, nodataval, NULL) != ES_NONE) {
                rterror("rt_band_new_inline: Unable to set NODATA value");
                rtdealloc(band);
                return NULL;
@@ -1386,14 +1392,14 @@ rt_band_new_offline(
        band->offline = 1;
        band->width = width;
        band->height = height;
-       band->hasnodata = hasnodata;
+       band->hasnodata = hasnodata ? 1 : 0;
        band->nodataval = 0;
        band->isnodata = FALSE; /* we don't know if the offline band is NODATA */
        band->ownsdata = 0;
        band->raster = NULL;
 
        /* properly set nodataval as it may need to be constrained to the data type */
-       if (hasnodata && rt_band_set_nodata(band, nodataval) < 0) {
+       if (hasnodata && rt_band_set_nodata(band, nodataval, NULL) != ES_NONE) {
                rterror("rt_band_new_offline: Unable to set NODATA value");
                rtdealloc(band);
                return NULL;
@@ -1474,7 +1480,7 @@ rt_band_is_offline(rt_band band) {
     assert(NULL != band);
 
 
-    return band->offline;
+    return band->offline ? 1 : 0;
 }
 
 /**
@@ -1506,22 +1512,26 @@ rt_band_get_ext_path(rt_band band) {
 
     if (!band->offline) {
         RASTER_DEBUG(3, "rt_band_get_ext_path: Band is not offline");
-        return 0;
+        return NULL;
     }
     return band->data.offline.path;
 }
 
-uint8_t
-rt_band_get_ext_band_num(rt_band band) {
+rt_errorstate
+rt_band_get_ext_band_num(rt_band band, uint8_t *bandnum) {
+       assert(NULL != band);
+       assert(NULL != bandnum);
 
-    assert(NULL != band);
+       *bandnum = 0;
 
+       if (!band->offline) {
+               RASTER_DEBUG(3, "rt_band_get_ext_band_num: Band is not offline");
+               return ES_ERROR;
+       }
 
-    if (!band->offline) {
-        RASTER_DEBUG(3, "rt_band_get_ext_path: Band is not offline");
-        return 0;
-    }
-    return band->data.offline.bandNum;
+       *bandnum = band->data.offline.bandNum;
+
+       return ES_NONE;
 }
 
 /**
@@ -1529,23 +1539,20 @@ rt_band_get_ext_band_num(rt_band band) {
        *
        * @param band : the band who's data to get
        *
-       * @return void pointer to band data
+       * @return pointer to band data or NULL if error
        */
 void *
 rt_band_get_data(rt_band band) {
        assert(NULL != band);
 
        if (band->offline) {
-               int state = 0;
-
                if (band->data.offline.mem != NULL)
                        return band->data.offline.mem;
 
-               state = rt_band_load_offline_data(band);
-               if (state == 0)
-                       return band->data.offline.mem;
-               else
+               if (rt_band_load_offline_data(band) != ES_NONE)
                        return NULL;
+               else
+                       return band->data.offline.mem;
        }
        else
                return band->data.mem;
@@ -1558,9 +1565,9 @@ rt_band_get_data(rt_band band) {
        *
        * @param band : the band who's data to get
        *
-       * @return 0 if success, non-zero if failure
+       * @return ES_NONE if success, ES_ERROR if failure
        */
-int
+rt_errorstate
 rt_band_load_offline_data(rt_band band) {
        GDALDatasetH hdsSrc = NULL;
        int nband = 0;
@@ -1578,18 +1585,18 @@ rt_band_load_offline_data(rt_band band) {
 
        if (!band->offline) {
                rterror("rt_band_load_offline_data: Band is not offline");
-               return 1;
+               return ES_ERROR;
        }
        else if (!strlen(band->data.offline.path)) {
                rterror("rt_band_load_offline_data: Offline band does not a have a specified file");
-               return 1;
+               return ES_ERROR;
        }
 
        rt_util_gdal_register_all();
        hdsSrc = GDALOpenShared(band->data.offline.path, GA_ReadOnly);
        if (hdsSrc == NULL) {
                rterror("rt_band_load_offline_data: Cannot open offline raster: %s", band->data.offline.path);
-               return 1;
+               return ES_ERROR;
        }
 
        /* # of bands */
@@ -1597,13 +1604,13 @@ rt_band_load_offline_data(rt_band band) {
        if (!nband) {
                rterror("rt_band_load_offline_data: No bands found in offline raster: %s", band->data.offline.path);
                GDALClose(hdsSrc);
-               return 1;
+               return ES_ERROR;
        }
        /* bandNum is 0-based */
        else if (band->data.offline.bandNum + 1 > nband) {
                rterror("rt_band_load_offline_data: Specified band %d not found in offline raster: %s", band->data.offline.bandNum, band->data.offline.path);
                GDALClose(hdsSrc);
-               return 1;
+               return ES_ERROR;
        }
 
        /* get raster's geotransform */
@@ -1662,14 +1669,14 @@ rt_band_load_offline_data(rt_band band) {
 
        if (_rast == NULL) {
                rterror("rt_band_load_offline_data: Cannot load data from offline raster: %s", band->data.offline.path);
-               return 1;
+               return ES_ERROR;
        }
 
        _band = rt_raster_get_band(_rast, 0);
        if (_band == NULL) {
                rterror("rt_band_load_offline_data: Cannot load data from offline raster: %s", band->data.offline.path);
                rt_raster_destroy(_rast);
-               return 1;
+               return ES_ERROR;
        }
 
        /* band->data.offline.mem not NULL, free first */
@@ -1683,7 +1690,7 @@ rt_band_load_offline_data(rt_band band) {
        rtdealloc(_band); /* cannot use rt_band_destroy */
        rt_raster_destroy(_rast);
 
-       return 0;
+       return ES_NONE;
 }
 
 rt_pixtype
@@ -1718,7 +1725,7 @@ int
 rt_band_get_ownsdata_flag(rt_band band) {
        assert(NULL != band);
 
-       return (int) band->ownsdata;
+       return band->ownsdata ? 1 : 0;
 }
 
 /* set ownsdata flag */
@@ -1726,7 +1733,7 @@ void
 rt_band_set_ownsdata_flag(rt_band band, int flag) {
        assert(NULL != band);
 
-       band->ownsdata = (int8_t) flag;
+       band->ownsdata = flag ? 1 : 0;
 }
 
 #ifdef OPTIMIZE_SPACE
@@ -1789,11 +1796,9 @@ setBits(char* ch, double val, int bits, int bitOffset) {
 
 int
 rt_band_get_hasnodata_flag(rt_band band) {
+       assert(NULL != band);
 
-    assert(NULL != band);
-
-
-    return band->hasnodata;
+       return band->hasnodata ? 1 : 0;
 }
 
 void
@@ -1810,7 +1815,7 @@ rt_band_set_hasnodata_flag(rt_band band, int flag) {
                }
 }
 
-void
+rt_errorstate
 rt_band_set_isnodata_flag(rt_band band, int flag) {
        assert(NULL != band);
 
@@ -1818,11 +1823,15 @@ rt_band_set_isnodata_flag(rt_band band, int flag) {
                /* silently permit setting isnodata flag to FALSE */
                if (!flag)
                        band->isnodata = 0;
-               else
+               else {
                        rterror("rt_band_set_isnodata_flag: Cannot set isnodata flag as band has no NODATA");
+                       return ES_ERROR;
+               }
        }
        else 
                band->isnodata = (flag) ? 1 : 0;
+
+       return ES_NONE;
 }
 
 int
@@ -1830,7 +1839,7 @@ rt_band_get_isnodata_flag(rt_band band) {
        assert(NULL != band);
 
        if (band->hasnodata)
-               return band->isnodata;
+               return band->isnodata ? 1 : 0;
        else
                return 0;
 }
@@ -1840,136 +1849,109 @@ rt_band_get_isnodata_flag(rt_band band) {
  *
  * @param band : the band to set nodata value to
  * @param val : the nodata value
+ * @param converted : if non-zero, value was truncated/clamped/coverted
  *
- * @return 0 on success, -1 on error (invalid pixel type),
- *   1 on truncation/clamping/converting.
+ * @return ES_NONE or ES_ERROR
  */
-int
-rt_band_set_nodata(rt_band band, double val) {
-    rt_pixtype pixtype = PT_END;
-    /*
-               double oldnodataval = band->nodataval;
-               */
-
-    int32_t checkvalint = 0;
-    uint32_t checkvaluint = 0;
-    float checkvalfloat = 0;
-    double checkvaldouble = 0;
-
-
-
-    assert(NULL != band);
-
-    pixtype = band->pixtype;
+rt_errorstate
+rt_band_set_nodata(rt_band band, double val, int *converted) {
+       rt_pixtype pixtype = PT_END;
+       int32_t checkvalint = 0;
+       uint32_t checkvaluint = 0;
+       float checkvalfloat = 0;
+       double checkvaldouble = 0;
 
-    RASTER_DEBUGF(3, "rt_band_set_nodata: setting nodata value %g with band type %s", val, rt_pixtype_name(pixtype));
+       assert(NULL != band);
 
-    /* return -1 on out of range */
-    switch (pixtype) {
-        case PT_1BB:
-        {
-            band->nodataval = rt_util_clamp_to_1BB(val);
-            checkvalint = band->nodataval;
-            break;
-        }
-        case PT_2BUI:
-        {
-            band->nodataval = rt_util_clamp_to_2BUI(val);
-            checkvalint = band->nodataval;
-            break;
-        }
-        case PT_4BUI:
-        {
-            band->nodataval = rt_util_clamp_to_4BUI(val);
-            checkvalint = band->nodataval;
-            break;
-        }
-        case PT_8BSI:
-        {
-            band->nodataval = rt_util_clamp_to_8BSI(val);
-            checkvalint = band->nodataval;
-            break;
-        }
-        case PT_8BUI:
-        {
-            band->nodataval = rt_util_clamp_to_8BUI(val);
-            checkvalint = band->nodataval;
-            break;
-        }
-        case PT_16BSI:
-        {
-            band->nodataval = rt_util_clamp_to_16BSI(val);
-            checkvalint = band->nodataval;
-            break;
-        }
-        case PT_16BUI:
-        {
-            band->nodataval = rt_util_clamp_to_16BUI(val);
-            checkvalint = band->nodataval;
-            break;
-        }
-        case PT_32BSI:
-        {
-            band->nodataval = rt_util_clamp_to_32BSI(val);
-            checkvalint = band->nodataval;
-            break;
-        }
-        case PT_32BUI:
-        {
-            band->nodataval = rt_util_clamp_to_32BUI(val);
-            checkvaluint = band->nodataval;
-            break;
-        }
-        case PT_32BF:
-        {
-            band->nodataval = rt_util_clamp_to_32F(val);
-            checkvalfloat = band->nodataval;
-            break;
-        }
-        case PT_64BF:
-        {
-            band->nodataval = val;
-            checkvaldouble = band->nodataval;
-            break;
-        }
-        default:
-            {
-            rterror("rt_band_set_nodata: Unknown pixeltype %d", pixtype);
-            band->hasnodata = 0;
-            return -1;
-        }
-    }
+       if (converted != NULL)
+               *converted = 0;
 
-    RASTER_DEBUGF(3, "rt_band_set_nodata: band->hasnodata = %d", band->hasnodata);
-    RASTER_DEBUGF(3, "rt_band_set_nodata: band->nodataval = %f", band->nodataval);
+       pixtype = band->pixtype;
 
+       RASTER_DEBUGF(3, "rt_band_set_nodata: setting nodata value %g with band type %s", val, rt_pixtype_name(pixtype));
 
-    /* the nodata value was just set, so this band has NODATA */
-               band->hasnodata = 1;
+       /* return -1 on out of range */
+       switch (pixtype) {
+               case PT_1BB: {
+                       band->nodataval = rt_util_clamp_to_1BB(val);
+                       checkvalint = band->nodataval;
+                       break;
+               }
+               case PT_2BUI: {
+                       band->nodataval = rt_util_clamp_to_2BUI(val);
+                       checkvalint = band->nodataval;
+                       break;
+               }
+               case PT_4BUI: {
+                       band->nodataval = rt_util_clamp_to_4BUI(val);
+                       checkvalint = band->nodataval;
+                       break;
+               }
+               case PT_8BSI: {
+                       band->nodataval = rt_util_clamp_to_8BSI(val);
+                       checkvalint = band->nodataval;
+                       break;
+               }
+               case PT_8BUI: {
+                       band->nodataval = rt_util_clamp_to_8BUI(val);
+                       checkvalint = band->nodataval;
+                       break;
+               }
+               case PT_16BSI: {
+                       band->nodataval = rt_util_clamp_to_16BSI(val);
+                       checkvalint = band->nodataval;
+                       break;
+               }
+               case PT_16BUI: {
+                       band->nodataval = rt_util_clamp_to_16BUI(val);
+                       checkvalint = band->nodataval;
+                       break;
+               }
+               case PT_32BSI: {
+                       band->nodataval = rt_util_clamp_to_32BSI(val);
+                       checkvalint = band->nodataval;
+                       break;
+               }
+               case PT_32BUI: {
+                       band->nodataval = rt_util_clamp_to_32BUI(val);
+                       checkvaluint = band->nodataval;
+                       break;
+               }
+               case PT_32BF: {
+                       band->nodataval = rt_util_clamp_to_32F(val);
+                       checkvalfloat = band->nodataval;
+                       break;
+               }
+               case PT_64BF: {
+                       band->nodataval = val;
+                       checkvaldouble = band->nodataval;
+                       break;
+               }
+               default: {
+                       rterror("rt_band_set_nodata: Unknown pixeltype %d", pixtype);
+                       band->hasnodata = 0;
+                       return ES_ERROR;
+               }
+       }
 
-               /* also set isnodata flag to false */
-               band->isnodata = 0;
+       RASTER_DEBUGF(3, "rt_band_set_nodata: band->hasnodata = %d", band->hasnodata);
+       RASTER_DEBUGF(3, "rt_band_set_nodata: band->nodataval = %f", band->nodataval); 
+       /* the nodata value was just set, so this band has NODATA */
+       band->hasnodata = 1;
 
-    /* If the nodata value is different from the previous one, we need to check
-     * again if the band is a nodata band
-     * TODO: NO, THAT'S TOO SLOW!!!
-     */
+       /* also set isnodata flag to false */
+       band->isnodata = 0; 
 
-    /*
-    if (FLT_NEQ(band->nodataval, oldnodataval))
-        rt_band_check_is_nodata(band);
-    */
-
-    if (rt_util_dbl_trunc_warning(
-                       val,
-                       checkvalint, checkvaluint,
-                       checkvalfloat, checkvaldouble,
-                       pixtype
-               )) {
-        return 1;
-               }
+       if (rt_util_dbl_trunc_warning(
+               val,
+               checkvalint, checkvaluint,
+               checkvalfloat, checkvaldouble,
+               pixtype
+       ) && converted != NULL) {
+               *converted = 1;
+       }
 
-    return 0;
+       return ES_NONE;
 }
 
 /**
@@ -1989,9 +1971,9 @@ rt_band_set_nodata(rt_band band, double val) {
  * @param vals : the pixel values to apply
  * @param len : # of elements in vals
  *
- * @return 1 on success, 0 on error
+ * @return ES_NONE on success, ES_ERROR on error
  */
-int
+rt_errorstate
 rt_band_set_pixel_line(
        rt_band band,
        int x, int y,
@@ -2006,7 +1988,7 @@ rt_band_set_pixel_line(
 
        if (band->offline) {
                rterror("rt_band_set_pixel_line not implemented yet for OFFDB bands");
-               return 0;
+               return ES_ERROR;
        }
 
        pixtype = band->pixtype;
@@ -2017,7 +1999,7 @@ rt_band_set_pixel_line(
                y < 0 || y >= band->height
        ) {
                rterror("rt_band_set_pixel_line: Coordinates out of range (%d, %d) vs (%d, %d)", x, y, band->width, band->height);
-               return 0;
+               return ES_ERROR;
        }
 
        data = rt_band_get_data(band);
@@ -2027,7 +2009,7 @@ rt_band_set_pixel_line(
        /* make sure len of values to copy don't exceed end of data */
        if (len > (band->width * band->height) - offset) {
                rterror("rt_band_set_pixel_line: Unable to apply pixels as values length exceeds end of data");
-               return 0;
+               return ES_ERROR;
        }
 
        switch (pixtype) {
@@ -2079,7 +2061,7 @@ rt_band_set_pixel_line(
                }
                default: {
                        rterror("rt_band_set_pixel_line: Unknown pixeltype %d", pixtype);
-                       return 0;
+                       return ES_ERROR;
                }
        }
 
@@ -2095,7 +2077,7 @@ rt_band_set_pixel_line(
        if (rt_band_get_hasnodata_flag(band))
                rt_band_set_isnodata_flag(band, 0);
 
-       return 1;
+       return ES_NONE;
 }
 
 /**
@@ -2105,20 +2087,20 @@ rt_band_set_pixel_line(
  * @param x : x ordinate (0-based)
  * @param y : y ordinate (0-based)
  * @param val : the pixel value
+ * @param converted : (optional) non-zero if value truncated/clamped/converted
  *
- * @return 0 on success, -1 on error (value out of valid range),
- *   1 on truncation/clamping/converting.
+ * @return ES_NONE on success, ES_ERROR on error
  */
-int
+rt_errorstate
 rt_band_set_pixel(
        rt_band band,
        int x, int y,
-       double val
+       double val,
+       int *converted
 ) {
        rt_pixtype pixtype = PT_END;
        unsigned char* data = NULL;
        uint32_t offset = 0;
-       int rtn = 0;
 
        int32_t checkvalint = 0;
        uint32_t checkvaluint = 0;
@@ -2127,9 +2109,12 @@ rt_band_set_pixel(
 
        assert(NULL != band);
 
+       if (converted != NULL)
+               *converted = 0;
+
        if (band->offline) {
                rterror("rt_band_set_pixel not implemented yet for OFFDB bands");
-               return -1;
+               return ES_ERROR;
        }
 
        pixtype = band->pixtype;
@@ -2139,18 +2124,24 @@ rt_band_set_pixel(
                y < 0 || y >= band->height
        ) {
                rterror("rt_band_set_pixel: Coordinates out of range");
-               return -1;
+               return ES_ERROR;
        }
 
        /* check that clamped value isn't clamped NODATA */
        if (band->hasnodata && pixtype != PT_64BF) {
                double newval;
-               if (rt_band_corrected_clamped_value(band, val, &newval) == 1) {
+               int corrected;
+
+               rt_band_corrected_clamped_value(band, val, &newval, &corrected);
+
+               if (corrected) {
 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
                        rtwarn("Value for pixel %d x %d has been corrected as clamped value becomes NODATA", x, y);
 #endif
                        val = newval;
-                       rtn = 1;
+
+                       if (converted != NULL)
+                               *converted = 1;
                }
        }
 
@@ -2221,40 +2212,27 @@ rt_band_set_pixel(
                }
                default: {
                        rterror("rt_band_set_pixel: Unknown pixeltype %d", pixtype);
-                       return -1;
+                       return ES_ERROR;
                }
        }
 
        /* If the stored value is not NODATA, reset the isnodata flag */
-       if (
-               FLT_NEQ(val, band->nodataval) ||
-               rt_band_clamped_value_is_nodata(band, val) != 1
-       ) {
+       if (!rt_band_clamped_value_is_nodata(band, val)) {
                RASTER_DEBUG(3, "Band has a value that is not NODATA. Setting isnodata to FALSE");
                band->isnodata = FALSE;
        }
 
-       /*
-        * If the pixel was a nodata value, now the band may be NODATA band)
-        * TODO: NO, THAT'S TOO SLOW!!!
-        */
-       /*
-       else {
-               rt_band_check_is_nodata(band);
-       }
-       */
-
        /* Overflow checking */
        if (rt_util_dbl_trunc_warning(
                val,
                checkvalint, checkvaluint,
                checkvalfloat, checkvaldouble,
                pixtype
-       )) {
-               return 1;
+       ) && converted != NULL) {
+               *converted = 1;
        }
 
-       return rtn;
+       return ES_NONE;
 }
 
 /**
@@ -2272,12 +2250,12 @@ rt_band_set_pixel(
  * @param x : pixel column (0-based)
  * @param y : pixel row (0-based)
  * @param len : the number of pixels to get
- * @param vals : the pixel values
+ * @param **vals : the pixel values
  * @param *nvals : the number of pixel values being returned
  *
- * @return 0 on success, -1 on error
+ * @return ES_NONE on success, ES_ERROR on error
  */
-int rt_band_get_pixel_line(
+rt_errorstate rt_band_get_pixel_line(
        rt_band band,
        int x, int y,
        uint16_t len,
@@ -2302,16 +2280,16 @@ int rt_band_get_pixel_line(
                y < 0 || y >= band->height
        ) {
                rtwarn("Attempting to get pixel values with out of range raster coordinates: (%d, %d)", x, y);
-               return -1;
+               return ES_ERROR;
        }
 
        if (len < 1)
-               return 0;
+               return ES_NONE;
 
        data = rt_band_get_data(band);
        if (data == NULL) {
                rterror("rt_band_get_pixel_line: Cannot get band data");
-               return -1;
+               return ES_ERROR;
        }
 
        /* +1 for the nodata value */
@@ -2337,7 +2315,7 @@ int rt_band_get_pixel_line(
        _vals = rtalloc(_nvals * pixsize);
        if (_vals == NULL) {
                rterror("rt_band_get_pixel_line: Unable to allocate memory for pixel values");
-               return -1;
+               return ES_ERROR;
        }
 
        /* copy pixels */
@@ -2346,7 +2324,7 @@ int rt_band_get_pixel_line(
        *vals = _vals;
        *nvals = _nvals;
 
-       return 0;
+       return ES_NONE;
 }
 
 /**
@@ -2361,7 +2339,7 @@ int rt_band_get_pixel_line(
  *
  * @return 0 on success, -1 on error (value out of valid range).
  */
-int
+rt_errorstate
 rt_band_get_pixel(
        rt_band band,
        int x, int y,
@@ -2383,7 +2361,7 @@ rt_band_get_pixel(
                y < 0 || y >= band->height
        ) {
                rtwarn("Attempting to get pixel value with out of range raster coordinates: (%d, %d)", x, y);
-               return -1;
+               return ES_ERROR;
        }
 
        /* band is NODATA */
@@ -2391,13 +2369,13 @@ rt_band_get_pixel(
                RASTER_DEBUG(3, "Band's isnodata flag is TRUE. Returning NODATA value");
                *value = band->nodataval;
                if (nodata != NULL) *nodata = 1;
-               return 0;
+               return ES_NONE;
        }
 
        data = rt_band_get_data(band);
        if (data == NULL) {
                rterror("rt_band_get_pixel: Cannot get band data");
-               return -1;
+               return ES_ERROR;
        }
 
        /* +1 for the nodata value */
@@ -2484,21 +2462,17 @@ rt_band_get_pixel(
                }
                default: {
                        rterror("rt_band_get_pixel: Unknown pixeltype %d", pixtype);
-                       return -1;
+                       return ES_ERROR;
                }
        }
 
        /* set NODATA flag */
        if (band->hasnodata && nodata != NULL) {
-               if (
-                       FLT_EQ(*value, band->nodataval) ||
-                       rt_band_clamped_value_is_nodata(band, *value) == 1
-               ) {
+               if (rt_band_clamped_value_is_nodata(band, *value))
                        *nodata = 1;
-               }
        }
 
-       return 0;
+       return ES_NONE;
 }
 
 /**
@@ -2808,6 +2782,7 @@ rt_band_get_pixel_of_value(
        int err;
        int count = 0;
        int isnodata = 0;
+       int isequal = 0;
 
        rt_pixel pixel = NULL;
 
@@ -2833,13 +2808,13 @@ rt_band_get_pixel_of_value(
                                continue;
 
                        for (i = 0; i < searchcount; i++) {
-                               if (
-                                       FLT_NEQ(pixval, searchset[i]) ||
-                                       (rt_pixtype_compare_clamped_values(band->pixtype, searchset[i], pixval) != 1)
-                               ) {
+                               if (rt_pixtype_compare_clamped_values(band->pixtype, searchset[i], pixval, &isequal) != ES_NONE) {
                                        continue;
                                }
 
+                               if (FLT_NEQ(pixval, searchset[i]) || !isequal)
+                                       continue;
+
                                /* match found */
                                count++;
                                if (*pixels == NULL)
@@ -2869,9 +2844,9 @@ rt_band_get_pixel_of_value(
  * @param band : the band whose NODATA value will be returned
  * @param nodata : the band's NODATA value
  *
- * @return 0 if error, 1 otherwise
+ * @return ES_NONE or ES_ERROR
  */
-int
+rt_errorstate
 rt_band_get_nodata(rt_band band, double *nodata) { 
        assert(NULL != band);
 
@@ -2879,10 +2854,10 @@ rt_band_get_nodata(rt_band band, double *nodata) {
 
        if (!band->hasnodata) {
                rterror("rt_band_get_nodata: Band has no NODATA value");
-               return 0;
+               return ES_ERROR;
        }
 
-       return 1;
+       return ES_NONE;
 }
 
 double
@@ -2929,35 +2904,37 @@ rt_band_check_is_nodata(rt_band band) {
 }
 
 /**
- * Compare clamped value to band's clamped NODATA value.  If unclamped
- * value is exactly unclamped NODATA value, function returns -1.
+ * Compare clamped value to band's clamped NODATA value.
  *
  * @param band : the band whose NODATA value will be used for comparison
  * @param val : the value to compare to the NODATA value
  *
- * @return 1 if clamped value is clamped NODATA
+ * @return 2 if unclamped value is unclamped NODATA
+ *         1 if clamped value is clamped NODATA
  *         0 if clamped value is NOT clamped NODATA
- *         -1 otherwise
  */
 int
 rt_band_clamped_value_is_nodata(rt_band band, double val) {
+       int isequal = 0;
 
        assert(NULL != band);
 
-       /* no NODATA, so no need to test */
+       /* no NODATA, so never equal */
        if (!band->hasnodata)
-               return -1;
+               return 0;
 
        /* value is exactly NODATA */
-       if (FLT_EQ(val, band->nodataval)) {
-               return -1;
-       }
+       if (FLT_EQ(val, band->nodataval))
+               return 2;
 
-       return rt_pixtype_compare_clamped_values(
+       /* ignore error from rt_pixtype_compare_clamped_values */
+       rt_pixtype_compare_clamped_values(
                band->pixtype,
-               val,
-               band->nodataval
+               val, band->nodataval,
+               &isequal
        );
+
+       return isequal ? 1 : 0;
 }
 
 /**
@@ -2967,20 +2944,29 @@ rt_band_clamped_value_is_nodata(rt_band band, double val) {
  * 
  * @param band : the band whose NODATA value will be used for comparison
  * @param val : the value to compare to the NODATA value and correct
- * @param newval : pointer to corrected value
+ * @param *newval : pointer to corrected value
+ * @param *corrected : (optional) non-zero if val was corrected
  *
- * @return 0 on error, 1 if corrected, -1 otherwise
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int
-rt_band_corrected_clamped_value(rt_band band, double val, double *newval) {
+rt_errorstate
+rt_band_corrected_clamped_value(
+       rt_band band,
+       double val,
+       double *newval, int *corrected
+) {
        double minval = 0.;
 
        assert(NULL != band);
+       assert(NULL != newval);
+
+       if (corrected != NULL)
+               *corrected = 0;
 
-       /* check that value needs correcting */
+       /* no need to correct if clamped values IS NOT clamped NODATA */
        if (rt_band_clamped_value_is_nodata(band, val) != 1) {
                *newval = val;
-               return -1;
+               return ES_NONE;
        }
 
        minval = rt_pixtype_get_min_value(band->pixtype);
@@ -3047,11 +3033,14 @@ rt_band_corrected_clamped_value(rt_band band, double val, double *newval) {
                case PT_64BF:
                        break;
                default:
-                       rterror("rt_band_alternative_clamped_value: Unknown pixeltype %d", band->pixtype);
-                       return 0;
+                       rterror("rt_band_corrected_clamped_value: Unknown pixeltype %d", band->pixtype);
+                       return ES_ERROR;
        }
 
-       return 1;
+       if (corrected != NULL)
+               *corrected = 1;
+
+       return ES_NONE;
 }
 
 /**
@@ -3065,7 +3054,7 @@ rt_band_corrected_clamped_value(rt_band band, double val, double *newval) {
  * @param cM : M component of 1-pass stddev for coverage
  * @param cQ : Q component of 1-pass stddev for coverage
  *
- * @return the summary statistics for a band
+ * @return the summary statistics for a band or NULL
  */
 rt_bandstats
 rt_band_get_summary_stats(
@@ -3368,7 +3357,7 @@ rt_band_get_summary_stats(
  *   if min = max, min and max are not used
  * @param rtn_count : set to the number of bins being returned
  *
- * @return the histogram of the data
+ * @return the histogram of the data or NULL
  */
 rt_histogram
 rt_band_get_histogram(
@@ -3625,7 +3614,7 @@ rt_band_get_histogram(
  * @param quantiles_count : the number of quantiles to be computed
  * @param rtn_count : set to the number of quantiles being returned
  *
- * @return the default set of or requested quantiles for a band
+ * @return the default set of or requested quantiles for a band or NULL
  */
 rt_quantile
 rt_band_get_quantiles(
@@ -3957,7 +3946,7 @@ static void quantile_llist_index_reset(struct quantile_llist *qll) {
  * @param quantiles_count : the number of quantiles to be computed
  * @param rtn_count : the number of quantiles being returned
  *
- * @return the default set of or requested quantiles for a band
+ * @return the default set of or requested quantiles for a band or NULL
  */
 rt_quantile
 rt_band_get_quantiles_stream(
@@ -4550,7 +4539,7 @@ rt_band_get_quantiles_stream(
  * @param rtn_total : the number of pixels examined in the band
  * @param rtn_count : the number of value counts being returned
  *
- * @return the number of times the provide value(s) occur
+ * @return the number of times the provide value(s) occur or NULL
  */
 rt_valuecount
 rt_band_get_value_count(
@@ -4807,7 +4796,7 @@ rt_band_get_value_count(
  * @param exprset : array of rt_reclassexpr structs
  * @param exprcount : number of elements in expr
  *
- * @return a new rt_band or 0 on error
+ * @return a new rt_band or NULL on error
  */
 rt_band
 rt_band_reclass(
@@ -5123,7 +5112,7 @@ rt_band_reclass(
                                , (NULL != expr) ? expr->dst.max : 0
                                , nv
                        );
-                       if (rt_band_set_pixel(band, x, y, nv) < 0) {
+                       if (rt_band_set_pixel(band, x, y, nv, NULL) != ES_NONE) {
                                rterror("rt_band_reclass: Could not assign value to new band");
                                rt_band_destroy(band);
                                rtdealloc(mem);
@@ -5139,6 +5128,17 @@ rt_band_reclass(
 
 /*- rt_raster --------------------------------------------------------*/
 
+/**
+ * Construct a raster with given dimensions.
+ *
+ * Transform will be set to identity.
+ * Will contain no bands.
+ *
+ * @param width : number of pixel columns
+ * @param height : number of pixel rows
+ *
+ * @return an rt_raster or NULL if out of memory
+ */
 rt_raster
 rt_raster_new(uint32_t width, uint32_t height) {
        rt_raster ret = NULL;
@@ -5455,7 +5455,7 @@ rt_raster_get_band(rt_raster raster, int n) {
  *
  * @return identifier (position) for the just-added raster, or -1 on error
  */
-int32_t
+int
 rt_raster_add_band(rt_raster raster, rt_band band, int index) {
     rt_band *oldbands = NULL;
     rt_band oldband = NULL;
@@ -5532,7 +5532,7 @@ rt_raster_add_band(rt_raster raster, rt_band band, int index) {
  *
  * @return identifier (position) for the just-added raster, or -1 on error
  */
-int32_t
+int
 rt_raster_generate_new_band(
        rt_raster raster, rt_pixtype pixtype,
        double initialvalue, uint32_t hasnodata, double nodatavalue,
@@ -5722,10 +5722,12 @@ rt_raster_generate_new_band(
  * @param gt : optional input parameter, 6-element geotransform matrix
  * @param igt : output parameter, 6-element inverse geotransform matrix
  *
- * @return if zero, error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_get_inverse_geotransform_matrix(rt_raster raster,
-       double *gt, double *igt) {
+rt_errorstate rt_raster_get_inverse_geotransform_matrix(
+       rt_raster raster,
+       double *gt, double *igt
+) {
        double _gt[6] = {0};
 
        assert((raster != NULL || gt != NULL));
@@ -5738,10 +5740,10 @@ int rt_raster_get_inverse_geotransform_matrix(rt_raster raster,
        
        if (!GDALInvGeoTransform(_gt, igt)) {
                rterror("rt_raster_get_inverse_geotransform_matrix: Unable to compute inverse geotransform matrix");
-               return 0;
+               return ES_ERROR;
        }
 
-       return 1;
+       return ES_NONE;
 }
 
 /**
@@ -5796,10 +5798,11 @@ rt_raster_set_geotransform_matrix(rt_raster raster,
  * @param yw : output parameter, Y ordinate of the geographical point
  * @param gt : input/output parameter, 3x2 geotransform matrix
  *
- * @return if zero, error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error 
  */
-int
-rt_raster_cell_to_geopoint(rt_raster raster,
+rt_errorstate
+rt_raster_cell_to_geopoint(
+       rt_raster raster,
        double xr, double yr,
        double *xw, double *yw,
        double *gt
@@ -5834,7 +5837,7 @@ rt_raster_cell_to_geopoint(rt_raster raster,
        RASTER_DEBUGF(4, "GDALApplyGeoTransform (c -> g) for (%f, %f) = (%f, %f)",
                xr, yr, *xw, *yw);
 
-       return 1;
+       return ES_NONE;
 }
 
 /**
@@ -5847,10 +5850,11 @@ rt_raster_cell_to_geopoint(rt_raster raster,
  * @param yr : output parameter, the pixel's row
  * @param igt : input/output parameter, inverse geotransform matrix
  *
- * @return if zero, error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int
-rt_raster_geopoint_to_cell(rt_raster raster,
+rt_errorstate
+rt_raster_geopoint_to_cell(
+       rt_raster raster,
        double xw, double yw,
        double *xr, double *yr,
        double *igt
@@ -5874,9 +5878,9 @@ rt_raster_geopoint_to_cell(rt_raster raster,
                FLT_EQ(_igt[4], 0.) &&
                FLT_EQ(_igt[5], 0.)
        ) {
-               if (!rt_raster_get_inverse_geotransform_matrix(raster, NULL, _igt)) {
+               if (rt_raster_get_inverse_geotransform_matrix(raster, NULL, _igt) != ES_NONE) {
                        rterror("rt_raster_geopoint_to_cell: Unable to get inverse geotransform matrix");
-                       return 0;
+                       return ES_ERROR;
                }
        }
 
@@ -5899,7 +5903,7 @@ rt_raster_geopoint_to_cell(rt_raster raster,
        RASTER_DEBUGF(4, "Corrected GDALApplyGeoTransform (g -> c) for (%f, %f) = (%f, %f)",
                xw, yw, *xr, *yr);
 
-       return 1;
+       return ES_NONE;
 }
 
 /**
@@ -6350,9 +6354,9 @@ rt_raster_get_convex_hull(rt_raster raster) {
  * @param raster : the raster to get envelope of
  * @param env : pointer to rt_envelope
  *
- * @return 0 on error, 1 on success
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_get_envelope(
+rt_errorstate rt_raster_get_envelope(
        rt_raster raster,
        rt_envelope *env
 ) {
@@ -6394,9 +6398,9 @@ int rt_raster_get_envelope(
                        &(_w[0]), &(_w[1]),
                        _gt
                );
-               if (!rtn) {
+               if (rtn != ES_NONE) {
                        rterror("rt_raster_get_envelope: Unable to compute spatial coordinates for raster pixel");
-                       return 0;
+                       return ES_ERROR;
                }
 
                if (!set) {
@@ -6419,7 +6423,7 @@ int rt_raster_get_envelope(
                }
        }
 
-       return 1;
+       return ES_NONE;
 }
 
 /*
@@ -6606,7 +6610,7 @@ rt_raster_compute_skewed_raster(
                                        &(_r[0]), &(_r[1]),
                                        _igt
                                );
-                               if (!rtn) {
+                               if (rtn != ES_NONE) {
                                        rterror("rt_raster_compute_skewed_raster: Unable to compute raster pixel for spatial coordinates");
                                        rt_raster_destroy(raster);
                                        return NULL;
@@ -6650,7 +6654,7 @@ rt_raster_compute_skewed_raster(
                                        &(_w[0]), &(_w[1]),
                                        _gt
                                );
-                               if (!rtn) {
+                               if (rtn != ES_NONE) {
                                        rterror("rt_raster_compute_skewed_raster: Unable to compute spatial coordinates for raster pixel");
                                        rt_raster_destroy(raster);
                                        return NULL;
@@ -6689,7 +6693,7 @@ rt_raster_compute_skewed_raster(
                &(_r[0]), &(_r[1]),
                _igt
        );
-       if (!rtn) {
+       if (rtn != ES_NONE) {
                rterror("rt_raster_compute_skewed_raster: Unable to compute raster pixel for spatial coordinates");
                rt_raster_destroy(raster);
                return NULL;
@@ -8257,8 +8261,9 @@ rt_raster_has_band(rt_raster raster, int nband) {
  * @param toindex : index of new band in destination raster, 0-based
  *
  * @return The band index of the second raster where the new band is copied.
+ *   -1 if error
  */
-int32_t
+int
 rt_raster_copy_band(
        rt_raster torast, rt_raster fromrast,
        int fromindex, int toindex
@@ -8317,7 +8322,7 @@ rt_raster_copy_band(
  *                   and add to the new raster (0 based)
  * @param count : number of elements in bandNums
  *
- * @return a new rt_raster or 0 on error
+ * @return a new rt_raster or NULL on error
  */
 rt_raster
 rt_raster_from_band(rt_raster raster, uint32_t *bandNums, int count) {
@@ -8374,7 +8379,7 @@ rt_raster_from_band(rt_raster raster, uint32_t *bandNums, int count) {
  * @param band : new band to add to raster
  * @param index : index of band to replace (0-based)
  *
- * @return 0 on error or replaced band
+ * @return NULL on error or replaced band
  */
 rt_band
 rt_raster_replace_band(rt_raster raster, rt_band band, int index) {
@@ -8959,7 +8964,7 @@ rt_raster_to_gdal_mem(
  *
  * @param ds : the GDAL dataset to convert to a raster
  *
- * @return raster
+ * @return raster or NULL
  */
 rt_raster
 rt_raster_from_gdal_dataset(GDALDatasetH ds) {
@@ -9232,7 +9237,7 @@ rt_raster_from_gdal_dataset(GDALDatasetH ds) {
  * @param max_err : maximum error measured in input pixels permitted
  *   (0.0 for exact calculations)
  *
- * @return the warped raster
+ * @return the warped raster or NULL
  */
 rt_raster rt_raster_gdal_warp(
        rt_raster raster, const char *src_srs,
@@ -9643,12 +9648,12 @@ rt_raster rt_raster_gdal_warp(
                        rt_raster_set_offsets(rast, *grid_xw, *grid_yw);
 
                        /* process upper-left corner */
-                       if (!rt_raster_geopoint_to_cell(
+                       if (rt_raster_geopoint_to_cell(
                                rast,
                                extent.UpperLeftX, extent.UpperLeftY,
                                &(_r[0]), &(_r[1]),
                                NULL
-                       )) {
+                       ) != ES_NONE) {
                                rterror("rt_raster_gdal_warp: Unable to compute raster pixel for spatial coordinates");
 
                                rt_raster_destroy(rast);
@@ -9660,12 +9665,12 @@ rt_raster rt_raster_gdal_warp(
                                return NULL;
                        }
 
-                       if (!rt_raster_cell_to_geopoint(
+                       if (rt_raster_cell_to_geopoint(
                                rast,
                                _r[0], _r[1],
                                &(_w[0]), &(_w[1]),
                                NULL
-                       )) {
+                       ) != ES_NONE) {
                                rterror("rt_raster_gdal_warp: Unable to compute spatial coordinates for raster pixel");
 
                                rt_raster_destroy(rast);
@@ -9687,12 +9692,12 @@ rt_raster rt_raster_gdal_warp(
                                        rt_raster_set_offsets(rast, extent.UpperLeftX, extent.UpperLeftY);
 
                                        /* get upper-right corner */
-                                       if (!rt_raster_cell_to_geopoint(
+                                       if (rt_raster_cell_to_geopoint(
                                                rast,
                                                rast->width, 0,
                                                &(_c[0]), &(_c[1]),
                                                NULL
-                                       )) {
+                                       ) != ES_NONE) {
                                                rterror("rt_raster_gdal_warp: Unable to compute spatial coordinates for raster pixel");
 
                                                rt_raster_destroy(rast);
@@ -9716,12 +9721,12 @@ rt_raster rt_raster_gdal_warp(
                                        rt_raster_set_offsets(rast, extent.UpperLeftX, extent.UpperLeftY);
 
                                        /* get upper-right corner */
-                                       if (!rt_raster_cell_to_geopoint(
+                                       if (rt_raster_cell_to_geopoint(
                                                rast,
                                                0, rast->height,
                                                &(_c[0]), &(_c[1]),
                                                NULL
-                                       )) {
+                                       ) != ES_NONE) {
                                                rterror("rt_raster_gdal_warp: Unable to compute spatial coordinates for raster pixel");
 
                                                rt_raster_destroy(rast);
@@ -9765,12 +9770,12 @@ rt_raster rt_raster_gdal_warp(
                        (NULL != scale_x) &&
                        (*scale_x < 0.)
                ) {
-                       if (!rt_raster_cell_to_geopoint(
+                       if (rt_raster_cell_to_geopoint(
                                rast,
                                rast->width, 0,
                                &(_w[0]), &(_w[1]),
                                NULL
-                       )) {
+                       ) != ES_NONE) {
                                rterror("rt_raster_gdal_warp: Unable to compute spatial coordinates for raster pixel");
 
                                rt_raster_destroy(rast);
@@ -9795,12 +9800,12 @@ rt_raster rt_raster_gdal_warp(
                        (NULL != scale_y) &&
                        (*scale_y > 0)
                ) {
-                       if (!rt_raster_cell_to_geopoint(
+                       if (rt_raster_cell_to_geopoint(
                                rast,
                                0, rast->height,
                                &(_w[0]), &(_w[1]),
                                NULL
-                       )) {
+                       ) != ES_NONE) {
                                rterror("rt_raster_gdal_warp: Unable to compute spatial coordinates for raster pixel");
 
                                rt_raster_destroy(rast);
@@ -10216,7 +10221,7 @@ _rti_rasterize_arg_destroy(_rti_rasterize_arg arg) {
  * @param skew_y : the Y skew of the raster
  * @param options : array of options.  only option is "ALL_TOUCHED"
  *
- * @return the raster of the provided geometry
+ * @return the raster of the provided geometry or NULL
  */
 rt_raster
 rt_raster_gdal_rasterize(const unsigned char *wkb,
@@ -10708,12 +10713,12 @@ rt_raster_gdal_rasterize(const unsigned char *wkb,
                        rt_raster_set_offsets(rast, *grid_xw, *grid_yw);
 
                        /* process upper-left corner */
-                       if (!rt_raster_geopoint_to_cell(
+                       if (rt_raster_geopoint_to_cell(
                                rast,
                                extent.UpperLeftX, extent.UpperLeftY,
                                &(_r[0]), &(_r[1]),
                                NULL
-                       )) {
+                       ) != ES_NONE) {
                                rterror("rt_raster_gdal_rasterize: Unable to compute raster pixel for spatial coordinates");
 
                                rt_raster_destroy(rast);
@@ -10726,12 +10731,12 @@ rt_raster_gdal_rasterize(const unsigned char *wkb,
                                return NULL;
                        }
 
-                       if (!rt_raster_cell_to_geopoint(
+                       if (rt_raster_cell_to_geopoint(
                                rast,
                                _r[0], _r[1],
                                &(_w[0]), &(_w[1]),
                                NULL
-                       )) {
+                       ) != ES_NONE) {
                                rterror("rt_raster_gdal_rasterize: Unable to compute spatial coordinates for raster pixel");
 
                                rt_raster_destroy(rast);
@@ -10754,12 +10759,12 @@ rt_raster_gdal_rasterize(const unsigned char *wkb,
                                        rt_raster_set_offsets(rast, extent.UpperLeftX, extent.UpperLeftY);
 
                                        /* get upper-right corner */
-                                       if (!rt_raster_cell_to_geopoint(
+                                       if (rt_raster_cell_to_geopoint(
                                                rast,
                                                rast->width, 0,
                                                &(_c[0]), &(_c[1]),
                                                NULL
-                                       )) {
+                                       ) != ES_NONE) {
                                                rterror("rt_raster_gdal_rasterize: Unable to compute spatial coordinates for raster pixel");
 
                                                rt_raster_destroy(rast);
@@ -10784,12 +10789,12 @@ rt_raster_gdal_rasterize(const unsigned char *wkb,
                                        rt_raster_set_offsets(rast, extent.UpperLeftX, extent.UpperLeftY);
 
                                        /* get upper-right corner */
-                                       if (!rt_raster_cell_to_geopoint(
+                                       if (rt_raster_cell_to_geopoint(
                                                rast,
                                                0, rast->height,
                                                &(_c[0]), &(_c[1]),
                                                NULL
-                                       )) {
+                                       ) != ES_NONE) {
                                                rterror("rt_raster_gdal_rasterize: Unable to compute spatial coordinates for raster pixel");
 
                                                rt_raster_destroy(rast);
@@ -10835,12 +10840,12 @@ rt_raster_gdal_rasterize(const unsigned char *wkb,
                ) {
                        RASTER_DEBUG(3, "Processing negative scale-x");
 
-                       if (!rt_raster_cell_to_geopoint(
+                       if (rt_raster_cell_to_geopoint(
                                rast,
                                _dim[0], 0,
                                &(_w[0]), &(_w[1]),
                                NULL
-                       )) {
+                       ) != ES_NONE) {
                                rterror("rt_raster_gdal_rasterize: Unable to compute spatial coordinates for raster pixel");
 
                                rt_raster_destroy(rast);
@@ -10867,12 +10872,12 @@ rt_raster_gdal_rasterize(const unsigned char *wkb,
                ) {
                        RASTER_DEBUG(3, "Processing positive scale-y");
 
-                       if (!rt_raster_cell_to_geopoint(
+                       if (rt_raster_cell_to_geopoint(
                                rast,
                                0, _dim[1],
                                &(_w[0]), &(_w[1]),
                                NULL
-                       )) {
+                       ) != ES_NONE) {
                                rterror("rt_raster_gdal_rasterize: Unable to compute spatial coordinates for raster pixel");
 
                                rt_raster_destroy(rast);
@@ -11141,8 +11146,8 @@ rt_raster_gdal_rasterize(const unsigned char *wkb,
                                if (nodata)
                                        val = nodataval;
 
-                               err = rt_band_set_pixel(band, x, y, val);
-                               if (err < 0) {
+                               err = rt_band_set_pixel(band, x, y, val, NULL);
+                               if (err != ES_NONE) {
                                        rterror("rt_raster_gdal_rasterize: Unable to set pixel value");
                                        _rti_rasterize_arg_destroy(arg);
                                        rt_raster_destroy(rast);
@@ -11412,12 +11417,12 @@ int rt_raster_intersects_algorithm(
 
                                                        /* unable to convert point to cell */
                                                        noval1 = 0;
-                                                       if (!rt_raster_geopoint_to_cell(
+                                                       if (rt_raster_geopoint_to_cell(
                                                                rast1,
                                                                Qw[pX], Qw[pY],
                                                                &(Qr[pX]), &(Qr[pY]),
                                                                igt1
-                                                       )) {
+                                                       ) != ES_NONE) {
                                                                noval1 = 1;
                                                        }
                                                        /* cell is outside bounds of grid */
@@ -11435,12 +11440,12 @@ int rt_raster_intersects_algorithm(
 
                                                        /* unable to convert point to cell */
                                                        noval2 = 0;
-                                                       if (!rt_raster_geopoint_to_cell(
+                                                       if (rt_raster_geopoint_to_cell(
                                                                rast2,
                                                                Qw[pX], Qw[pY],
                                                                &(Qr[pX]), &(Qr[pY]),
                                                                igt2
-                                                       )) {
+                                                       ) != ES_NONE) {
                                                                noval2 = 1;
                                                        }
                                                        /* cell is outside bounds of grid */
@@ -11530,9 +11535,9 @@ int rt_raster_intersects_algorithm(
  *   if nband2 gte zero, nband1 must be gte zero
  * @param intersects : non-zero value if the two rasters' bands intersects
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int
+rt_errorstate
 rt_raster_intersects(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
@@ -11602,7 +11607,7 @@ rt_raster_intersects(
        if (rt_raster_get_srid(rast1) != rt_raster_get_srid(rast2)) {
                rterror("rt_raster_intersects: The two rasters provided have different SRIDs");
                *intersects = 0;
-               return 0;
+               return ES_ERROR;
        }
 
        /* raster extents need to intersect */
@@ -11656,12 +11661,12 @@ rt_raster_intersects(
                        RASTER_DEBUGF(4, "convex hulls of rasters do %sintersect", rtn != 1 ? "NOT " : "");
                        if (rtn != 1) {
                                *intersects = 0;
-                               return 1;
+                               return ES_NONE;
                        }
                        /* band isn't specified */
                        else if (nband1 < 0) {
                                *intersects = 1;
-                               return 1;
+                               return ES_NONE;
                        }
                }
                else {
@@ -11726,7 +11731,7 @@ rt_raster_intersects(
        if (NULL == bandS) {
                rterror("rt_raster_intersects: Unable to get band %d of the first raster", nbandS);
                *intersects = 0;
-               return 0;
+               return ES_ERROR;
        }
 
        hasnodataS = rt_band_get_hasnodata_flag(bandS);
@@ -11738,7 +11743,7 @@ rt_raster_intersects(
        if (NULL == bandL) {
                rterror("rt_raster_intersects: Unable to get band %d of the first raster", nbandL);
                *intersects = 0;
-               return 0;
+               return ES_ERROR;
        }
 
        hasnodataL = rt_band_get_hasnodata_flag(bandL);
@@ -11758,7 +11763,7 @@ rt_raster_intersects(
        ) {
                RASTER_DEBUG(3, "One of the two raster bands is NODATA. The two rasters do not intersect");
                *intersects = 0;
-               return 1;
+               return ES_NONE;
        }
 
        /* special case where a raster can fit inside another raster's pixel */
@@ -11782,12 +11787,12 @@ rt_raster_intersects(
                                                                gtS
                                                        );
 
-                                                       if (!rt_raster_geopoint_to_cell(
+                                                       if (rt_raster_geopoint_to_cell(
                                                                rastL,
                                                                lineS[X1], lineS[Y1],
                                                                &(Qr[pX]), &(Qr[pY]),
                                                                igtL
-                                                       )) {
+                                                       ) != ES_NONE) {
                                                                continue;
                                                        }
 
@@ -11806,7 +11811,7 @@ rt_raster_intersects(
                                                        if ((hasnodataL == FALSE) || !isnodataL) {
                                                                RASTER_DEBUG(3, "The two rasters do intersect");
                                                                *intersects = 1;
-                                                               return 1;
+                                                               return ES_NONE;
                                                        }
                                                }
                                        }
@@ -11824,7 +11829,7 @@ rt_raster_intersects(
                nodataS, nodataL
        );
 
-       if (*intersects) return 1;
+       if (*intersects) return ES_NONE;
 
        RASTER_DEBUG(4, "Testing larger raster vs smaller raster");
        *intersects = rt_raster_intersects_algorithm(
@@ -11834,12 +11839,12 @@ rt_raster_intersects(
                nodataL, nodataS
        );
 
-       if (*intersects) return 1;
+       if (*intersects) return ES_NONE;
 
        RASTER_DEBUG(3, "The two rasters do not intersect");
 
        *intersects = 0;
-       return 1;
+       return ES_NONE;
 }
 
 /******************************************************************************
@@ -11847,7 +11852,7 @@ rt_raster_intersects(
 ******************************************************************************/
 
 static
-int rt_raster_geos_spatial_relationship(
+rt_errorstate rt_raster_geos_spatial_relationship(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        rt_geos_spatial_test testtype,
@@ -11864,6 +11869,7 @@ int rt_raster_geos_spatial_relationship(
 
        assert(NULL != rast1);
        assert(NULL != rast2);
+       assert(NULL != testresult);
 
        if (nband1 < 0 && nband2 < 0) {
                nband1 = -1;
@@ -11880,7 +11886,7 @@ int rt_raster_geos_spatial_relationship(
        /* same srid */
        if (rt_raster_get_srid(rast1) != rt_raster_get_srid(rast2)) {
                rterror("rt_raster_geos_spatial_relationship: The two rasters provided have different SRIDs");
-               return 0;
+               return ES_ERROR;
        }
 
        initGEOS(lwnotice, lwgeom_geos_error);
@@ -11889,20 +11895,20 @@ int rt_raster_geos_spatial_relationship(
        surface1 = rt_raster_surface(rast1, nband1, &rtn);
        if (!rtn) {
                rterror("rt_raster_geos_spatial_relationship: Unable to get surface of the specified band from the first raster");
-               return 0;
+               return ES_ERROR;
        }
        surface2 = rt_raster_surface(rast2, nband2, &rtn);
        if (!rtn) {
                rterror("rt_raster_geos_spatial_relationship: Unable to get surface of the specified band from the second raster");
                lwmpoly_free(surface1);
-               return 0;
+               return ES_ERROR;
        }
 
        /* either surface is NULL, spatial relationship test is false */
        if (surface1 == NULL || surface2 == NULL) {
                if (surface1 != NULL) lwmpoly_free(surface1);
                if (surface2 != NULL) lwmpoly_free(surface2);
-               return 1;
+               return ES_NONE;
        }
 
        /* convert LWMPOLY to GEOSGeometry */
@@ -11911,14 +11917,14 @@ int rt_raster_geos_spatial_relationship(
        if (geom1 == NULL) {
                rterror("rt_raster_geos_spatial_relationship: Unable to convert surface of the specified band from the first raster to a GEOSGeometry");
                lwmpoly_free(surface2);
-               return 0;
+               return ES_ERROR;
        }
 
        geom2 = LWGEOM2GEOS(lwmpoly_as_lwgeom(surface2));
        lwmpoly_free(surface2);
        if (geom2 == NULL) {
                rterror("rt_raster_geos_spatial_relationship: Unable to convert surface of the specified band from the second raster to a GEOSGeometry");
-               return 0;
+               return ES_ERROR;
        }
 
        flag = 0;
@@ -11952,23 +11958,23 @@ int rt_raster_geos_spatial_relationship(
        /* something happened in the spatial relationship test */
        if (rtn == 2) {
                rterror("rt_raster_geos_spatial_relationship: Unable to run the appropriate GEOS spatial relationship test");
-               flag = 0;
+               flag = ES_ERROR;
        }
        /* spatial relationship test ran fine */
        else if (flag >= 0) {
                if (rtn != 0)
                        *testresult = 1;
-               flag = 1;
+               flag = ES_NONE;
        }
        /* flag < 0 for when testtype is unknown */
        else
-               flag = 0;
+               flag = ES_ERROR;
 
        return flag;
 }
 
 /**
- * Return zero if error occurred in function.
+ * Return ES_ERROR if error occurred in function.
  * Parameter overlaps returns non-zero if two rasters overlap
  *
  * @param rast1 : the first raster whose band will be tested
@@ -11981,9 +11987,9 @@ int rt_raster_geos_spatial_relationship(
  *   if nband2 gte zero, nband1 must be gte zero
  * @param overlaps : non-zero value if the two rasters' bands overlaps
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_overlaps(
+rt_errorstate rt_raster_overlaps(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        int *overlaps
@@ -11999,7 +12005,7 @@ int rt_raster_overlaps(
 }
 
 /**
- * Return zero if error occurred in function.
+ * Return ES_ERROR if error occurred in function.
  * Parameter touches returns non-zero if two rasters touch
  *
  * @param rast1 : the first raster whose band will be tested
@@ -12012,9 +12018,9 @@ int rt_raster_overlaps(
  *   if nband2 gte zero, nband1 must be gte zero
  * @param touches : non-zero value if the two rasters' bands touch
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_touches(
+rt_errorstate rt_raster_touches(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        int *touches
@@ -12030,7 +12036,7 @@ int rt_raster_touches(
 }
 
 /**
- * Return zero if error occurred in function.
+ * Return ES_ERROR if error occurred in function.
  * Parameter contains returns non-zero if rast1 contains rast2
  *
  * @param rast1 : the first raster whose band will be tested
@@ -12043,9 +12049,9 @@ int rt_raster_touches(
  *   if nband2 gte zero, nband1 must be gte zero
  * @param contains : non-zero value if rast1 contains rast2
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_contains(
+rt_errorstate rt_raster_contains(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        int *contains
@@ -12061,7 +12067,7 @@ int rt_raster_contains(
 }
 
 /**
- * Return zero if error occurred in function.
+ * Return ES_ERROR if error occurred in function.
  * Parameter contains returns non-zero if rast1 contains properly rast2
  *
  * @param rast1 : the first raster whose band will be tested
@@ -12074,9 +12080,9 @@ int rt_raster_contains(
  *   if nband2 gte zero, nband1 must be gte zero
  * @param contains : non-zero value if rast1 contains properly rast2
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_contains_properly(
+rt_errorstate rt_raster_contains_properly(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        int *contains
@@ -12092,8 +12098,8 @@ int rt_raster_contains_properly(
 }
 
 /**
- * Return zero if error occurred in function.
- * Parameter contains returns non-zero if rast1 covers rast2
+ * Return ES_ERROR if error occurred in function.
+ * Parameter covers returns non-zero if rast1 covers rast2
  *
  * @param rast1 : the first raster whose band will be tested
  * @param nband1 : the 0-based band of raster rast1 to use
@@ -12105,9 +12111,9 @@ int rt_raster_contains_properly(
  *   if nband2 gte zero, nband1 must be gte zero
  * @param covers : non-zero value if rast1 covers rast2
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_covers(
+rt_errorstate rt_raster_covers(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        int *covers
@@ -12123,8 +12129,8 @@ int rt_raster_covers(
 }
 
 /**
- * Return zero if error occurred in function.
- * Parameter contains returns non-zero if rast1 is covered by rast2
+ * Return ES_ERROR if error occurred in function.
+ * Parameter coveredby returns non-zero if rast1 is covered by rast2
  *
  * @param rast1 : the first raster whose band will be tested
  * @param nband1 : the 0-based band of raster rast1 to use
@@ -12136,9 +12142,9 @@ int rt_raster_covers(
  *   if nband2 gte zero, nband1 must be gte zero
  * @param coveredby : non-zero value if rast1 is covered by rast2
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_coveredby(
+rt_errorstate rt_raster_coveredby(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        int *coveredby
@@ -12154,8 +12160,8 @@ int rt_raster_coveredby(
 }
 
 /**
- * Return zero if error occurred in function.
- * Parameter contains returns non-zero if rast1 is within the specified
+ * Return ES_ERROR if error occurred in function.
+ * Parameter dwithin returns non-zero if rast1 is within the specified
  *   distance of rast2
  *
  * @param rast1 : the first raster whose band will be tested
@@ -12169,9 +12175,9 @@ int rt_raster_coveredby(
  * @param dwithin : non-zero value if rast1 is within the specified distance
  *   of rast2
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_within_distance(
+rt_errorstate rt_raster_within_distance(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        double distance,
@@ -12202,33 +12208,33 @@ int rt_raster_within_distance(
        /* same srid */
        if (rt_raster_get_srid(rast1) != rt_raster_get_srid(rast2)) {
                rterror("rt_raster_distance_within: The two rasters provided have different SRIDs");
-               return 0;
+               return ES_ERROR;
        }
 
        /* distance cannot be less than zero */
        if (distance < 0) {
                rterror("rt_raster_distance_within: Distance cannot be less than zero");
-               return 0;
+               return ES_ERROR;
        }
 
        /* get LWMPOLY of each band */
        surface1 = lwmpoly_as_lwgeom(rt_raster_surface(rast1, nband1, &rtn));
        if (!rtn) {
                rterror("rt_raster_distance_within: Unable to get surface of the specified band from the first raster");
-               return 0;
+               return ES_ERROR;
        }
        surface2 = lwmpoly_as_lwgeom(rt_raster_surface(rast2, nband2, &rtn));
        if (!rtn) {
                rterror("rt_raster_distance_within: Unable to get surface of the specified band from the second raster");
                lwgeom_free(surface1);
-               return 0;
+               return ES_ERROR;
        }
 
        /* either surface is NULL, test is false */
        if (surface1 == NULL || surface2 == NULL) {
                if (surface1 != NULL) lwgeom_free(surface1);
                if (surface2 != NULL) lwgeom_free(surface2);
-               return 1;
+               return ES_NONE;
        }
 
        /* get the min distance between the two surfaces */
@@ -12243,12 +12249,12 @@ int rt_raster_within_distance(
 
        RASTER_DEBUGF(3, "(mindist, distance) = (%f, %f, %d)", mindist, distance, *dwithin);
 
-       return 1;
+       return ES_NONE;
 }
 
 /**
- * Return zero if error occurred in function.
- * Parameter contains returns non-zero if rast1 is fully within the specified
+ * Return ES_ERROR if error occurred in function.
+ * Parameter dfwithin returns non-zero if rast1 is fully within the specified
  *   distance of rast2
  *
  * @param rast1 : the first raster whose band will be tested
@@ -12262,9 +12268,9 @@ int rt_raster_within_distance(
  * @param dfwithin : non-zero value if rast1 is fully within the specified
  *   distance of rast2
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_fully_within_distance(
+rt_errorstate rt_raster_fully_within_distance(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        double distance,
@@ -12295,33 +12301,33 @@ int rt_raster_fully_within_distance(
        /* same srid */
        if (rt_raster_get_srid(rast1) != rt_raster_get_srid(rast2)) {
                rterror("rt_raster_distance_within: The two rasters provided have different SRIDs");
-               return 0;
+               return ES_ERROR;
        }
 
        /* distance cannot be less than zero */
        if (distance < 0) {
                rterror("rt_raster_distance_within: Distance cannot be less than zero");
-               return 0;
+               return ES_ERROR;
        }
 
        /* get LWMPOLY of each band */
        surface1 = lwmpoly_as_lwgeom(rt_raster_surface(rast1, nband1, &rtn));
        if (!rtn) {
                rterror("rt_raster_distance_within: Unable to get surface of the specified band from the first raster");
-               return 0;
+               return ES_ERROR;
        }
        surface2 = lwmpoly_as_lwgeom(rt_raster_surface(rast2, nband2, &rtn));
        if (!rtn) {
                rterror("rt_raster_distance_within: Unable to get surface of the specified band from the second raster");
                lwgeom_free(surface1);
-               return 0;
+               return ES_ERROR;
        }
 
        /* either surface is NULL, test is false */
        if (surface1 == NULL || surface2 == NULL) {
                if (surface1 != NULL) lwgeom_free(surface1);
                if (surface2 != NULL) lwgeom_free(surface2);
-               return 1;
+               return ES_NONE;
        }
 
        /* get the maximum distance between the two surfaces */
@@ -12336,20 +12342,20 @@ int rt_raster_fully_within_distance(
 
        RASTER_DEBUGF(3, "(maxdist, distance, dfwithin) = (%f, %f, %d)", maxdist, distance, *dfwithin);
 
-       return 1;
+       return ES_NONE;
 }
 
 /*
- * Return zero if error occurred in function.
+ * Return ES_ERROR if error occurred in function.
  * Paramter aligned returns non-zero if two rasters are aligned
  *
  * @param rast1 : the first raster for alignment test
  * @param rast2 : the second raster for alignment test
  * @param aligned : non-zero value if the two rasters are aligned
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int
+rt_errorstate
 rt_raster_same_alignment(
        rt_raster rast1,
        rt_raster rast2,
@@ -12391,7 +12397,7 @@ rt_raster_same_alignment(
 
        if (err) {
                *aligned = 0;
-               return 1;
+               return ES_NONE;
        }
 
        /* raster coordinates in context of second raster of first raster's upper-left corner */
@@ -12400,10 +12406,10 @@ rt_raster_same_alignment(
                        rast1->ipX, rast1->ipY,
                        &xr, &yr,
                        NULL
-       ) == 0) {
+       ) != ES_NONE) {
                rterror("rt_raster_same_alignment: Unable to get raster coordinates of second raster from first raster's spatial coordinates");
                *aligned = 0;
-               return 0;
+               return ES_ERROR;
        }
 
        /* spatial coordinates of raster coordinates from above */
@@ -12412,10 +12418,10 @@ rt_raster_same_alignment(
                xr, yr,
                &xw, &yw,
                NULL
-       ) == 0) {
+       ) != ES_NONE) {
                rterror("rt_raster_same_alignment: Unable to get spatial coordinates of second raster from raster coordinates");
                *aligned = 0;
-               return 0;
+               return ES_ERROR;
        }
 
        RASTER_DEBUGF(4, "rast1(ipX, ipxY) = (%f, %f)", rast1->ipX, rast1->ipY);
@@ -12426,13 +12432,13 @@ rt_raster_same_alignment(
        if (FLT_EQ(xw, rast1->ipX) && FLT_EQ(yw, rast1->ipY)) {
                RASTER_DEBUG(3, "The two rasters are aligned");
                *aligned = 1;
-               return 1;
+               return ES_NONE;
        }
 
        /* no alignment */
        RASTER_DEBUG(3, "The two rasters are NOT aligned");
        *aligned = 0;
-       return 1;
+       return ES_NONE;
 }
 
 /*
@@ -12472,7 +12478,7 @@ rt_raster_from_two_rasters(
        *noerr = 0;
 
        /* rasters must be aligned */
-       if (!rt_raster_same_alignment(rast1, rast2, &aligned)) {
+       if (rt_raster_same_alignment(rast1, rast2, &aligned) != ES_NONE) {
                rterror("rt_raster_from_two_rasters: Unable to test for alignment on the two rasters");
                return NULL;
        }
@@ -12488,12 +12494,12 @@ rt_raster_from_two_rasters(
        _dim[1][1] = rast2->height;
 
        /* get raster offsets */
-       if (!rt_raster_geopoint_to_cell(
+       if (rt_raster_geopoint_to_cell(
                _rast[1],
                _rast[0]->ipX, _rast[0]->ipY,
                &(_offset[1][0]), &(_offset[1][1]),
                NULL
-       )) {
+       ) != ES_NONE) {
                rterror("rt_raster_from_two_rasters: Unable to compute offsets of the second raster relative to the first raster");
                return NULL;
        }
@@ -12562,12 +12568,12 @@ rt_raster_from_two_rasters(
                                off[3] = _offset[1][3];
 
                        /* upper left corner */
-                       if (!rt_raster_cell_to_geopoint(
+                       if (rt_raster_cell_to_geopoint(
                                _rast[0],
                                off[0], off[1],
                                &(gt[0]), &(gt[3]),
                                NULL
-                       )) {
+                       ) != ES_NONE) {
                                rterror("rt_raster_from_two_rasters: Unable to get spatial coordinates of upper-left pixel of output raster");
                                return NULL;
                        }
@@ -12602,12 +12608,12 @@ rt_raster_from_two_rasters(
                        );
 
                        /* get offsets */
-                       if (!rt_raster_geopoint_to_cell(
+                       if (rt_raster_geopoint_to_cell(
                                _rast[0],
                                gt[0], gt[3],
                                &(_offset[0][0]), &(_offset[0][1]),
                                NULL
-                       )) {
+                       ) != ES_NONE) {
                                rterror("rt_raster_from_two_rasters: Unable to get offsets of the FIRST raster relative to the output raster");
                                rt_raster_destroy(raster);
                                return NULL;
@@ -12615,12 +12621,12 @@ rt_raster_from_two_rasters(
                        _offset[0][0] *= -1;
                        _offset[0][1] *= -1;
 
-                       if (!rt_raster_geopoint_to_cell(
+                       if (rt_raster_geopoint_to_cell(
                                _rast[1],
                                gt[0], gt[3],
                                &(_offset[1][0]), &(_offset[1][1]),
                                NULL
-                       )) {
+                       ) != ES_NONE) {
                                rterror("rt_raster_from_two_rasters: Unable to get offsets of the SECOND raster relative to the output raster");
                                rt_raster_destroy(raster);
                                return NULL;
@@ -12683,12 +12689,12 @@ rt_raster_from_two_rasters(
 
                        /* get upper-left corner */
                        rt_raster_get_geotransform_matrix(_rast[0], gt);
-                       if (!rt_raster_cell_to_geopoint(
+                       if (rt_raster_cell_to_geopoint(
                                _rast[0],
                                off[0], off[1],
                                &(gt[0]), &(gt[3]),
                                gt
-                       )) {
+                       ) != ES_NONE) {
                                rterror("rt_raster_from_two_rasters: Unable to get spatial coordinates of upper-left pixel of output raster");
                                rt_raster_destroy(raster);
                                return NULL;
@@ -12697,12 +12703,12 @@ rt_raster_from_two_rasters(
                        rt_raster_set_geotransform_matrix(raster, gt);
 
                        /* get offsets */
-                       if (!rt_raster_geopoint_to_cell(
+                       if (rt_raster_geopoint_to_cell(
                                _rast[0],
                                gt[0], gt[3],
                                &(_offset[0][0]), &(_offset[0][1]),
                                NULL
-                       )) {
+                       ) != ES_NONE) {
                                rterror("rt_raster_from_two_rasters: Unable to get pixel coordinates to compute the offsets of the FIRST raster relative to the output raster");
                                rt_raster_destroy(raster);
                                return NULL;
@@ -12710,12 +12716,12 @@ rt_raster_from_two_rasters(
                        _offset[0][0] *= -1;
                        _offset[0][1] *= -1;
 
-                       if (!rt_raster_geopoint_to_cell(
+                       if (rt_raster_geopoint_to_cell(
                                _rast[1],
                                gt[0], gt[3],
                                &(_offset[1][0]), &(_offset[1][1]),
                                NULL
-                       )) {
+                       ) != ES_NONE) {
                                rterror("rt_raster_from_two_rasters: Unable to get pixel coordinates to compute the offsets of the SECOND raster relative to the output raster");
                                rt_raster_destroy(raster);
                                return NULL;
@@ -13648,7 +13654,7 @@ rt_raster_iterator(
 
                /* check custom first if set. also skip if rasters are the same */
                if (extenttype == ET_CUSTOM && rast != customextent) {
-                       if (!rt_raster_same_alignment(rast, customextent, &aligned)) {
+                       if (rt_raster_same_alignment(rast, customextent, &aligned) != ES_NONE) {
                                rterror("rt_raster_iterator: Unable to test for alignment between reference raster and custom extent");
 
                                _rti_iterator_arg_destroy(_param);
@@ -13666,7 +13672,7 @@ rt_raster_iterator(
                        if (_param->isempty[i] || rast == _param->raster[i])
                                continue;
 
-                       if (!rt_raster_same_alignment(rast, _param->raster[i], &aligned)) {
+                       if (rt_raster_same_alignment(rast, _param->raster[i], &aligned) != ES_NONE) {
                                rterror("rt_raster_iterator: Unable to test for alignment between reference raster and raster %d", i);
 
                                _rti_iterator_arg_destroy(_param);
@@ -14050,7 +14056,7 @@ rt_raster_iterator(
                                        NULL, NULL
                                );
                                rtdealloc(npixels);
-                               if (!status) {
+                               if (status != ES_NONE) {
                                        rterror("rt_raster_iterator: Unable to create 2D array of neighborhood");
 
                                        _rti_iterator_arg_destroy(_param);
@@ -14084,17 +14090,17 @@ rt_raster_iterator(
                        /* burn value to pixel */
                        status = 0;
                        if (!nodata) {
-                               status = rt_band_set_pixel(rtnband, _x, _y, value);
+                               status = rt_band_set_pixel(rtnband, _x, _y, value, NULL);
                                RASTER_DEBUGF(4, "burning pixel (%d, %d) with value: %f", _x, _y, value);
                        }
                        else if (!hasnodata) {
-                               status = rt_band_set_pixel(rtnband, _x, _y, minval);
+                               status = rt_band_set_pixel(rtnband, _x, _y, minval, NULL);
                                RASTER_DEBUGF(4, "burning pixel (%d, %d) with minval: %f", _x, _y, minval);
                        }
                        else {
                                RASTER_DEBUGF(4, "NOT burning pixel (%d, %d)", _x, _y);
                        }
-                       if (status < 0) {
+                       if (status != ES_NONE) {
                                rterror("rt_raster_iterator: Unable to set pixel value");
 
                                _rti_iterator_arg_destroy(_param);
index 9f261bd5eabd0759372971326a96576c84133431..aee353867ad9b78a1acee853de571d09a9c1d956 100644 (file)
@@ -159,6 +159,13 @@ typedef struct {
 /**
  * Enum definitions
  */
+
+/* function return error states */
+typedef enum {
+       ES_NONE = 0, /* no error */
+       ES_ERROR = 1 /* generic error */
+} rt_errorstate;
+
 /* Pixel types */
 typedef enum {
     PT_1BB=0,     /* 1-bit boolean            */
@@ -305,6 +312,10 @@ void rt_set_handlers(rt_allocator allocator, rt_reallocator reallocator,
 
 /**
  * Return size in bytes of a value in the given pixtype
+ *
+ * @param pixtype : the pixel type to get byte size for
+ *
+ * @return the pixel type's byte size
  */
 int rt_pixtype_size(rt_pixtype pixtype);
 
@@ -312,6 +323,10 @@ int rt_pixtype_size(rt_pixtype pixtype);
  * Return alignment requirements for data in the given pixel type.
  * Fast access to pixel values of this type must be aligned to as
  * many bytes as returned by this function.
+ *
+ * @param pixtype : the pixel type to get alignment requirements for
+ *
+ * @return the alignment requirements
  */
 int rt_pixtype_alignment(rt_pixtype pixtype);
 
@@ -331,15 +346,20 @@ rt_pixtype rt_pixtype_index_from_name(const char* pixname);
 double rt_pixtype_get_min_value(rt_pixtype pixtype);
 
 /**
- * Returns 1 if clamped values are equal, 0 if not equal, -1 if error
+ * Test to see if two values are equal when clamped
  *
  * @param pixtype : the pixel type to clamp the provided values
  * @param val : value to compare to reference value
  * @param refval : reference value to be compared with
+ * @param isequal : non-zero if clamped values are equal, 0 otherwise
  *
- * @return 1 if clamped values are equal, 0 if not equal, -1 if error
+ * @return ES_NONE on success, ES_ERROR on error
  */
-int rt_pixtype_compare_clamped_values(rt_pixtype pixtype, double val, double refval);
+rt_errorstate rt_pixtype_compare_clamped_values(
+       rt_pixtype pixtype,
+       double val, double refval,
+       int *isequal
+);
 
 /*- rt_pixel ----------------------------------------------------------*/
 
@@ -361,9 +381,9 @@ int rt_pixtype_compare_clamped_values(rt_pixtype pixtype, double val, double ref
  * @param dimx : size of value and nodata along the X axis
  * @param dimy : size of value and nodata along the Y axis
  *
- * @return 0 on error, otherwise 1
+ * @return ES_NONE on success, ES_ERROR on error
  */
-int rt_pixel_set_to_array(
+rt_errorstate rt_pixel_set_to_array(
        rt_pixel npixel, int count,
        int x, int y,
        uint16_t distancex, uint16_t distancey,
@@ -392,7 +412,7 @@ int rt_pixel_set_to_array(
  *                    allocated for the whole lifetime of the returned
  *                    rt_band.
  *
- * @return an rt_band, or 0 on failure
+ * @return an rt_band or NULL on failure
  */
 rt_band rt_band_new_inline(
        uint16_t width, uint16_t height,
@@ -418,7 +438,7 @@ rt_band rt_band_new_inline(
  *                    responsible to keep it allocated for the whole
  *                    lifetime of the returned rt_band.
  *
- * @return an rt_band, or 0 on failure
+ * @return an rt_band or NULL on failure
  */
 rt_band rt_band_new_offline(
        uint16_t width, uint16_t height,
@@ -451,27 +471,62 @@ rt_band rt_band_duplicate(rt_band band);
 int rt_band_is_offline(rt_band band);
 
 /**
- * Return bands' external path (only valid when rt_band_is_offline
+ * Return band's external path (only valid when rt_band_is_offline
  * returns non-zero).
+ *
+ * @param band : the band
+ *
+ * @return string or NULL if band is not offline
  */
 const char* rt_band_get_ext_path(rt_band band);
 
 /**
  * Return bands' external band number (only valid when
  * rt_band_is_offline returns non-zero).
+ *
+ * @param band : the band
+ * @param bandnum : external band number (0-based)
+ *
+ * @return ES_NONE or ES_ERROR if band is NOT out-db
  */
-uint8_t rt_band_get_ext_band_num(rt_band band);
+rt_errorstate rt_band_get_ext_band_num(rt_band band, uint8_t *bandnum);
 
-/* Get pixeltype of this band */
+/**
+ * Return pixeltype of this band
+ *
+ * @param band : the band
+ *
+ * @return band's pixeltype
+ */
 rt_pixtype rt_band_get_pixtype(rt_band band);
 
-/* Get width of this band */
+/**
+ * Return width of this band
+ *
+ * @param band : the band
+ *
+ * @return band's width
+ */
 uint16_t rt_band_get_width(rt_band band);
 
-/* Get height of this band */
+/**
+ * Return height of this band
+ *
+ * @param band : the band
+ *
+ * @return band's height
+ */
 uint16_t rt_band_get_height(rt_band band);
 
-/* Get own_data flag */
+/**
+ * Return 0 (FALSE) or non-zero (TRUE) indicating if rt_band is responsible
+ * for managing the memory for band data
+ *
+ * @param band : the band
+ *
+ * @return non-zero indicates that rt_band manages the memory
+ * allocated for band data
+ */
 int rt_band_get_ownsdata_flag(rt_band band);
 
 /* set ownsdata flag */
@@ -482,7 +537,7 @@ void rt_band_set_ownsdata_flag(rt_band band, int flag);
        *
        * @param band : the band who's data to get
        *
-       * @return void pointer to band data
+       * @return pointer to band data or NULL if error
        */
 void* rt_band_get_data(rt_band band);
 
@@ -493,9 +548,9 @@ void* rt_band_get_data(rt_band band);
        *
        * @param band : the band who's data to get
        *
-       * @return 0 if success, non-zero if failure
+       * @return ES_NONE if success, ES_ERROR if failure
        */
-int rt_band_load_offline_data(rt_band band);
+rt_errorstate rt_band_load_offline_data(rt_band band);
 
 /**
  * Destroy a raster band
@@ -525,12 +580,16 @@ void rt_band_set_hasnodata_flag(rt_band band, int flag);
  *
  * @param band : the band on which to set the isnodata flag
  * @param flag : the new isnodata flag value. Must be 1 or 0
+ *
+ * @return ES_NONE or ES_ERROR
  */
-void rt_band_set_isnodata_flag(rt_band band, int flag);
+rt_errorstate rt_band_set_isnodata_flag(rt_band band, int flag);
 
 /**
- * Get hasnodata flag value
+ * Get isnodata flag value
+ *
  * @param band : the band on which to check the isnodata flag
+ *
  * @return the hasnodata flag.
  */
 int rt_band_get_isnodata_flag(rt_band band);
@@ -540,11 +599,12 @@ int rt_band_get_isnodata_flag(rt_band band);
  *
  * @param band : the band to set nodata value to
  * @param val : the nodata value
+ * @param converted : (optional) if non-zero, value was
+ * truncated/clamped/converted
  *
- * @return 0 on success, -1 on error (invalid pixel type),
- *   1 on truncation/clamping/converting.
+ * @return ES_NONE or ES_ERROR
  */
-int rt_band_set_nodata(rt_band band, double val);
+rt_errorstate rt_band_set_nodata(rt_band band, double val, int *converted);
 
 /**
  * Get NODATA value
@@ -552,9 +612,9 @@ int rt_band_set_nodata(rt_band band, double val);
  * @param band: the band whose NODATA value will be returned
  * @param nodata: the band's NODATA value
  *
- * @return 0 if error, 1 otherwise
+ * @return ES_NONE or ES_ERROR
  */
-int rt_band_get_nodata(rt_band band, double *nodata);
+rt_errorstate rt_band_get_nodata(rt_band band, double *nodata);
 
 /**
  * Set values of multiple pixels.  Unlike rt_band_set_pixel,
@@ -573,9 +633,9 @@ int rt_band_get_nodata(rt_band band, double *nodata);
  * @param vals : the pixel values to apply
  * @param len : # of elements in vals
  *
- * @return 1 on success, 0 on error
+ * @return ES_NONE on success, ES_ERROR on error
  */
-int rt_band_set_pixel_line(
+rt_errorstate rt_band_set_pixel_line(
        rt_band band,
        int x, int y,
        void *vals, uint16_t len
@@ -588,14 +648,15 @@ int rt_band_set_pixel_line(
  * @param x : pixel column (0-based)
  * @param y : pixel row (0-based)
  * @param val : the pixel value
+ * @param converted : (optional) non-zero if value truncated/clamped/converted
  *
- * @return 0 on success, -1 on error (value out of valid range),
- *   1 on truncation/clamping/converting.
+ * @return ES_NONE on success, ES_ERROR on error
  */
-int rt_band_set_pixel(
+rt_errorstate rt_band_set_pixel(
        rt_band band,
        int x, int y,
-       double val
+       double val,
+       int *converted
 );
 
 /**
@@ -613,12 +674,12 @@ int rt_band_set_pixel(
  * @param x : pixel column (0-based)
  * @param y : pixel row (0-based)
  * @param len : the number of pixels to get
- * @param vals : the pixel values
+ * @param **vals : the pixel values
  * @param *nvals : the number of pixel values being returned
  *
- * @return 0 on success, -1 on error
+ * @return ES_NONE on success, ES_ERROR on error
  */
-int rt_band_get_pixel_line(
+rt_errorstate rt_band_get_pixel_line(
        rt_band band,
        int x, int y,
        uint16_t len,
@@ -635,9 +696,9 @@ int rt_band_get_pixel_line(
  * @param *value : pixel value
  * @param *nodata : 0 if pixel is not NODATA
  *
- * @return 0 on success, -1 on error (value out of valid range).
+ * @return ES_NONE on success, ES_ERROR on error
  */
-int rt_band_get_pixel(
+rt_errorstate rt_band_get_pixel(
        rt_band band,
        int x, int y,
        double *value,
@@ -710,9 +771,9 @@ int rt_band_check_is_nodata(rt_band band);
  * @param band : the band whose NODATA value will be used for comparison
  * @param val : the value to compare to the NODATA value
  *
- * @return 1 if clamped value is clamped NODATA
- *         0 if clamped value is NOT clamped NODATA
- *         -1 if error
+ * @return 2 if unclamped value is unclamped NODATA
+ *         1 if clamped value is clamped NODATA
+ *         0 if clamped values is NOT clamped NODATA
  */
 int rt_band_clamped_value_is_nodata(rt_band band, double val);
 
@@ -723,12 +784,17 @@ int rt_band_clamped_value_is_nodata(rt_band band, double val);
  * 
  * @param band : the band whose NODATA value will be used for comparison
  * @param val : the value to compare to the NODATA value and correct
- * @param newval : pointer to corrected value
+ * @param *newval : pointer to corrected value
+ * @param *corrected : (optional) non-zero if val was corrected
  *
- * @return 0 on error, 1 if corrected, -1 otherwise
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int
-rt_band_corrected_clamped_value(rt_band band, double val, double *newval);
+rt_errorstate
+rt_band_corrected_clamped_value(
+       rt_band band,
+       double val,
+       double *newval, int *corrected
+);
 
 /**
  * Compute summary statistics for a band
@@ -741,10 +807,13 @@ rt_band_corrected_clamped_value(rt_band band, double val, double *newval);
  * @param cM : M component of 1-pass stddev for coverage
  * @param cQ : Q component of 1-pass stddev for coverage
  *
- * @return the summary statistics for a band
+ * @return the summary statistics for a band or NULL
  */
-rt_bandstats rt_band_get_summary_stats(rt_band band, int exclude_nodata_value,
-       double sample, int inc_vals, uint64_t *cK, double *cM, double *cQ);
+rt_bandstats rt_band_get_summary_stats(
+       rt_band band,
+       int exclude_nodata_value, double sample, int inc_vals,
+       uint64_t *cK, double *cM, double *cQ
+);
        
 /**
  * Count the distribution of data
@@ -762,11 +831,14 @@ rt_bandstats rt_band_get_summary_stats(rt_band band, int exclude_nodata_value,
  *   if min = max, min and max are not used
  * @param rtn_count : set to the number of bins being returned
  *
- * @return the histogram of the data
+ * @return the histogram of the data or NULL
  */
-rt_histogram rt_band_get_histogram(rt_bandstats stats,
+rt_histogram rt_band_get_histogram(
+       rt_bandstats stats,
        int bin_count, double *bin_widths, int bin_widths_count,
-       int right, double min, double max, uint32_t *rtn_count);
+       int right, double min, double max,
+       uint32_t *rtn_count
+);
 
 /**
  * Compute the default set of or requested quantiles for a set of data
@@ -777,14 +849,16 @@ rt_histogram rt_band_get_histogram(rt_bandstats stats,
  * @param quantiles_count : the number of quantiles to be computed
  * @param rtn_count : the number of quantiles being returned
  *
- * @return the default set of or requested quantiles for a band
+ * @return the default set of or requested quantiles for a band or NULL
  */
 rt_quantile rt_band_get_quantiles(rt_bandstats stats,
        double *quantiles, int quantiles_count, uint32_t *rtn_count);
 
 struct quantile_llist;
-int quantile_llist_destroy(struct quantile_llist **list,
-       uint32_t list_count);
+int quantile_llist_destroy(
+       struct quantile_llist **list,
+       uint32_t list_count
+);
 
 /**
  * Compute the default set of or requested quantiles for a coverage
@@ -811,14 +885,16 @@ int quantile_llist_destroy(struct quantile_llist **list,
  * @param quantiles_count : the number of quantiles to be computed
  * @param rtn_count : the number of quantiles being returned
  *
- * @return the default set of or requested quantiles for a band
+ * @return the default set of or requested quantiles for a band or NULL
  */
-rt_quantile rt_band_get_quantiles_stream(rt_band band,
+rt_quantile rt_band_get_quantiles_stream(
+       rt_band band,
        int exclude_nodata_value, double sample,
        uint64_t cov_count,
        struct quantile_llist **qlls, uint32_t *qlls_count,
        double *quantiles, int quantiles_count,
-       uint32_t *rtn_count);
+       uint32_t *rtn_count
+);
 
 /**
  * Count the number of times provided value(s) occur in
@@ -832,11 +908,13 @@ rt_quantile rt_band_get_quantiles_stream(rt_band band,
  * @param rtn_total : the number of pixels examined in the band
  * @param rtn_count : the number of value counts being returned
  *
- * @return the number of times the provide value(s) occur
+ * @return the number of times the provide value(s) occur or NULL
  */
-rt_valuecount rt_band_get_value_count(rt_band band, int exclude_nodata_value,
-       double *search_values, uint32_t search_values_count,
-       double roundto, uint32_t *rtn_total, uint32_t *rtn_count);
+rt_valuecount rt_band_get_value_count(
+       rt_band band, int exclude_nodata_value,
+       double *search_values, uint32_t search_values_count, double roundto,
+       uint32_t *rtn_total, uint32_t *rtn_count
+);
 
 /**
  * Returns new band with values reclassified
@@ -848,11 +926,13 @@ rt_valuecount rt_band_get_value_count(rt_band band, int exclude_nodata_value,
  * @param exprset : array of rt_reclassexpr structs
  * @param exprcount : number of elements in expr
  *
- * @return a new rt_band or 0 on error
+ * @return a new rt_band or NULL on error
  */
-rt_band rt_band_reclass(rt_band srcband, rt_pixtype pixtype,
+rt_band rt_band_reclass(
+       rt_band srcband, rt_pixtype pixtype,
        uint32_t hasnodata, double nodataval,
-       rt_reclassexpr *exprset, int exprcount);
+       rt_reclassexpr *exprset, int exprcount
+);
 
 /*- rt_raster --------------------------------------------------------*/
 
@@ -865,7 +945,7 @@ rt_band rt_band_reclass(rt_band srcband, rt_pixtype pixtype,
  * @param width : number of pixel columns
  * @param height : number of pixel rows
  *
- * @return an rt_raster or 0 if out of memory
+ * @return an rt_raster or NULL if out of memory
  */
 rt_raster rt_raster_new(uint32_t width, uint32_t height);
 
@@ -875,7 +955,7 @@ rt_raster rt_raster_new(uint32_t width, uint32_t height);
  * @param wkb : an octet stream
  * @param wkbsize : size (in bytes) of the wkb octet stream
  *
- * @return an rt_raster or 0 on error (out of memory or
+ * @return an rt_raster or NULL on error (out of memory or
  *         malformed WKB).
  *
  */
@@ -888,7 +968,7 @@ rt_raster rt_raster_from_wkb(const uint8_t* wkb,
  * @param hexwkb : an hex-encoded stream
  * @param hexwkbsize : size (in bytes) of the hexwkb stream
  *
- * @return an rt_raster or 0 on error (out of memory or
+ * @return an rt_raster or NULL on error (out of memory or
  *         malformed WKB).
  *
  */
@@ -900,6 +980,8 @@ rt_raster rt_raster_from_hexwkb(const char* hexwkb,
  *
  * @param raster : the raster
  * @param wkbsize : will be set to the size of returned wkb form
+ *
+ * @return WKB of raster or NULL on error
  */
 uint8_t *rt_raster_to_wkb(rt_raster raster,
                                     uint32_t *wkbsize);
@@ -910,6 +992,8 @@ uint8_t *rt_raster_to_wkb(rt_raster raster,
  * @param raster : the raster
  * @param hexwkbsize : will be set to the size of returned wkb form,
  *                     not including the null termination
+ *
+ * @return HEXWKB of raster or NULL on error
  */
 char *rt_raster_to_hexwkb(rt_raster raster,
                                     uint32_t *hexwkbsize);
@@ -922,7 +1006,6 @@ char *rt_raster_to_hexwkb(rt_raster raster,
  * the one associated with the pointers pointing
  * at them).
  *
-
  * @param raster : the raster to destroy
  */
 void rt_raster_destroy(rt_raster raster);
@@ -930,7 +1013,14 @@ void rt_raster_destroy(rt_raster raster);
 /* Get number of bands */
 int rt_raster_get_num_bands(rt_raster raster);
 
-/* Return Nth band, or 0 if unavailable */
+/**
+ * Return Nth band, or NULL if unavailable
+ *
+ * @param raster : the raster
+ * @param bandNum : 0-based index of the band to return
+ *
+ * Return band at specified index or NULL if error
+ */
 rt_band rt_raster_get_band(rt_raster raster, int bandNum);
 
 /* Get number of rows */
@@ -949,7 +1039,7 @@ uint16_t rt_raster_get_height(rt_raster raster);
  *
  * @return identifier (position) for the just-added raster, or -1 on error
  */
-int32_t rt_raster_add_band(rt_raster raster, rt_band band, int index);
+int rt_raster_add_band(rt_raster raster, rt_band band, int index);
 
 /**
  * Generate a new inline band and add it to a raster.
@@ -963,7 +1053,7 @@ int32_t rt_raster_add_band(rt_raster raster, rt_band band, int index);
  *
  * @return identifier (position) for the just-added raster, or -1 on error
  */
-int32_t rt_raster_generate_new_band(
+int rt_raster_generate_new_band(
        rt_raster raster,
        rt_pixtype pixtype,
        double initialvalue,
@@ -1156,17 +1246,18 @@ int32_t rt_raster_get_srid(rt_raster raster);
  * @param gt : optional input parameter, 6-element geotransform matrix
  * @param igt : output parameter, 6-element inverse geotransform matrix
  *
- * @return if zero, error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_get_inverse_geotransform_matrix(rt_raster raster,
-       double *gt, double *igt);
+rt_errorstate rt_raster_get_inverse_geotransform_matrix(
+       rt_raster raster,
+       double *gt, double *igt
+);
 
 /**
  * Get 6-element array of raster geotransform matrix
  *
  * @param raster : the raster to get matrix of
  * @param gt : output parameter, 6-element geotransform matrix
- *
  */
 void rt_raster_get_geotransform_matrix(rt_raster raster,
        double *gt);
@@ -1191,12 +1282,14 @@ void rt_raster_set_geotransform_matrix(rt_raster raster,
  * @param yw : output parameter, Y ordinate of the geographical point
  * @param gt : input/output parameter, 3x2 geotransform matrix
  *
- * @return if zero, error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_cell_to_geopoint(rt_raster raster,
+rt_errorstate rt_raster_cell_to_geopoint(
+       rt_raster raster,
        double xr, double yr,
        double* xw, double* yw,
-       double *gt);
+       double *gt
+);
 
 /**
  * Convert an xw, yw map point to a xr, yr raster point
@@ -1208,12 +1301,14 @@ int rt_raster_cell_to_geopoint(rt_raster raster,
  * @param yr : output parameter, the pixel's row
  * @param igt : input/output parameter, inverse geotransform matrix
  *
- * @return if zero, error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_geopoint_to_cell(rt_raster raster,
+rt_errorstate rt_raster_geopoint_to_cell(
+       rt_raster raster,
        double xw, double yw,
        double *xr, double *yr,
-       double *igt);
+       double *igt
+);
 
 /**
  * Get raster's polygon convex hull.
@@ -1225,7 +1320,6 @@ int rt_raster_geopoint_to_cell(rt_raster raster,
  * @param raster : the raster to get info from
  *
  * @return the convex hull, or NULL on error.
- *
  */
 LWPOLY* rt_raster_get_convex_hull(rt_raster raster);
 
@@ -1237,9 +1331,9 @@ LWPOLY* rt_raster_get_convex_hull(rt_raster raster);
  * @param raster : the raster to get envelope of
  * @param env : pointer to rt_envelope
  *
- * @return 0 on error, 1 on success
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_get_envelope(
+rt_errorstate rt_raster_get_envelope(
        rt_raster raster,
        rt_envelope *env
 );
@@ -1367,8 +1461,9 @@ int rt_raster_has_band(rt_raster raster, int nband);
  * @param toindex : index of new band in destination raster, 0-based
  *
  * @return The band index of the second raster where the new band is copied.
+ *   -1 if error
  */
-int32_t rt_raster_copy_band(
+int rt_raster_copy_band(
        rt_raster torast, rt_raster fromrast,
        int fromindex, int toindex
 );
@@ -1382,7 +1477,7 @@ int32_t rt_raster_copy_band(
  *                   and add to the new raster (0 based)
  * @param count : number of elements in bandNums
  *
- * @return a new rt_raster or 0 on error
+ * @return a new rt_raster or NULL on error
  */
 rt_raster rt_raster_from_band(rt_raster raster, uint32_t *bandNums,
        int count);
@@ -1394,7 +1489,7 @@ rt_raster rt_raster_from_band(rt_raster raster, uint32_t *bandNums,
  * @param band : new band to add to raster
  * @param index : index of band to replace (0-based)
  *
- * @return 0 on error or replaced band
+ * @return NULL on error or replaced band
  */
 rt_band rt_raster_replace_band(rt_raster raster, rt_band band,
        int index);
@@ -1464,7 +1559,7 @@ GDALDatasetH rt_raster_to_gdal_mem(
  *
  * @param ds : the GDAL dataset to convert to a raster
  *
- * @return raster
+ * @return raster or NULL
  */
 rt_raster rt_raster_from_gdal_dataset(GDALDatasetH ds);
 
@@ -1496,7 +1591,7 @@ rt_raster rt_raster_from_gdal_dataset(GDALDatasetH ds);
  * @param max_err : maximum error measured in input pixels permitted
  *   (0.0 for exact calculations)
  *
- * @return the warped raster
+ * @return the warped raster or NULL
  */
 rt_raster rt_raster_gdal_warp(rt_raster raster, const char *src_srs,
        const char *dst_srs,
@@ -1531,7 +1626,7 @@ rt_raster rt_raster_gdal_warp(rt_raster raster, const char *src_srs,
  * @param skew_y : the Y skew of the raster
  * @param options : array of options.  only option is "ALL_TOUCHED"
  *
- * @return the raster of the provided geometry
+ * @return the raster of the provided geometry or NULL
  */
 rt_raster rt_raster_gdal_rasterize(const unsigned char *wkb,
        uint32_t wkb_len, const char *srs,
@@ -1547,7 +1642,7 @@ rt_raster rt_raster_gdal_rasterize(const unsigned char *wkb,
 );
 
 /**
- * Return zero if error occurred in function.
+ * Return ES_ERROR if error occurred in function.
  * Parameter intersects returns non-zero if two rasters intersect
  *
  * @param rast1 : the first raster whose band will be tested
@@ -1560,16 +1655,16 @@ rt_raster rt_raster_gdal_rasterize(const unsigned char *wkb,
  *   if nband2 gte zero, nband1 must be gte zero
  * @param intersects : non-zero value if the two rasters' bands intersects
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_intersects(
+rt_errorstate rt_raster_intersects(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        int *intersects
 );
 
 /**
- * Return zero if error occurred in function.
+ * Return ES_ERROR if error occurred in function.
  * Parameter overlaps returns non-zero if two rasters overlap
  *
  * @param rast1 : the first raster whose band will be tested
@@ -1582,16 +1677,16 @@ int rt_raster_intersects(
  *   if nband2 gte zero, nband1 must be gte zero
  * @param overlaps : non-zero value if the two rasters' bands overlaps
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_overlaps(
+rt_errorstate rt_raster_overlaps(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        int *overlaps
 );
 
 /**
- * Return zero if error occurred in function.
+ * Return ES_ERROR if error occurred in function.
  * Parameter contains returns non-zero if rast1 contains rast2
  *
  * @param rast1 : the first raster whose band will be tested
@@ -1604,16 +1699,16 @@ int rt_raster_overlaps(
  *   if nband2 gte zero, nband1 must be gte zero
  * @param contains : non-zero value if rast1 contains rast2
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_contains(
+rt_errorstate rt_raster_contains(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        int *contains
 );
 
 /**
- * Return zero if error occurred in function.
+ * Return ES_ERROR if error occurred in function.
  * Parameter contains returns non-zero if rast1 contains properly rast2
  *
  * @param rast1 : the first raster whose band will be tested
@@ -1626,16 +1721,16 @@ int rt_raster_contains(
  *   if nband2 gte zero, nband1 must be gte zero
  * @param contains : non-zero value if rast1 contains properly rast2
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_contains_properly(
+rt_errorstate rt_raster_contains_properly(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        int *contains
 );
 
 /**
- * Return zero if error occurred in function.
+ * Return ES_ERROR if error occurred in function.
  * Parameter touches returns non-zero if two rasters touch
  *
  * @param rast1 : the first raster whose band will be tested
@@ -1648,17 +1743,17 @@ int rt_raster_contains_properly(
  *   if nband2 gte zero, nband1 must be gte zero
  * @param touches : non-zero value if the two rasters' bands touch
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_touches(
+rt_errorstate rt_raster_touches(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        int *touches
 );
 
 /**
- * Return zero if error occurred in function.
- * Parameter contains returns non-zero if rast1 covers rast2
+ * Return ES_ERROR if error occurred in function.
+ * Parameter covers returns non-zero if rast1 covers rast2
  *
  * @param rast1 : the first raster whose band will be tested
  * @param nband1 : the 0-based band of raster rast1 to use
@@ -1670,17 +1765,17 @@ int rt_raster_touches(
  *   if nband2 gte zero, nband1 must be gte zero
  * @param covers : non-zero value if rast1 covers rast2
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_covers(
+rt_errorstate rt_raster_covers(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        int *covers
 );
 
 /**
- * Return zero if error occurred in function.
- * Parameter contains returns non-zero if rast1 is covered by rast2
+ * Return ES_ERROR if error occurred in function.
+ * Parameter coveredby returns non-zero if rast1 is covered by rast2
  *
  * @param rast1 : the first raster whose band will be tested
  * @param nband1 : the 0-based band of raster rast1 to use
@@ -1692,17 +1787,17 @@ int rt_raster_covers(
  *   if nband2 gte zero, nband1 must be gte zero
  * @param coveredby : non-zero value if rast1 is covered by rast2
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_coveredby(
+rt_errorstate rt_raster_coveredby(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        int *coveredby
 );
 
 /**
- * Return zero if error occurred in function.
- * Parameter contains returns non-zero if rast1 is within the specified
+ * Return ES_ERROR if error occurred in function.
+ * Parameter dwithin returns non-zero if rast1 is within the specified
  *   distance of rast2
  *
  * @param rast1 : the first raster whose band will be tested
@@ -1716,9 +1811,9 @@ int rt_raster_coveredby(
  * @param dwithin : non-zero value if rast1 is within the specified distance
  *   of rast2
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_within_distance(
+rt_errorstate rt_raster_within_distance(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        double distance,
@@ -1726,8 +1821,8 @@ int rt_raster_within_distance(
 );
 
 /**
- * Return zero if error occurred in function.
- * Parameter contains returns non-zero if rast1 is fully within the specified
+ * Return ES_ERROR if error occurred in function.
+ * Parameter dfwithin returns non-zero if rast1 is fully within the specified
  *   distance of rast2
  *
  * @param rast1 : the first raster whose band will be tested
@@ -1741,9 +1836,9 @@ int rt_raster_within_distance(
  * @param dfwithin : non-zero value if rast1 is fully within the specified
  *   distance of rast2
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_fully_within_distance(
+rt_errorstate rt_raster_fully_within_distance(
        rt_raster rast1, int nband1,
        rt_raster rast2, int nband2,
        double distance,
@@ -1751,16 +1846,16 @@ int rt_raster_fully_within_distance(
 );
 
 /*
- * Return zero if error occurred in function.
+ * Return ES_ERROR if error occurred in function.
  * Paramter aligned returns non-zero if two rasters are aligned
  *
  * @param rast1 : the first raster for alignment test
  * @param rast2 : the second raster for alignment test
  * @param aligned : non-zero value if the two rasters are aligned
  *
- * @return if zero, an error occurred in function
+ * @return ES_NONE if success, ES_ERROR if error
  */
-int rt_raster_same_alignment(
+rt_errorstate rt_raster_same_alignment(
        rt_raster rast1,
        rt_raster rast2,
        int *aligned
index 1a3204d7417be9da65cdd0638f1e15307a9f5040..558fc20fdadf5daa19f7ab317ea1f63a2bf0a08d 100644 (file)
@@ -2174,7 +2174,7 @@ Datum RASTER_setBandNoDataValue(PG_FUNCTION_ARGS)
                                nodata = PG_GETARG_FLOAT8(2);
 
                                /* Set the band's nodata value */
-                               rt_band_set_nodata(band, nodata);
+                               rt_band_set_nodata(band, nodata, NULL);
 
                                /* Recheck all pixels if requested */
                                if (forcechecking)
@@ -2416,7 +2416,7 @@ Datum RASTER_getPixelValue(PG_FUNCTION_ARGS)
 
     /* If the result is -1 or the value is nodata and we take nodata into account
      * then return nodata = NULL */
-    if (result == -1 || (exclude_nodata_value && isnodata)) {
+    if (result != ES_NONE || (exclude_nodata_value && isnodata)) {
         rt_raster_destroy(raster);
         PG_FREE_IF_COPY(pgraster, 0);
         PG_RETURN_NULL();
@@ -2732,7 +2732,7 @@ Datum RASTER_dumpValues(PG_FUNCTION_ARGS)
                        for (y = 0; y < arg1->rows; y++) {
                                for (x = 0; x < arg1->columns; x++) {
                                        /* get pixel */
-                                       if (rt_band_get_pixel(band, x, y, &val, &isnodata) != 0) {
+                                       if (rt_band_get_pixel(band, x, y, &val, &isnodata) != ES_NONE) {
                                                elog(ERROR, "RASTER_dumpValues: Unable to pixel (%d, %d) of band %d", x, y, arg1->nbands[z] + 1);
                                                rtpg_dumpvalues_arg_destroy(arg1);
                                                rt_raster_destroy(raster);
@@ -2913,12 +2913,12 @@ Datum RASTER_setPixelValue(PG_FUNCTION_ARGS)
                                }
                                else {
                                        rt_band_get_nodata(band, &pixvalue);
-                                       rt_band_set_pixel(band, x - 1, y - 1, pixvalue);
+                                       rt_band_set_pixel(band, x - 1, y - 1, pixvalue, NULL);
                                }
                        }
                        else {
                                pixvalue = PG_GETARG_FLOAT8(4);
-                               rt_band_set_pixel(band, x - 1, y - 1, pixvalue);
+                               rt_band_set_pixel(band, x - 1, y - 1, pixvalue, NULL);
                        }
                }
        }
@@ -3311,7 +3311,7 @@ Datum RASTER_setPixelValuesArray(PG_FUNCTION_ARGS)
                /* if hasnodata = TRUE and keepnodata = TRUE, inspect pixel value */
                if (hasnodata && keepnodata) {
                        rtn = rt_band_get_pixel(band, pixval[i].x, pixval[i].y, &val, &isnodata);
-                       if (rtn != 0) {
+                       if (rtn != ES_NONE) {
                                elog(ERROR, "Cannot get value of pixel.  Returning NULL");
                                pfree(pixval);
                                rt_raster_destroy(raster);
@@ -3326,9 +3326,9 @@ Datum RASTER_setPixelValuesArray(PG_FUNCTION_ARGS)
                }
 
                if (pixval[i].nodata)
-                       rt_band_set_pixel(band, pixval[i].x, pixval[i].y, nodataval);
+                       rt_band_set_pixel(band, pixval[i].x, pixval[i].y, nodataval, NULL);
                else
-                       rt_band_set_pixel(band, pixval[i].x, pixval[i].y, pixval[i].value);
+                       rt_band_set_pixel(band, pixval[i].x, pixval[i].y, pixval[i].value, NULL);
        }
 
        pfree(pixval);
@@ -3741,7 +3741,7 @@ Datum RASTER_setPixelValuesGeomval(PG_FUNCTION_ARGS)
                                point = lwgeom_as_lwpoint(coll->geoms[j]);
                                getPoint2d_p(point->point, 0, &p);
 
-                               if (!rt_raster_geopoint_to_cell(raster, p.x, p.y, &(xy[0]), &(xy[1]), igt)) {
+                               if (rt_raster_geopoint_to_cell(raster, p.x, p.y, &(xy[0]), &(xy[1]), igt) != ES_NONE) {
                                        elog(ERROR, "RASTER_setPixelValuesGeomval: Unable to process coordinates of point");
                                        rtpg_setvaluesgv_arg_destroy(arg);
                                        rt_raster_destroy(raster);
@@ -3759,7 +3759,7 @@ Datum RASTER_setPixelValuesGeomval(PG_FUNCTION_ARGS)
                                }
 
                                /* get pixel value */
-                               if (rt_band_get_pixel(band, xy[0], xy[1], &value, &isnodata) != 0) {
+                               if (rt_band_get_pixel(band, xy[0], xy[1], &value, &isnodata) != ES_NONE) {
                                        elog(ERROR, "RASTER_setPixelValuesGeomval: Unable to get pixel value");
                                        rtpg_setvaluesgv_arg_destroy(arg);
                                        rt_raster_destroy(raster);
@@ -3773,11 +3773,11 @@ Datum RASTER_setPixelValuesGeomval(PG_FUNCTION_ARGS)
 
                                /* set pixel */
                                if (arg->gv[i].pixval.nodata)
-                                       noerr = rt_band_set_pixel(band, xy[0], xy[1], nodataval);
+                                       noerr = rt_band_set_pixel(band, xy[0], xy[1], nodataval, NULL);
                                else
-                                       noerr = rt_band_set_pixel(band, xy[0], xy[1], arg->gv[i].pixval.value);
+                                       noerr = rt_band_set_pixel(band, xy[0], xy[1], arg->gv[i].pixval.value, NULL);
 
-                               if (noerr < 0) {
+                               if (noerr != ES_NONE) {
                                        elog(ERROR, "RASTER_setPixelValuesGeomval: Unable to set pixel value");
                                        rtpg_setvaluesgv_arg_destroy(arg);
                                        rt_raster_destroy(raster);
@@ -4057,7 +4057,7 @@ Datum RASTER_getPixelPolygons(PG_FUNCTION_ARGS)
 
                                /* value, NODATA flag */
                                if (!noband) {
-                                       if (rt_band_get_pixel(band, x - 1, y - 1, &(pix[pixcount].value), &isnodata) != 0) {
+                                       if (rt_band_get_pixel(band, x - 1, y - 1, &(pix[pixcount].value), &isnodata) != ES_NONE) {
                                                elog(ERROR, "RASTER_getPixelPolygons: Could not get pixel value");
 
                                                for (i = 0; i < pixcount; i++)
@@ -4554,12 +4554,12 @@ Datum RASTER_nearestValue(PG_FUNCTION_ARGS)
        point = lwgeom_as_lwpoint(lwgeom);
        getPoint2d_p(point->point, 0, &p);
 
-       if (!rt_raster_geopoint_to_cell(
+       if (rt_raster_geopoint_to_cell(
                raster,
                p.x, p.y,
                &x, &y,
                NULL
-       )) {
+       ) != ES_NONE) {
                elog(ERROR, "RASTER_nearestValue: Unable to compute pixel coordinates from spatial coordinates");
                rt_raster_destroy(raster);
                PG_FREE_IF_COPY(pgraster, 0);
@@ -4573,7 +4573,7 @@ Datum RASTER_nearestValue(PG_FUNCTION_ARGS)
                (x >= 0 && x < rt_raster_get_width(raster)) &&
                (y >= 0 && y < rt_raster_get_height(raster))
        ) {
-               if (rt_band_get_pixel(band, x, y, &value, &isnodata) < 0) {
+               if (rt_band_get_pixel(band, x, y, &value, &isnodata) != ES_NONE) {
                        elog(ERROR, "RASTER_nearestValue: Unable to get pixel value for band at index %d", bandindex);
                        rt_raster_destroy(raster);
                        PG_FREE_IF_COPY(pgraster, 0);
@@ -4801,7 +4801,7 @@ Datum RASTER_neighborhood(PG_FUNCTION_ARGS)
                        _x, _y,
                        &pixval,
                        &isnodata
-               ) < 0) {
+               ) != ES_NONE) {
                        elog(NOTICE, "Unable to get the pixel of band at index %d. Returning NULL", bandindex);
                        rt_band_destroy(band);
                        rt_raster_destroy(raster);
@@ -4865,7 +4865,7 @@ Datum RASTER_neighborhood(PG_FUNCTION_ARGS)
                &(dim[1]), &(dim[0])
        );
        pfree(npixels);
-       if (!count) {
+       if (count != ES_NONE) {
                elog(NOTICE, "Unable to create 2D array of neighborhood");
                PG_RETURN_NULL();
        }
@@ -5649,7 +5649,7 @@ Datum RASTER_tile(PG_FUNCTION_ARGS)
                rx = tx * arg2->tile.width;
                ry = ty * arg2->tile.height;
                POSTGIS_RT_DEBUGF(4, "raster coordinates = %d, %d", rx, ry);
-               if (!rt_raster_cell_to_geopoint(arg2->raster.raster, rx, ry, &ulx, &uly, arg2->raster.gt)) {
+               if (rt_raster_cell_to_geopoint(arg2->raster.raster, rx, ry, &ulx, &uly, arg2->raster.gt) != ES_NONE) {
                        elog(ERROR, "RASTER_tile: Unable to compute the coordinates of the upper-left corner of the output tile");
                        rt_raster_destroy(tile);
                        rt_raster_destroy(arg2->raster.raster);
@@ -5723,7 +5723,7 @@ Datum RASTER_tile(PG_FUNCTION_ARGS)
                                        }
 
                                        POSTGIS_RT_DEBUGF(4, "getting pixel line %d, %d for %d pixels", rx, k, len);
-                                       if (rt_band_get_pixel_line(_band, rx, k, len, &vals, &nvals) != 0) {
+                                       if (rt_band_get_pixel_line(_band, rx, k, len, &vals, &nvals) != ES_NONE) {
                                                elog(ERROR, "RASTER_tile: Unable to get pixel line from source raster");
                                                rt_raster_destroy(tile);
                                                rt_raster_destroy(arg2->raster.raster);
@@ -5732,7 +5732,7 @@ Datum RASTER_tile(PG_FUNCTION_ARGS)
                                                SRF_RETURN_DONE(funcctx);
                                        }
 
-                                       if (nvals && !rt_band_set_pixel_line(band, 0, j, vals, nvals)) {
+                                       if (nvals && rt_band_set_pixel_line(band, 0, j, vals, nvals) != ES_NONE) {
                                                elog(ERROR, "RASTER_tile: Unable to set pixel line of output tile");
                                                rt_raster_destroy(tile);
                                                rt_raster_destroy(arg2->raster.raster);
@@ -5744,11 +5744,14 @@ Datum RASTER_tile(PG_FUNCTION_ARGS)
                        }
                        /* offline */
                        else {
+                               uint8_t bandnum = 0;
+                               rt_band_get_ext_band_num(_band, &bandnum);
+
                                band = rt_band_new_offline(
                                        arg2->raster.width, arg2->raster.height,
                                        pixtype,
                                        hasnodata, nodataval,
-                                       rt_band_get_ext_band_num(_band), rt_band_get_ext_path(_band)
+                                       bandnum, rt_band_get_ext_path(_band)
                                );
 
                                if (band == NULL) {
@@ -6495,7 +6498,7 @@ Datum RASTER_mapAlgebraExpr(PG_FUNCTION_ARGS)
              * We compute a value only for the withdata value pixel since the
              * nodata value has already been set by the first optimization
              **/
-            if (ret != -1 && FLT_NEQ(r, newnodatavalue)) {
+            if (ret == ES_NONE && FLT_NEQ(r, newnodatavalue)) {
                 if (skipcomputation == 0) {
                     if (initexpr != NULL) {
                         /* Reset the null arg flags. */
@@ -6573,7 +6576,7 @@ Datum RASTER_mapAlgebraExpr(PG_FUNCTION_ARGS)
                 }
 
 
-                rt_band_set_pixel(newband, x, y, newval);
+                rt_band_set_pixel(newband, x, y, newval, NULL);
             }
 
         }
@@ -6979,7 +6982,7 @@ Datum RASTER_mapAlgebraFct(PG_FUNCTION_ARGS)
              * We compute a value only for the withdata value pixel since the
              * nodata value has already been set by the first optimization
              **/
-            if (ret != -1) {
+            if (ret == ES_NONE) {
                 if (FLT_EQ(r, newnodatavalue)) {
                     if (cbinfo.fn_strict) {
                         POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFct: Strict callbacks cannot accept NULL arguments, skipping NODATA cell.");
@@ -7022,7 +7025,7 @@ Datum RASTER_mapAlgebraFct(PG_FUNCTION_ARGS)
                 POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFct: new value = %f", 
                     newval);
                 
-                rt_band_set_pixel(newband, x, y, newval);
+                rt_band_set_pixel(newband, x, y, newval, NULL);
             }
 
         }
@@ -11833,7 +11836,7 @@ Datum RASTER_rasterToWorldCoord(PG_FUNCTION_ARGS)
                (double) cr[0] - 1, (double) cr[1] - 1,
                &(cw[0]), &(cw[1]),
                NULL
-       ) == 0) {
+       ) != ES_NONE) {
                elog(ERROR, "RASTER_rasterToWorldCoord: Could not compute longitude and latitude from pixel row and column");
                rt_raster_destroy(raster);
                PG_FREE_IF_COPY(pgraster, 0);
@@ -11930,7 +11933,7 @@ Datum RASTER_worldToRasterCoord(PG_FUNCTION_ARGS)
                cw[0], cw[1],
                &(_cr[0]), &(_cr[1]),
                NULL
-       ) == 0) {
+       ) != ES_NONE) {
                elog(ERROR, "RASTER_worldToRasterCoord: Could not compute pixel row and column from longitude and latitude");
                rt_raster_destroy(raster);
                PG_FREE_IF_COPY(pgraster, 0);
@@ -12081,7 +12084,7 @@ Datum RASTER_intersects(PG_FUNCTION_ARGS)
                PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
        }
 
-       if (!rtn) {
+       if (rtn != ES_NONE) {
                elog(ERROR, "RASTER_intersects: Unable to test for intersection on the two rasters");
                PG_RETURN_NULL();
        }
@@ -12200,7 +12203,7 @@ Datum RASTER_overlaps(PG_FUNCTION_ARGS)
                PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
        }
 
-       if (!rtn) {
+       if (rtn != ES_NONE) {
                elog(ERROR, "RASTER_overlaps: Unable to test for overlap on the two rasters");
                PG_RETURN_NULL();
        }
@@ -12319,7 +12322,7 @@ Datum RASTER_touches(PG_FUNCTION_ARGS)
                PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
        }
 
-       if (!rtn) {
+       if (rtn != ES_NONE) {
                elog(ERROR, "RASTER_touches: Unable to test for touch on the two rasters");
                PG_RETURN_NULL();
        }
@@ -12438,7 +12441,7 @@ Datum RASTER_contains(PG_FUNCTION_ARGS)
                PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
        }
 
-       if (!rtn) {
+       if (rtn != ES_NONE) {
                elog(ERROR, "RASTER_contains: Unable to test that the first raster contains the second raster");
                PG_RETURN_NULL();
        }
@@ -12557,7 +12560,7 @@ Datum RASTER_containsProperly(PG_FUNCTION_ARGS)
                PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
        }
 
-       if (!rtn) {
+       if (rtn != ES_NONE) {
                elog(ERROR, "RASTER_containsProperly: Unable to test that the first raster contains properly the second raster");
                PG_RETURN_NULL();
        }
@@ -12676,7 +12679,7 @@ Datum RASTER_covers(PG_FUNCTION_ARGS)
                PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
        }
 
-       if (!rtn) {
+       if (rtn != ES_NONE) {
                elog(ERROR, "RASTER_covers: Unable to test that the first raster covers the second raster");
                PG_RETURN_NULL();
        }
@@ -12795,7 +12798,7 @@ Datum RASTER_coveredby(PG_FUNCTION_ARGS)
                PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
        }
 
-       if (!rtn) {
+       if (rtn != ES_NONE) {
                elog(ERROR, "RASTER_coveredby: Unable to test that the first raster is covered by the second raster");
                PG_RETURN_NULL();
        }
@@ -12936,7 +12939,7 @@ Datum RASTER_dwithin(PG_FUNCTION_ARGS)
                PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
        }
 
-       if (!rtn) {
+       if (rtn != ES_NONE) {
                elog(ERROR, "RASTER_dwithin: Unable to test that the two rasters are within the specified distance of each other");
                PG_RETURN_NULL();
        }
@@ -13077,7 +13080,7 @@ Datum RASTER_dfullywithin(PG_FUNCTION_ARGS)
                PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
        }
 
-       if (!rtn) {
+       if (rtn != ES_NONE) {
                elog(ERROR, "RASTER_dfullywithin: Unable to test that the two rasters are fully within the specified distance of each other");
                PG_RETURN_NULL();
        }
@@ -13172,7 +13175,7 @@ Datum RASTER_sameAlignment(PG_FUNCTION_ARGS)
                PG_FREE_IF_COPY(pgrast[k], pgrastpos[k]);
        }
 
-       if (!rtn) {
+       if (rtn != ES_NONE) {
                elog(ERROR, "RASTER_sameAlignment: Unable to test for alignment on the two rasters");
                PG_RETURN_NULL();
        }
@@ -13404,7 +13407,7 @@ Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS)
        */
 
        /* same alignment */
-       if (!rt_raster_same_alignment(_rast[0], _rast[1], &aligned)) {
+       if (rt_raster_same_alignment(_rast[0], _rast[1], &aligned) != ES_NONE) {
                elog(ERROR, "RASTER_mapAlgebra2: Unable to test for alignment on the two rasters");
                for (k = 0; k < set_count; k++) {
                        if (_rast[k] != NULL)
@@ -14041,7 +14044,7 @@ Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS)
                                                (_y >= 0 && _y < _dim[i][1])
                                        ) {
                                                err = rt_band_get_pixel(_band[i], _x, _y, &(_pixel[i]), &isnodata);
-                                               if (err < 0) {
+                                               if (err != ES_NONE) {
                                                        elog(ERROR, "RASTER_mapAlgebra2: Unable to get pixel of %s raster", (i < 1 ? "FIRST" : "SECOND"));
 
                                                        if (calltype == TEXTOID) {
@@ -14262,7 +14265,7 @@ Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS)
 
                                /* burn pixel if haspixel != 0 */
                                if (haspixel) {
-                                       if (rt_band_set_pixel(band, x, y, pixel) < 0) {
+                                       if (rt_band_set_pixel(band, x, y, pixel, NULL) != ES_NONE) {
                                                elog(ERROR, "RASTER_mapAlgebra2: Unable to set pixel value of output raster");
 
                                                if (calltype == TEXTOID) {
@@ -14802,14 +14805,14 @@ Datum RASTER_mapAlgebraFctNgb(PG_FUNCTION_ARGS)
             pixelreplace = false;
             if (valuereplace) {
                 ret = rt_band_get_pixel(band, x, y, &rpix, NULL);
-                if (ret != -1 && FLT_NEQ(rpix, newnodatavalue)) {
+                if (ret == ES_NONE && FLT_NEQ(rpix, newnodatavalue)) {
                     pixelreplace = true;
                 }
             }
             for (u = x - ngbwidth; u <= x + ngbwidth; u++) {
                 for (v = y - ngbheight; v <= y + ngbheight; v++) {
                     ret = rt_band_get_pixel(band, u, v, &r, NULL);
-                    if (ret != -1) {
+                    if (ret == ES_NONE) {
                         if (FLT_NEQ(r, newnodatavalue)) {
                             /* If the pixel value for this neighbor cell is not NODATA */
                             neighborData[nIndex] = Float8GetDatum((double)r);
@@ -14873,7 +14876,7 @@ Datum RASTER_mapAlgebraFctNgb(PG_FUNCTION_ARGS)
                 POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: new value = %f", 
                     newval);
                 
-                rt_band_set_pixel(newband, x, y, newval);
+                rt_band_set_pixel(newband, x, y, newval, NULL);
             }
 
             /* reset the number of null items in the neighborhood */
index 147932560cf31619aa384e9b1cc4cd2553e00bea..135509ba9a6a69ccd0738595180a0428297fd9c3 100644 (file)
@@ -70,37 +70,37 @@ fillRasterToPolygonize(int hasnodata, double nodatavalue)
         int x, y;
         for (x = 0; x < rt_band_get_width(band); ++x)
             for (y = 0; y < rt_band_get_height(band); ++y)
-                rt_band_set_pixel(band, x, y, 0.0);
+                rt_band_set_pixel(band, x, y, 0.0, NULL);
     }
     
-    rt_band_set_pixel(band, 3, 1, 1.8);
-    rt_band_set_pixel(band, 4, 1, 1.8);
-    rt_band_set_pixel(band, 5, 1, 2.8);
-    rt_band_set_pixel(band, 2, 2, 1.8);
-    rt_band_set_pixel(band, 3, 2, 1.8);
-    rt_band_set_pixel(band, 4, 2, 1.8);
-    rt_band_set_pixel(band, 5, 2, 2.8);
-    rt_band_set_pixel(band, 6, 2, 2.8);
-    rt_band_set_pixel(band, 1, 3, 1.8);
-    rt_band_set_pixel(band, 2, 3, 1.8);
-    rt_band_set_pixel(band, 6, 3, 2.8);
-    rt_band_set_pixel(band, 7, 3, 2.8);
-    rt_band_set_pixel(band, 1, 4, 1.8);
-    rt_band_set_pixel(band, 2, 4, 1.8);
-    rt_band_set_pixel(band, 6, 4, 2.8);
-    rt_band_set_pixel(band, 7, 4, 2.8);
-    rt_band_set_pixel(band, 1, 5, 1.8);
-    rt_band_set_pixel(band, 2, 5, 1.8);
-    rt_band_set_pixel(band, 6, 5, 2.8);
-    rt_band_set_pixel(band, 7, 5, 2.8);
-    rt_band_set_pixel(band, 2, 6, 1.8);
-    rt_band_set_pixel(band, 3, 6, 1.8);
-    rt_band_set_pixel(band, 4, 6, 1.8);
-    rt_band_set_pixel(band, 5, 6, 2.8);
-    rt_band_set_pixel(band, 6, 6, 2.8);
-    rt_band_set_pixel(band, 3, 7, 1.8);
-    rt_band_set_pixel(band, 4, 7, 1.8);
-    rt_band_set_pixel(band, 5, 7, 2.8);
+    rt_band_set_pixel(band, 3, 1, 1.8, NULL);
+    rt_band_set_pixel(band, 4, 1, 1.8, NULL);
+    rt_band_set_pixel(band, 5, 1, 2.8, NULL);
+    rt_band_set_pixel(band, 2, 2, 1.8, NULL);
+    rt_band_set_pixel(band, 3, 2, 1.8, NULL);
+    rt_band_set_pixel(band, 4, 2, 1.8, NULL);
+    rt_band_set_pixel(band, 5, 2, 2.8, NULL);
+    rt_band_set_pixel(band, 6, 2, 2.8, NULL);
+    rt_band_set_pixel(band, 1, 3, 1.8, NULL);
+    rt_band_set_pixel(band, 2, 3, 1.8, NULL);
+    rt_band_set_pixel(band, 6, 3, 2.8, NULL);
+    rt_band_set_pixel(band, 7, 3, 2.8, NULL);
+    rt_band_set_pixel(band, 1, 4, 1.8, NULL);
+    rt_band_set_pixel(band, 2, 4, 1.8, NULL);
+    rt_band_set_pixel(band, 6, 4, 2.8, NULL);
+    rt_band_set_pixel(band, 7, 4, 2.8, NULL);
+    rt_band_set_pixel(band, 1, 5, 1.8, NULL);
+    rt_band_set_pixel(band, 2, 5, 1.8, NULL);
+    rt_band_set_pixel(band, 6, 5, 2.8, NULL);
+    rt_band_set_pixel(band, 7, 5, 2.8, NULL);
+    rt_band_set_pixel(band, 2, 6, 1.8, NULL);
+    rt_band_set_pixel(band, 3, 6, 1.8, NULL);
+    rt_band_set_pixel(band, 4, 6, 1.8, NULL);
+    rt_band_set_pixel(band, 5, 6, 2.8, NULL);
+    rt_band_set_pixel(band, 6, 6, 2.8, NULL);
+    rt_band_set_pixel(band, 3, 7, 1.8, NULL);
+    rt_band_set_pixel(band, 4, 7, 1.8, NULL);
+    rt_band_set_pixel(band, 5, 7, 2.8, NULL);
 
     return raster;
 }
@@ -368,29 +368,36 @@ static void testGDALPolygonize() {
 static void testBand1BB(rt_band band)
 {
     int failure;
+               int clamped;
     double val = 0;
 
-    failure = rt_band_set_nodata(band, 1);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 1, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+    CHECK(!clamped);
                rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 1);
 
-    failure = rt_band_set_nodata(band, 0);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 0, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+    CHECK(!clamped);
                rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 2);
-    CHECK(failure); /* out of range value */
+    failure = rt_band_set_nodata(band, 2, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
-    failure = rt_band_set_nodata(band, 3);
-    CHECK(failure); /* out of range value */
+    failure = rt_band_set_nodata(band, 3, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
-    failure = rt_band_set_pixel(band, 0, 0, 2);
-    CHECK(failure); /* out of range value */
+    failure = rt_band_set_pixel(band, 0, 0, 2, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
-    failure = rt_band_set_pixel(band, 0, 0, 3);
-    CHECK(failure); /* out of range value */
+    failure = rt_band_set_pixel(band, 0, 0, 3, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     {
         int x, y;
@@ -398,16 +405,16 @@ static void testBand1BB(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 1);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 1, NULL);
+                CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 1);
 
-                failure = rt_band_set_pixel(band, x, y, 0);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 0, NULL);
+                CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 0);
 
             }
@@ -420,38 +427,47 @@ static void testBand2BUI(rt_band band)
 {
     double val;
     int failure;
+               int clamped;
 
-    failure = rt_band_set_nodata(band, 1);
+    failure = rt_band_set_nodata(band, 1, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 1);
-    CHECK(!failure);
 
-    failure = rt_band_set_nodata(band, 0);
+    failure = rt_band_set_nodata(band, 0, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 0);
-    CHECK(!failure);
 
-    failure = rt_band_set_nodata(band, 2);
+    failure = rt_band_set_nodata(band, 2, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 2);
-    CHECK(!failure);
 
-    failure = rt_band_set_nodata(band, 3);
+    failure = rt_band_set_nodata(band, 3, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 3);
-    CHECK(!failure);
 
-    failure = rt_band_set_nodata(band, 4); /* invalid: out of range */
-    CHECK(failure);
+    failure = rt_band_set_nodata(band, 4, &clamped); /* invalid: out of range */
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
-    failure = rt_band_set_nodata(band, 5); /* invalid: out of range */
-    CHECK(failure);
+    failure = rt_band_set_nodata(band, 5, &clamped); /* invalid: out of range */
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
-    failure = rt_band_set_pixel(band, 0, 0, 4); /* out of range */
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, 0, 0, 4, &clamped); /* out of range */
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
-    failure = rt_band_set_pixel(band, 0, 0, 5); /* out of range */
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, 0, 0, 5, &clamped); /* out of range */
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
 
     {
@@ -460,22 +476,22 @@ static void testBand2BUI(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 1);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 1, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 1);
 
-                failure = rt_band_set_pixel(band, x, y, 2);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 2, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 2);
 
-                failure = rt_band_set_pixel(band, x, y, 3);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 3, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 3);
             }
         }
@@ -487,45 +503,55 @@ static void testBand4BUI(rt_band band)
 {
     double val;
     int failure;
+               int clamped;
 
-    failure = rt_band_set_nodata(band, 1);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 1, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 1);
 
-    failure = rt_band_set_nodata(band, 0);
+    failure = rt_band_set_nodata(band, 0, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
-    CHECK(!failure);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 2);
+    failure = rt_band_set_nodata(band, 2, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
-    CHECK(!failure);
     CHECK_EQUALS(val, 2);
 
-    failure = rt_band_set_nodata(band, 4);
+    failure = rt_band_set_nodata(band, 4, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
-    CHECK(!failure);
     CHECK_EQUALS(val, 4);
 
-    failure = rt_band_set_nodata(band, 8);
+    failure = rt_band_set_nodata(band, 8, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
-    CHECK(!failure);
     CHECK_EQUALS(val, 8);
 
-    failure = rt_band_set_nodata(band, 15);
+    failure = rt_band_set_nodata(band, 15, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
-    CHECK(!failure);
     CHECK_EQUALS(val, 15);
 
-    failure = rt_band_set_nodata(band, 16);  /* out of value range */
-    CHECK(failure);
+    failure = rt_band_set_nodata(band, 16, &clamped);  /* out of value range */
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
-    failure = rt_band_set_nodata(band, 17);  /* out of value range */
-    CHECK(failure);
+    failure = rt_band_set_nodata(band, 17, &clamped);  /* out of value range */
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
-    failure = rt_band_set_pixel(band, 0, 0, 35); /* out of value range */
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, 0, 0, 35, &clamped); /* out of value range */
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
 
     {
@@ -535,28 +561,28 @@ static void testBand4BUI(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 1);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 1, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 1);
 
-                failure = rt_band_set_pixel(band, x, y, 3);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 3, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 3);
 
-                failure = rt_band_set_pixel(band, x, y, 7);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 7, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 7);
 
-                failure = rt_band_set_pixel(band, x, y, 15);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 15, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 15);
             }
         }
@@ -568,52 +594,63 @@ static void testBand8BUI(rt_band band)
 {
     double val;
     int failure;
+               int clamped;
 
-    failure = rt_band_set_nodata(band, 1);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 1, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 1);
 
-    failure = rt_band_set_nodata(band, 0);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 0, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 2);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 2, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 2);
 
-    failure = rt_band_set_nodata(band, 4);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 4, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 4);
 
-    failure = rt_band_set_nodata(band, 8);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 8, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 8);
 
-    failure = rt_band_set_nodata(band, 15);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 15, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 15);
 
-    failure = rt_band_set_nodata(band, 31);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 31, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 31);
 
-    failure = rt_band_set_nodata(band, 255);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 255, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 255);
 
-    failure = rt_band_set_nodata(band, 256); /* out of value range */
-    CHECK(failure);
+    failure = rt_band_set_nodata(band, 256, &clamped); /* out of value range */
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
-    failure = rt_band_set_pixel(band, 0, 0, 256); /* out of value range */
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, 0, 0, 256, &clamped); /* out of value range */
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     {
         int x, y;
@@ -621,22 +658,22 @@ static void testBand8BUI(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 31);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 31, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 31);
 
-                failure = rt_band_set_pixel(band, x, y, 255);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 255, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 255);
 
-                failure = rt_band_set_pixel(band, x, y, 1);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 1, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 1);
             }
         }
@@ -647,66 +684,81 @@ static void testBand8BSI(rt_band band)
 {
     double val;
     int failure;
+               int clamped;
 
-    failure = rt_band_set_nodata(band, 1);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 1, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 1);
 
-    failure = rt_band_set_nodata(band, 0);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 0, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 2);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 2, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 2);
 
-    failure = rt_band_set_nodata(band, 4);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 4, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 4);
 
-    failure = rt_band_set_nodata(band, 8);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 8, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 8);
 
-    failure = rt_band_set_nodata(band, 15);
+    failure = rt_band_set_nodata(band, 15, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 15);
 
-    failure = rt_band_set_nodata(band, 31);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 31, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 31);
 
-    failure = rt_band_set_nodata(band, -127);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, -127, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, -127);
 
-    failure = rt_band_set_nodata(band, 127);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 127, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 127);
 
     /* out of range (-127..127) */
-    failure = rt_band_set_nodata(band, -129);
-    CHECK(failure);
+    failure = rt_band_set_nodata(band, -129, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     /* out of range (-127..127) */
-    failure = rt_band_set_nodata(band, 129);
-    CHECK(failure);
+    failure = rt_band_set_nodata(band, 129, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     /* out of range (-127..127) */
-    failure = rt_band_set_pixel(band, 0, 0, -129);
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, 0, 0, -129, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     /* out of range (-127..127) */
-    failure = rt_band_set_pixel(band, 0, 0, 129);
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, 0, 0, 129, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
 
     {
@@ -715,28 +767,28 @@ static void testBand8BSI(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 31);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 31, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 31);
 
-                failure = rt_band_set_pixel(band, x, y, 1);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 1, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 1);
 
-                failure = rt_band_set_pixel(band, x, y, -127);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, -127, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, -127);
 
-                failure = rt_band_set_pixel(band, x, y, 127);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 127, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 127);
 
             }
@@ -748,43 +800,51 @@ static void testBand16BUI(rt_band band)
 {
     double val;
     int failure;
+               int clamped;
 
-    failure = rt_band_set_nodata(band, 1);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 1, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 1);
 
-    failure = rt_band_set_nodata(band, 0);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 0, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 31);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 31, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 31);
 
-    failure = rt_band_set_nodata(band, 255);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 255, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 255);
 
-    failure = rt_band_set_nodata(band, 65535);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 65535, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     //printf("set 65535 on %s band gets %g back\n", pixtypeName, val);
     CHECK_EQUALS(val, 65535);
 
-    failure = rt_band_set_nodata(band, 65536); /* out of range */
-    CHECK(failure);
+    failure = rt_band_set_nodata(band, 65536, &clamped); /* out of range */
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     /* out of value range */
-    failure = rt_band_set_pixel(band, 0, 0, 65536);
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, 0, 0, 65536, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     /* out of dimensions range */
-    failure = rt_band_set_pixel(band, rt_band_get_width(band), 0, 0);
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, rt_band_get_width(band), 0, 0, &clamped);
+    CHECK((failure != ES_NONE));
 
     {
         int x, y;
@@ -792,16 +852,16 @@ static void testBand16BUI(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 255);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 255, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 255);
 
-                failure = rt_band_set_pixel(band, x, y, 65535);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 65535, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 65535);
             }
         }
@@ -812,58 +872,69 @@ static void testBand16BSI(rt_band band)
 {
     double val;
     int failure;
+               int clamped;
 
-    failure = rt_band_set_nodata(band, 1);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 1, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 1);
 
-    failure = rt_band_set_nodata(band, 0);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 0, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 31);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 31, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 31);
 
-    failure = rt_band_set_nodata(band, 255);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 255, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 255);
 
-    failure = rt_band_set_nodata(band, -32767);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, -32767, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     //printf("set 65535 on %s band gets %g back\n", pixtypeName, val);
     CHECK_EQUALS(val, -32767);
 
-    failure = rt_band_set_nodata(band, 32767);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 32767, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     //printf("set 65535 on %s band gets %g back\n", pixtypeName, val);
     CHECK_EQUALS(val, 32767);
 
     /* out of range (-32767..32767) */
-    failure = rt_band_set_nodata(band, -32769);
-    CHECK(failure);
+    failure = rt_band_set_nodata(band, -32769, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     /* out of range (-32767..32767) */
-    failure = rt_band_set_nodata(band, 32769);
-    CHECK(failure);
+    failure = rt_band_set_nodata(band, 32769, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     /* out of range (-32767..32767) */
-    failure = rt_band_set_pixel(band, 0, 0, -32769);
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, 0, 0, -32769, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     /* out of range (-32767..32767) */
-    failure = rt_band_set_pixel(band, 0, 0, 32769);
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, 0, 0, 32769, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     /* out of dimensions range */
-    failure = rt_band_set_pixel(band, rt_band_get_width(band), 0, 0);
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, rt_band_get_width(band), 0, 0, NULL);
+    CHECK((failure != ES_NONE));
 
     {
         int x, y;
@@ -871,22 +942,22 @@ static void testBand16BSI(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 255);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 255, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 255);
 
-                failure = rt_band_set_pixel(band, x, y, -32767);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, -32767, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, -32767);
 
-                failure = rt_band_set_pixel(band, x, y, 32767);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 32767, NULL);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 32767);
             }
         }
@@ -897,39 +968,45 @@ static void testBand32BUI(rt_band band)
 {
     double val;
     int failure;
+               int clamped;
 
-    failure = rt_band_set_nodata(band, 1);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 1, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 1);
 
-    failure = rt_band_set_nodata(band, 0);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 0, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 65535);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 65535, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 65535);
 
-    failure = rt_band_set_nodata(band, 4294967295UL);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 4294967295UL, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 4294967295UL);
 
     /* out of range */
-    failure = rt_band_set_nodata(band, 4294967296ULL);
-    CHECK(failure);
+    failure = rt_band_set_nodata(band, 4294967296ULL, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     /* out of value range */
-    failure = rt_band_set_pixel(band, 0, 0, 4294967296ULL);
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, 0, 0, 4294967296ULL, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     /* out of dimensions range */
-    failure = rt_band_set_pixel(band, rt_band_get_width(band),
-                                0, 4294967296ULL);
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, rt_band_get_width(band), 0, 4294967296ULL, NULL);
+    CHECK((failure != ES_NONE));
 
     {
         int x, y;
@@ -937,28 +1014,28 @@ static void testBand32BUI(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 1);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 1, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 1);
 
-                failure = rt_band_set_pixel(band, x, y, 0);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 0, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 0);
 
-                failure = rt_band_set_pixel(band, x, y, 65535);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 65535, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 65535);
 
-                failure = rt_band_set_pixel(band, x, y, 4294967295UL);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 4294967295UL, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 4294967295UL);
             }
         }
@@ -969,39 +1046,46 @@ static void testBand32BSI(rt_band band)
 {
     double val;
     int failure;
+               int clamped;
 
-    failure = rt_band_set_nodata(band, 1);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 1, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 1);
 
-    failure = rt_band_set_nodata(band, 0);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 0, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 65535);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 65535, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 65535);
 
-    failure = rt_band_set_nodata(band, 2147483647);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 2147483647, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     /*printf("32BSI pix is %ld\n", (long int)val);*/
     CHECK_EQUALS(val, 2147483647);
 
-    failure = rt_band_set_nodata(band, 2147483648UL);
     /* out of range */
-    CHECK(failure);
+    failure = rt_band_set_nodata(band, 2147483648UL, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     /* out of value range */
-    failure = rt_band_set_pixel(band, 0, 0, 2147483648UL);
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, 0, 0, 2147483648UL, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(clamped);
 
     /* out of dimensions range */
-    failure = rt_band_set_pixel(band, rt_band_get_width(band), 0, 0);
-    CHECK(failure);
+    failure = rt_band_set_pixel(band, rt_band_get_width(band), 0, 0, NULL);
+    CHECK((failure != ES_NONE));
 
 
     {
@@ -1010,28 +1094,28 @@ static void testBand32BSI(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 1);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 1, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 1);
 
-                failure = rt_band_set_pixel(band, x, y, 0);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 0, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 0);
 
-                failure = rt_band_set_pixel(band, x, y, 65535);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 65535, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 65535);
 
-                failure = rt_band_set_pixel(band, x, y, 2147483647);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 2147483647, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 2147483647);
             }
         }
@@ -1042,25 +1126,30 @@ static void testBand32BF(rt_band band)
 {
     double val;
     int failure;
+               int clamped;
 
-    failure = rt_band_set_nodata(band, 1);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 1, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 1);
 
-    failure = rt_band_set_nodata(band, 0);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 0, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 65535.5);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 65535.5, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     //printf("set 65535.56 on %s band gets %g back\n", pixtypeName, val);
     CHECK_EQUALS_DOUBLE(val, 65535.5);
 
-    failure = rt_band_set_nodata(band, 0.006);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 0.006, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS_DOUBLE(val, 0.0060000000521540); /* XXX: Alternatively, use CHECK_EQUALS_DOUBLE_EX */
 
@@ -1070,28 +1159,28 @@ static void testBand32BF(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 1);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 1, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 1);
 
-                failure = rt_band_set_pixel(band, x, y, 0);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 0, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 0);
 
-                failure = rt_band_set_pixel(band, x, y, 65535.5);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 65535.5, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS_DOUBLE(val, 65535.5);
 
-                failure = rt_band_set_pixel(band, x, y, 0.006);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 0.006, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS_DOUBLE(val, 0.0060000000521540);
 
             }
@@ -1103,24 +1192,29 @@ static void testBand64BF(rt_band band)
 {
     double val;
     int failure;
+               int clamped;
 
-    failure = rt_band_set_nodata(band, 1);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 1, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 1);
 
-    failure = rt_band_set_nodata(band, 0);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 0, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 0);
 
-    failure = rt_band_set_nodata(band, 65535.56);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 65535.56, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 65535.56);
 
-    failure = rt_band_set_nodata(band, 0.006);
-    CHECK(!failure);
+    failure = rt_band_set_nodata(band, 0.006, &clamped);
+    CHECK_EQUALS(failure, ES_NONE);
+               CHECK(!clamped);
     rt_band_get_nodata(band, &val);
     CHECK_EQUALS(val, 0.006);
 
@@ -1130,28 +1224,28 @@ static void testBand64BF(rt_band band)
         {
             for (y=0; y<rt_band_get_height(band); ++y)
             {
-                failure = rt_band_set_pixel(band, x, y, 1);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 1, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 1);
 
-                failure = rt_band_set_pixel(band, x, y, 0);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 0, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 0);
 
-                failure = rt_band_set_pixel(band, x, y, 65535.56);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 65535.56, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 65535.56);
 
-                failure = rt_band_set_pixel(band, x, y, 0.006);
-                CHECK(!failure);
+                failure = rt_band_set_pixel(band, x, y, 0.006, NULL);
+                                               CHECK_EQUALS(failure, ES_NONE);
                 failure = rt_band_get_pixel(band, x, y, &val, NULL);
-                CHECK(!failure);
+                                                               CHECK_EQUALS(failure, ES_NONE);
                 CHECK_EQUALS(val, 0.006);
 
             }
@@ -1195,7 +1289,7 @@ static void testRasterFromBand() {
        for (x = 0; x < 5; x++) {
                band = addBand(raster, PT_32BUI, 0, 0);
                CHECK(band);
-               rt_band_set_nodata(band, 0);
+               rt_band_set_nodata(band, 0, NULL);
        }
 
        rast = rt_raster_from_band(raster, bandNums, lenBandNums);
@@ -1239,8 +1333,8 @@ static void testBandStats() {
 
        for (x = 0; x < xmax; x++) {
                for (y = 0; y < ymax; y++) {
-                       rtn = rt_band_set_pixel(band, x, y, x + y);
-                       CHECK((rtn != -1));
+                       rtn = rt_band_set_pixel(band, x, y, x + y, NULL);
+                       CHECK_EQUALS(rtn, ES_NONE);
                }
        }
 
@@ -1332,12 +1426,12 @@ static void testBandStats() {
        assert(raster);
        band = addBand(raster, PT_8BUI, 0, 0);
        CHECK(band);
-       rt_band_set_nodata(band, 0);
+       rt_band_set_nodata(band, 0, NULL);
 
        for (x = 0; x < xmax; x++) {
                for (y = 0; y < ymax; y++) {
-                       rtn = rt_band_set_pixel(band, x, y, values[(x * ymax) + y]);
-                       CHECK((rtn != -1));
+                       rtn = rt_band_set_pixel(band, x, y, values[(x * ymax) + y], NULL);
+                       CHECK_EQUALS(rtn, ES_NONE);
                }
        }
 
@@ -1366,12 +1460,12 @@ static void testBandStats() {
        assert(raster);
        band = addBand(raster, PT_64BF, 0, 0);
        CHECK(band);
-       rt_band_set_nodata(band, 0);
+       rt_band_set_nodata(band, 0, NULL);
 
        for (x = 0; x < xmax; x++) {
                for (y = 0; y < ymax; y++) {
-                       rtn = rt_band_set_pixel(band, x, y, (((double) x * y) + (x + y) + (x + y * x)) / (x + y + 1));
-                       CHECK((rtn != -1));
+                       rtn = rt_band_set_pixel(band, x, y, (((double) x * y) + (x + y) + (x + y * x)) / (x + y + 1), NULL);
+                       CHECK_EQUALS(rtn, ES_NONE);
                }
        }
 
@@ -1453,12 +1547,12 @@ static void testBandReclass() {
        assert(raster); /* or we're out of virtual memory */
        band = addBand(raster, PT_16BUI, 0, 0);
        CHECK(band);
-       rt_band_set_nodata(band, 0);
+       rt_band_set_nodata(band, 0, NULL);
 
        for (x = 0; x < 100; x++) {
                for (y = 0; y < 10; y++) {
-                       rtn = rt_band_set_pixel(band, x, y, x * y + (x + y));
-                       CHECK((rtn != -1));
+                       rtn = rt_band_set_pixel(band, x, y, x * y + (x + y), NULL);
+                       CHECK_EQUALS(rtn, ES_NONE);
                }
        }
 
@@ -1504,15 +1598,15 @@ static void testBandReclass() {
        CHECK(newband);
 
        rtn = rt_band_get_pixel(newband, 0, 0, &val, NULL);
-       CHECK((rtn != -1));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK_EQUALS(val, 0);
 
        rtn = rt_band_get_pixel(newband, 49, 5, &val, NULL);
-       CHECK((rtn != -1));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK_EQUALS(val, 77);
 
        rtn = rt_band_get_pixel(newband, 99, 9, &val, NULL);
-       CHECK((rtn != -1));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK_EQUALS(val, 255);
 
        for (i = cnt - 1; i >= 0; i--) rtdealloc(exprset[i]);
@@ -1559,15 +1653,15 @@ static void testRasterToGDAL() {
        assert(raster); /* or we're out of virtual memory */
        band = addBand(raster, PT_64BF, 0, 0);
        CHECK(band);
-       rt_band_set_nodata(band, 0);
+       rt_band_set_nodata(band, 0, NULL);
 
        rt_raster_set_offsets(raster, -500000, 600000);
        rt_raster_set_scale(raster, 1000, -1000);
 
        for (x = 0; x < xmax; x++) {
                for (y = 0; y < ymax; y++) {
-                       rtn = rt_band_set_pixel(band, x, y, (((double) x * y) + (x + y) + (x + y * x)) / (x + y + 1));
-                       CHECK((rtn != -1));
+                       rtn = rt_band_set_pixel(band, x, y, (((double) x * y) + (x + y) + (x + y * x)) / (x + y + 1), NULL);
+                       CHECK_EQUALS(rtn, ES_NONE);
                }
        }
 
@@ -1590,15 +1684,15 @@ static void testRasterToGDAL() {
        assert(raster); /* or we're out of virtual memory */
        band = addBand(raster, PT_8BSI, 0, 0);
        CHECK(band);
-       rt_band_set_nodata(band, 0);
+       rt_band_set_nodata(band, 0, NULL);
 
        rt_raster_set_offsets(raster, -500000, 600000);
        rt_raster_set_scale(raster, 1000, -1000);
 
        for (x = 0; x < xmax; x++) {
                for (y = 0; y < ymax; y++) {
-                       rtn = rt_band_set_pixel(band, x, y, x);
-                       CHECK((rtn != -1));
+                       rtn = rt_band_set_pixel(band, x, y, x, NULL);
+                       CHECK_EQUALS(rtn, ES_NONE);
                }
        }
 
@@ -1631,12 +1725,12 @@ static void testValueCount() {
        assert(raster); /* or we're out of virtual memory */
        band = addBand(raster, PT_64BF, 0, 0);
        CHECK(band);
-       rt_band_set_nodata(band, 0);
+       rt_band_set_nodata(band, 0, NULL);
 
        for (x = 0; x < xmax; x++) {
                for (y = 0; y < ymax; y++) {
-                       rtn = rt_band_set_pixel(band, x, y, (((double) x * y) + (x + y) + (x + y * x)) / (x + y + 1));
-                       CHECK((rtn != -1));
+                       rtn = rt_band_set_pixel(band, x, y, (((double) x * y) + (x + y) + (x + y * x)) / (x + y + 1), NULL);
+                       CHECK_EQUALS(rtn, ES_NONE);
                }
        }
        vcnts = rt_band_get_value_count(band, 1, NULL, 0, 0, NULL, &rtn);
@@ -1692,13 +1786,13 @@ static void testGDALToRaster() {
        assert(raster); /* or we're out of virtual memory */
        band = addBand(raster, PT_64BF, 0, 0);
        CHECK(band);
-       rt_band_set_nodata(band, 0);
+       rt_band_set_nodata(band, 0, NULL);
 
        for (x = 0; x < xmax; x++) {
                for (y = 0; y < ymax; y++) {
                        values[x][y] = (((double) x * y) + (x + y) + (x + y * x)) / (x + y + 1);
-                       rtn = rt_band_set_pixel(band, x, y, values[x][y]);
-                       CHECK((rtn != -1));
+                       rtn = rt_band_set_pixel(band, x, y, values[x][y], NULL);
+                       CHECK_EQUALS(rtn, ES_NONE);
                }
        }
 
@@ -1718,7 +1812,7 @@ static void testGDALToRaster() {
        for (x = 0; x < xmax; x++) {
                for (y = 0; y < ymax; y++) {
                        rtn = rt_band_get_pixel(band, x, y, &value, NULL);
-                       CHECK((rtn != -1));
+                       CHECK_EQUALS(rtn, ES_NONE);
                        CHECK(FLT_EQ(value, values[x][y]));
                }
        }
@@ -1732,14 +1826,14 @@ static void testGDALToRaster() {
        assert(raster); /* or we're out of virtual memory */
        band = addBand(raster, PT_8BSI, 0, 0);
        CHECK(band);
-       rt_band_set_nodata(band, 0);
+       rt_band_set_nodata(band, 0, NULL);
 
        v = -127;
        for (x = 0; x < xmax; x++) {
                for (y = 0; y < ymax; y++) {
                        values[x][y] = v++;
-                       rtn = rt_band_set_pixel(band, x, y, values[x][y]);
-                       CHECK((rtn != -1));
+                       rtn = rt_band_set_pixel(band, x, y, values[x][y], NULL);
+                       CHECK_EQUALS(rtn, ES_NONE);
                        if (v == 128)
                                v = -127;
                }
@@ -1762,7 +1856,7 @@ static void testGDALToRaster() {
        for (x = 0; x < xmax; x++) {
                for (y = 0; y < ymax; y++) {
                        rtn = rt_band_get_pixel(band, x, y, &value, NULL);
-                       CHECK((rtn != -1));
+                       CHECK_EQUALS(rtn, ES_NONE);
                        CHECK(FLT_EQ(value, values[x][y]));
                }
        }
@@ -1792,15 +1886,15 @@ static void testGDALWarp() {
        assert(raster); /* or we're out of virtual memory */
        band = addBand(raster, PT_64BF, 0, 0);
        CHECK(band);
-       rt_band_set_nodata(band, 0);
+       rt_band_set_nodata(band, 0, NULL);
 
        rt_raster_set_offsets(raster, -500000, 600000);
        rt_raster_set_scale(raster, 1000, -1000);
 
        for (x = 0; x < xmax; x++) {
                for (y = 0; y < ymax; y++) {
-                       rtn = rt_band_set_pixel(band, x, y, (((double) x * y) + (x + y) + (x + y * x)) / (x + y + 1));
-                       CHECK((rtn != -1));
+                       rtn = rt_band_set_pixel(band, x, y, (((double) x * y) + (x + y) + (x + y * x)) / (x + y + 1), NULL);
+                       CHECK_EQUALS(rtn, ES_NONE);
                }
        }
 
@@ -1826,7 +1920,7 @@ static void testGDALWarp() {
        rt_band_get_nodata(band, &value);
        CHECK(FLT_EQ(value, 0.));
 
-       CHECK(rt_band_get_pixel(band, 0, 0, &value, NULL) == 0);
+       CHECK_EQUALS(rt_band_get_pixel(band, 0, 0, &value, NULL), ES_NONE);
        CHECK(FLT_EQ(value, 0.));
 
        deepRelease(rast);
@@ -1939,11 +2033,11 @@ static void testIntersects() {
 
        band1 = addBand(rast1, PT_8BUI, 1, 0);
        CHECK(band1);
-       rt_band_set_nodata(band1, 0);
-       rtn = rt_band_set_pixel(band1, 0, 0, 1);
-       rtn = rt_band_set_pixel(band1, 0, 1, 1);
-       rtn = rt_band_set_pixel(band1, 1, 0, 1);
-       rtn = rt_band_set_pixel(band1, 1, 1, 1);
+       rt_band_set_nodata(band1, 0, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band1, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -1965,11 +2059,11 @@ static void testIntersects() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -1979,7 +2073,7 @@ static void testIntersects() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        rtn = rt_raster_intersects(
@@ -1987,7 +2081,7 @@ static void testIntersects() {
                rast2, -1,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -2001,14 +2095,14 @@ static void testIntersects() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
 
        rtn = rt_raster_intersects(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -2022,15 +2116,15 @@ static void testIntersects() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
 
        rtn = rt_raster_intersects(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -2044,16 +2138,16 @@ static void testIntersects() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
 
        rtn = rt_raster_intersects(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -2067,17 +2161,17 @@ static void testIntersects() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
 
        rtn = rt_raster_intersects(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -2093,17 +2187,17 @@ static void testIntersects() {
        */
        rt_raster_set_offsets(rast2, 2, 0);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_intersects(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -2120,17 +2214,17 @@ static void testIntersects() {
        rt_raster_set_offsets(rast2, 0.1, 0.1);
        rt_raster_set_scale(rast2, 0.4, 0.4);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_intersects(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -2151,7 +2245,7 @@ static void testIntersects() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        deepRelease(rast2);
@@ -2175,16 +2269,16 @@ static void testIntersects() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -2194,7 +2288,7 @@ static void testIntersects() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -2212,22 +2306,22 @@ static void testIntersects() {
        */
        rt_raster_set_offsets(rast2, -2, -2);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rtn = rt_raster_intersects(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -2243,22 +2337,22 @@ static void testIntersects() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_intersects(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -2274,22 +2368,22 @@ static void testIntersects() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_intersects(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -2305,22 +2399,22 @@ static void testIntersects() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 0);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_intersects(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        deepRelease(rast2);
@@ -2334,23 +2428,23 @@ static void testIntersects() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 2);
-       rtn = rt_band_set_pixel(band2, 0, 2, 3);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 2);
-       rtn = rt_band_set_pixel(band2, 1, 2, 3);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 2);
-       rtn = rt_band_set_pixel(band2, 2, 2, 3);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 3, NULL);
 
        rtn = rt_raster_intersects(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /* rast2 (skewed by -1, 1) */
@@ -2361,7 +2455,7 @@ static void testIntersects() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /* rast2 (skewed by 1, -1) */
@@ -2372,7 +2466,7 @@ static void testIntersects() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        deepRelease(rast2);
@@ -2406,11 +2500,11 @@ static void testOverlaps() {
 
        band1 = addBand(rast1, PT_8BUI, 1, 0);
        CHECK(band1);
-       rt_band_set_nodata(band1, 0);
-       rtn = rt_band_set_pixel(band1, 0, 0, 1);
-       rtn = rt_band_set_pixel(band1, 0, 1, 1);
-       rtn = rt_band_set_pixel(band1, 1, 0, 1);
-       rtn = rt_band_set_pixel(band1, 1, 1, 1);
+       rt_band_set_nodata(band1, 0, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band1, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -2420,7 +2514,7 @@ static void testOverlaps() {
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -2440,11 +2534,11 @@ static void testOverlaps() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -2454,7 +2548,7 @@ static void testOverlaps() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        rtn = rt_raster_overlaps(
@@ -2462,7 +2556,7 @@ static void testOverlaps() {
                rast2, -1,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -2476,14 +2570,14 @@ static void testOverlaps() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
 
        rtn = rt_raster_overlaps(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -2497,15 +2591,15 @@ static void testOverlaps() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
 
        rtn = rt_raster_overlaps(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -2519,16 +2613,16 @@ static void testOverlaps() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
 
        rtn = rt_raster_overlaps(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -2542,17 +2636,17 @@ static void testOverlaps() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
 
        rtn = rt_raster_overlaps(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -2568,17 +2662,17 @@ static void testOverlaps() {
        */
        rt_raster_set_offsets(rast2, 2, 0);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_overlaps(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -2595,17 +2689,17 @@ static void testOverlaps() {
        rt_raster_set_offsets(rast2, 0.1, 0.1);
        rt_raster_set_scale(rast2, 0.4, 0.4);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_overlaps(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -2626,7 +2720,7 @@ static void testOverlaps() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        deepRelease(rast2);
@@ -2650,16 +2744,16 @@ static void testOverlaps() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -2669,7 +2763,7 @@ static void testOverlaps() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -2687,22 +2781,22 @@ static void testOverlaps() {
        */
        rt_raster_set_offsets(rast2, -2, -2);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rtn = rt_raster_overlaps(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -2718,22 +2812,22 @@ static void testOverlaps() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_overlaps(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -2749,22 +2843,22 @@ static void testOverlaps() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_overlaps(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -2780,22 +2874,22 @@ static void testOverlaps() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 0);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_overlaps(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        deepRelease(rast2);
@@ -2809,23 +2903,23 @@ static void testOverlaps() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 2);
-       rtn = rt_band_set_pixel(band2, 0, 2, 3);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 2);
-       rtn = rt_band_set_pixel(band2, 1, 2, 3);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 2);
-       rtn = rt_band_set_pixel(band2, 2, 2, 3);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 3, NULL);
 
        rtn = rt_raster_overlaps(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /* rast2 (skewed by -1, 1) */
@@ -2836,7 +2930,7 @@ static void testOverlaps() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /* rast2 (skewed by 1, -1) */
@@ -2847,7 +2941,7 @@ static void testOverlaps() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        deepRelease(rast2);
@@ -2881,11 +2975,11 @@ static void testTouches() {
 
        band1 = addBand(rast1, PT_8BUI, 1, 0);
        CHECK(band1);
-       rt_band_set_nodata(band1, 0);
-       rtn = rt_band_set_pixel(band1, 0, 0, 1);
-       rtn = rt_band_set_pixel(band1, 0, 1, 1);
-       rtn = rt_band_set_pixel(band1, 1, 0, 1);
-       rtn = rt_band_set_pixel(band1, 1, 1, 1);
+       rt_band_set_nodata(band1, 0, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band1, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -2895,7 +2989,7 @@ static void testTouches() {
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -2915,11 +3009,11 @@ static void testTouches() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -2929,7 +3023,7 @@ static void testTouches() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        rtn = rt_raster_touches(
@@ -2937,7 +3031,7 @@ static void testTouches() {
                rast2, -1,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -2951,14 +3045,14 @@ static void testTouches() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
 
        rtn = rt_raster_touches(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -2972,15 +3066,15 @@ static void testTouches() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
 
        rtn = rt_raster_touches(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -2994,16 +3088,16 @@ static void testTouches() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
 
        rtn = rt_raster_touches(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -3017,17 +3111,17 @@ static void testTouches() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
 
        rtn = rt_raster_touches(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3043,17 +3137,17 @@ static void testTouches() {
        */
        rt_raster_set_offsets(rast2, 2, 0);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_touches(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3069,17 +3163,17 @@ static void testTouches() {
        */
        rt_raster_set_offsets(rast2, 0, 1);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_touches(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -3095,17 +3189,17 @@ static void testTouches() {
        */
        rt_raster_set_offsets(rast2, -1, 1);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_touches(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -3122,17 +3216,17 @@ static void testTouches() {
        rt_raster_set_offsets(rast2, 0.1, 0.1);
        rt_raster_set_scale(rast2, 0.4, 0.4);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_touches(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3153,7 +3247,7 @@ static void testTouches() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        deepRelease(rast2);
@@ -3177,16 +3271,16 @@ static void testTouches() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -3196,7 +3290,7 @@ static void testTouches() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3214,22 +3308,22 @@ static void testTouches() {
        */
        rt_raster_set_offsets(rast2, -2, -2);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rtn = rt_raster_touches(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3245,22 +3339,22 @@ static void testTouches() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_touches(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3276,22 +3370,22 @@ static void testTouches() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_touches(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -3307,22 +3401,22 @@ static void testTouches() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 0);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_touches(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        deepRelease(rast2);
@@ -3336,23 +3430,23 @@ static void testTouches() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 2);
-       rtn = rt_band_set_pixel(band2, 0, 2, 3);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 2);
-       rtn = rt_band_set_pixel(band2, 1, 2, 3);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 2);
-       rtn = rt_band_set_pixel(band2, 2, 2, 3);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 3, NULL);
 
        rtn = rt_raster_touches(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /* rast2 (skewed by -1, 1) */
@@ -3363,7 +3457,7 @@ static void testTouches() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /* rast2 (skewed by 1, -1) */
@@ -3374,7 +3468,7 @@ static void testTouches() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        deepRelease(rast2);
@@ -3408,11 +3502,11 @@ static void testContains() {
 
        band1 = addBand(rast1, PT_8BUI, 1, 0);
        CHECK(band1);
-       rt_band_set_nodata(band1, 0);
-       rtn = rt_band_set_pixel(band1, 0, 0, 1);
-       rtn = rt_band_set_pixel(band1, 0, 1, 1);
-       rtn = rt_band_set_pixel(band1, 1, 0, 1);
-       rtn = rt_band_set_pixel(band1, 1, 1, 1);
+       rt_band_set_nodata(band1, 0, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band1, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -3422,7 +3516,7 @@ static void testContains() {
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -3442,11 +3536,11 @@ static void testContains() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -3456,7 +3550,7 @@ static void testContains() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        rtn = rt_raster_contains(
@@ -3464,7 +3558,7 @@ static void testContains() {
                rast2, -1,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3478,14 +3572,14 @@ static void testContains() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
 
        rtn = rt_raster_contains(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3499,15 +3593,15 @@ static void testContains() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
 
        rtn = rt_raster_contains(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3521,16 +3615,16 @@ static void testContains() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
 
        rtn = rt_raster_contains(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3544,17 +3638,17 @@ static void testContains() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
 
        rtn = rt_raster_contains(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3570,17 +3664,17 @@ static void testContains() {
        */
        rt_raster_set_offsets(rast2, 2, 0);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_contains(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3596,17 +3690,17 @@ static void testContains() {
        */
        rt_raster_set_offsets(rast2, 0, 1);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_contains(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3622,17 +3716,17 @@ static void testContains() {
        */
        rt_raster_set_offsets(rast2, -1, 1);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_contains(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3649,17 +3743,17 @@ static void testContains() {
        rt_raster_set_offsets(rast2, 0.1, 0.1);
        rt_raster_set_scale(rast2, 0.4, 0.4);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_contains(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -3680,7 +3774,7 @@ static void testContains() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        deepRelease(rast2);
@@ -3704,16 +3798,16 @@ static void testContains() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -3723,7 +3817,7 @@ static void testContains() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3741,22 +3835,22 @@ static void testContains() {
        */
        rt_raster_set_offsets(rast2, -2, -2);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rtn = rt_raster_contains(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3772,22 +3866,22 @@ static void testContains() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_contains(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3803,22 +3897,22 @@ static void testContains() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_contains(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3834,22 +3928,22 @@ static void testContains() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 0);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_contains(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        deepRelease(rast2);
@@ -3863,23 +3957,23 @@ static void testContains() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 2);
-       rtn = rt_band_set_pixel(band2, 0, 2, 3);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 2);
-       rtn = rt_band_set_pixel(band2, 1, 2, 3);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 2);
-       rtn = rt_band_set_pixel(band2, 2, 2, 3);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 3, NULL);
 
        rtn = rt_raster_contains(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /* rast2 (skewed by -1, 1) */
@@ -3890,7 +3984,7 @@ static void testContains() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /* rast2 (skewed by 1, -1) */
@@ -3901,7 +3995,7 @@ static void testContains() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        deepRelease(rast2);
@@ -3935,11 +4029,11 @@ static void testContainsProperly() {
 
        band1 = addBand(rast1, PT_8BUI, 1, 0);
        CHECK(band1);
-       rt_band_set_nodata(band1, 0);
-       rtn = rt_band_set_pixel(band1, 0, 0, 1);
-       rtn = rt_band_set_pixel(band1, 0, 1, 1);
-       rtn = rt_band_set_pixel(band1, 1, 0, 1);
-       rtn = rt_band_set_pixel(band1, 1, 1, 1);
+       rt_band_set_nodata(band1, 0, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band1, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -3949,7 +4043,7 @@ static void testContainsProperly() {
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -3969,11 +4063,11 @@ static void testContainsProperly() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -3983,7 +4077,7 @@ static void testContainsProperly() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        rtn = rt_raster_contains_properly(
@@ -3991,7 +4085,7 @@ static void testContainsProperly() {
                rast2, -1,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4005,14 +4099,14 @@ static void testContainsProperly() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
 
        rtn = rt_raster_contains_properly(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4026,15 +4120,15 @@ static void testContainsProperly() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
 
        rtn = rt_raster_contains_properly(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4048,16 +4142,16 @@ static void testContainsProperly() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
 
        rtn = rt_raster_contains_properly(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4071,17 +4165,17 @@ static void testContainsProperly() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
 
        rtn = rt_raster_contains_properly(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4097,17 +4191,17 @@ static void testContainsProperly() {
        */
        rt_raster_set_offsets(rast2, 2, 0);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_contains_properly(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4123,17 +4217,17 @@ static void testContainsProperly() {
        */
        rt_raster_set_offsets(rast2, 0, 1);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_contains_properly(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4149,17 +4243,17 @@ static void testContainsProperly() {
        */
        rt_raster_set_offsets(rast2, -1, 1);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_contains_properly(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4176,17 +4270,17 @@ static void testContainsProperly() {
        rt_raster_set_offsets(rast2, 0.1, 0.1);
        rt_raster_set_scale(rast2, 0.4, 0.4);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_contains_properly(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -4207,7 +4301,7 @@ static void testContainsProperly() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        deepRelease(rast2);
@@ -4231,16 +4325,16 @@ static void testContainsProperly() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -4250,7 +4344,7 @@ static void testContainsProperly() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4268,22 +4362,22 @@ static void testContainsProperly() {
        */
        rt_raster_set_offsets(rast2, -2, -2);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rtn = rt_raster_contains_properly(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4299,22 +4393,22 @@ static void testContainsProperly() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_contains_properly(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4330,22 +4424,22 @@ static void testContainsProperly() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_contains_properly(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4361,22 +4455,22 @@ static void testContainsProperly() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 0);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_contains_properly(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        deepRelease(rast2);
@@ -4390,23 +4484,23 @@ static void testContainsProperly() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 2);
-       rtn = rt_band_set_pixel(band2, 0, 2, 3);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 2);
-       rtn = rt_band_set_pixel(band2, 1, 2, 3);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 2);
-       rtn = rt_band_set_pixel(band2, 2, 2, 3);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 3, NULL);
 
        rtn = rt_raster_contains_properly(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /* rast2 (skewed by -1, 1) */
@@ -4417,7 +4511,7 @@ static void testContainsProperly() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /* rast2 (skewed by 1, -1) */
@@ -4428,7 +4522,7 @@ static void testContainsProperly() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        deepRelease(rast2);
@@ -4462,11 +4556,11 @@ static void testCovers() {
 
        band1 = addBand(rast1, PT_8BUI, 1, 0);
        CHECK(band1);
-       rt_band_set_nodata(band1, 0);
-       rtn = rt_band_set_pixel(band1, 0, 0, 1);
-       rtn = rt_band_set_pixel(band1, 0, 1, 1);
-       rtn = rt_band_set_pixel(band1, 1, 0, 1);
-       rtn = rt_band_set_pixel(band1, 1, 1, 1);
+       rt_band_set_nodata(band1, 0, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band1, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -4476,7 +4570,7 @@ static void testCovers() {
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -4496,11 +4590,11 @@ static void testCovers() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -4510,7 +4604,7 @@ static void testCovers() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        rtn = rt_raster_covers(
@@ -4518,7 +4612,7 @@ static void testCovers() {
                rast2, -1,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4532,14 +4626,14 @@ static void testCovers() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
 
        rtn = rt_raster_covers(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4553,15 +4647,15 @@ static void testCovers() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
 
        rtn = rt_raster_covers(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4575,16 +4669,16 @@ static void testCovers() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
 
        rtn = rt_raster_covers(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4598,17 +4692,17 @@ static void testCovers() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
 
        rtn = rt_raster_covers(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4624,17 +4718,17 @@ static void testCovers() {
        */
        rt_raster_set_offsets(rast2, 2, 0);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_covers(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4650,17 +4744,17 @@ static void testCovers() {
        */
        rt_raster_set_offsets(rast2, 0, 1);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_covers(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4676,17 +4770,17 @@ static void testCovers() {
        */
        rt_raster_set_offsets(rast2, -1, 1);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_covers(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4703,17 +4797,17 @@ static void testCovers() {
        rt_raster_set_offsets(rast2, 0.1, 0.1);
        rt_raster_set_scale(rast2, 0.4, 0.4);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_covers(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -4734,7 +4828,7 @@ static void testCovers() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        deepRelease(rast2);
@@ -4758,16 +4852,16 @@ static void testCovers() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -4777,7 +4871,7 @@ static void testCovers() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4795,22 +4889,22 @@ static void testCovers() {
        */
        rt_raster_set_offsets(rast2, -2, -2);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rtn = rt_raster_covers(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4826,22 +4920,22 @@ static void testCovers() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_covers(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4857,22 +4951,22 @@ static void testCovers() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_covers(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -4888,22 +4982,22 @@ static void testCovers() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 0);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_covers(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        deepRelease(rast2);
@@ -4917,23 +5011,23 @@ static void testCovers() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 2);
-       rtn = rt_band_set_pixel(band2, 0, 2, 3);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 2);
-       rtn = rt_band_set_pixel(band2, 1, 2, 3);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 2);
-       rtn = rt_band_set_pixel(band2, 2, 2, 3);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 3, NULL);
 
        rtn = rt_raster_covers(
                rast1, 0,
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /* rast2 (skewed by -1, 1) */
@@ -4944,7 +5038,7 @@ static void testCovers() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /* rast2 (skewed by 1, -1) */
@@ -4955,7 +5049,7 @@ static void testCovers() {
                rast2, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        deepRelease(rast2);
@@ -4989,11 +5083,11 @@ static void testCoveredBy() {
 
        band1 = addBand(rast1, PT_8BUI, 1, 0);
        CHECK(band1);
-       rt_band_set_nodata(band1, 0);
-       rtn = rt_band_set_pixel(band1, 0, 0, 1);
-       rtn = rt_band_set_pixel(band1, 0, 1, 1);
-       rtn = rt_band_set_pixel(band1, 1, 0, 1);
-       rtn = rt_band_set_pixel(band1, 1, 1, 1);
+       rt_band_set_nodata(band1, 0, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band1, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -5003,7 +5097,7 @@ static void testCoveredBy() {
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -5023,11 +5117,11 @@ static void testCoveredBy() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -5037,7 +5131,7 @@ static void testCoveredBy() {
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        rtn = rt_raster_coveredby(
@@ -5045,7 +5139,7 @@ static void testCoveredBy() {
                rast1, -1,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -5059,14 +5153,14 @@ static void testCoveredBy() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
 
        rtn = rt_raster_coveredby(
                rast2, 0,
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -5080,15 +5174,15 @@ static void testCoveredBy() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
 
        rtn = rt_raster_coveredby(
                rast2, 0,
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -5102,16 +5196,16 @@ static void testCoveredBy() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
 
        rtn = rt_raster_coveredby(
                rast2, 0,
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -5125,17 +5219,17 @@ static void testCoveredBy() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
 
        rtn = rt_raster_coveredby(
                rast2, 0,
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -5151,17 +5245,17 @@ static void testCoveredBy() {
        */
        rt_raster_set_offsets(rast2, 2, 0);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_coveredby(
                rast2, 0,
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -5177,17 +5271,17 @@ static void testCoveredBy() {
        */
        rt_raster_set_offsets(rast2, 0, 1);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_coveredby(
                rast2, 0,
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -5203,17 +5297,17 @@ static void testCoveredBy() {
        */
        rt_raster_set_offsets(rast2, -1, 1);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_coveredby(
                rast2, 0,
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -5230,17 +5324,17 @@ static void testCoveredBy() {
        rt_raster_set_offsets(rast2, 0.1, 0.1);
        rt_raster_set_scale(rast2, 0.4, 0.4);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_coveredby(
                rast2, 0,
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -5261,7 +5355,7 @@ static void testCoveredBy() {
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        deepRelease(rast2);
@@ -5285,16 +5379,16 @@ static void testCoveredBy() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -5304,7 +5398,7 @@ static void testCoveredBy() {
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -5322,22 +5416,22 @@ static void testCoveredBy() {
        */
        rt_raster_set_offsets(rast2, -2, -2);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rtn = rt_raster_coveredby(
                rast2, 0,
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -5353,22 +5447,22 @@ static void testCoveredBy() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_coveredby(
                rast2, 0,
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -5384,22 +5478,22 @@ static void testCoveredBy() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_coveredby(
                rast2, 0,
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -5415,22 +5509,22 @@ static void testCoveredBy() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 0);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_coveredby(
                rast2, 0,
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        deepRelease(rast2);
@@ -5444,23 +5538,23 @@ static void testCoveredBy() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 2);
-       rtn = rt_band_set_pixel(band2, 0, 2, 3);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 2);
-       rtn = rt_band_set_pixel(band2, 1, 2, 3);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 2);
-       rtn = rt_band_set_pixel(band2, 2, 2, 3);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 3, NULL);
 
        rtn = rt_raster_coveredby(
                rast2, 0,
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /* rast2 (skewed by -1, 1) */
@@ -5471,7 +5565,7 @@ static void testCoveredBy() {
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /* rast2 (skewed by 1, -1) */
@@ -5482,7 +5576,7 @@ static void testCoveredBy() {
                rast1, 0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        deepRelease(rast2);
@@ -5516,11 +5610,11 @@ static void testDWithin() {
 
        band1 = addBand(rast1, PT_8BUI, 1, 0);
        CHECK(band1);
-       rt_band_set_nodata(band1, 0);
-       rtn = rt_band_set_pixel(band1, 0, 0, 1);
-       rtn = rt_band_set_pixel(band1, 0, 1, 1);
-       rtn = rt_band_set_pixel(band1, 1, 0, 1);
-       rtn = rt_band_set_pixel(band1, 1, 1, 1);
+       rt_band_set_nodata(band1, 0, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band1, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -5531,7 +5625,7 @@ static void testDWithin() {
                0.,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        rtn = rt_raster_within_distance(
@@ -5540,7 +5634,7 @@ static void testDWithin() {
                -1.,
                &result
        );
-       CHECK((rtn == 0));
+       CHECK((rtn != ES_NONE));
 
        /*
                rast2
@@ -5559,11 +5653,11 @@ static void testDWithin() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -5574,7 +5668,7 @@ static void testDWithin() {
                0.,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        rtn = rt_raster_within_distance(
@@ -5583,7 +5677,7 @@ static void testDWithin() {
                1.,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        rtn = rt_raster_within_distance(
@@ -5592,7 +5686,7 @@ static void testDWithin() {
                2.,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -5606,7 +5700,7 @@ static void testDWithin() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
 
        rtn = rt_raster_within_distance(
                rast1, 0,
@@ -5614,7 +5708,7 @@ static void testDWithin() {
                0.,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -5628,8 +5722,8 @@ static void testDWithin() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
 
        rtn = rt_raster_within_distance(
                rast1, 0,
@@ -5637,7 +5731,7 @@ static void testDWithin() {
                0.,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -5651,9 +5745,9 @@ static void testDWithin() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
 
        rtn = rt_raster_within_distance(
                rast1, 0,
@@ -5661,7 +5755,7 @@ static void testDWithin() {
                0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -5675,10 +5769,10 @@ static void testDWithin() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
 
        rtn = rt_raster_within_distance(
                rast1, 0,
@@ -5686,7 +5780,7 @@ static void testDWithin() {
                0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -5702,10 +5796,10 @@ static void testDWithin() {
        */
        rt_raster_set_offsets(rast2, 2, 0);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_within_distance(
                rast1, 0,
@@ -5713,7 +5807,7 @@ static void testDWithin() {
                0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        rtn = rt_raster_within_distance(
@@ -5722,7 +5816,7 @@ static void testDWithin() {
                1.1,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -5739,10 +5833,10 @@ static void testDWithin() {
        rt_raster_set_offsets(rast2, 0.1, 0.1);
        rt_raster_set_scale(rast2, 0.4, 0.4);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_within_distance(
                rast1, 0,
@@ -5750,7 +5844,7 @@ static void testDWithin() {
                0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -5772,7 +5866,7 @@ static void testDWithin() {
                0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        deepRelease(rast2);
@@ -5796,16 +5890,16 @@ static void testDWithin() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -5816,7 +5910,7 @@ static void testDWithin() {
                0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -5834,15 +5928,15 @@ static void testDWithin() {
        */
        rt_raster_set_offsets(rast2, -2, -2);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rtn = rt_raster_within_distance(
                rast1, 0,
@@ -5850,7 +5944,7 @@ static void testDWithin() {
                0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -5866,15 +5960,15 @@ static void testDWithin() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_within_distance(
                rast1, 0,
@@ -5882,7 +5976,7 @@ static void testDWithin() {
                0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -5898,15 +5992,15 @@ static void testDWithin() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_within_distance(
                rast1, 0,
@@ -5914,7 +6008,7 @@ static void testDWithin() {
                0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -5930,15 +6024,15 @@ static void testDWithin() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 0);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_within_distance(
                rast1, 0,
@@ -5946,7 +6040,7 @@ static void testDWithin() {
                0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -5964,15 +6058,15 @@ static void testDWithin() {
        */
        rt_raster_set_offsets(rast2, -10, -1);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rtn = rt_raster_within_distance(
                rast1, 0,
@@ -5980,7 +6074,7 @@ static void testDWithin() {
                5,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        rtn = rt_raster_within_distance(
@@ -5989,7 +6083,7 @@ static void testDWithin() {
                6,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        deepRelease(rast2);
@@ -6003,16 +6097,16 @@ static void testDWithin() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 2);
-       rtn = rt_band_set_pixel(band2, 0, 2, 3);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 2);
-       rtn = rt_band_set_pixel(band2, 1, 2, 3);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 2);
-       rtn = rt_band_set_pixel(band2, 2, 2, 3);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 3, NULL);
 
        rtn = rt_raster_within_distance(
                rast1, 0,
@@ -6020,7 +6114,7 @@ static void testDWithin() {
                0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /* rast2 (skewed by -1, 1) */
@@ -6032,7 +6126,7 @@ static void testDWithin() {
                0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /* rast2 (skewed by 1, -1) */
@@ -6044,7 +6138,7 @@ static void testDWithin() {
                0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        deepRelease(rast2);
@@ -6078,11 +6172,11 @@ static void testDFullyWithin() {
 
        band1 = addBand(rast1, PT_8BUI, 1, 0);
        CHECK(band1);
-       rt_band_set_nodata(band1, 0);
-       rtn = rt_band_set_pixel(band1, 0, 0, 1);
-       rtn = rt_band_set_pixel(band1, 0, 1, 1);
-       rtn = rt_band_set_pixel(band1, 1, 0, 1);
-       rtn = rt_band_set_pixel(band1, 1, 1, 1);
+       rt_band_set_nodata(band1, 0, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band1, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band1, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -6093,7 +6187,7 @@ static void testDFullyWithin() {
                0.,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        rtn = rt_raster_fully_within_distance(
@@ -6102,7 +6196,7 @@ static void testDFullyWithin() {
                -1.,
                &result
        );
-       CHECK((rtn == 0));
+       CHECK((rtn != ES_NONE));
 
        /*
                rast2
@@ -6121,11 +6215,11 @@ static void testDFullyWithin() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -6136,7 +6230,7 @@ static void testDFullyWithin() {
                0.,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        rtn = rt_raster_fully_within_distance(
@@ -6145,7 +6239,7 @@ static void testDFullyWithin() {
                1.,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        rtn = rt_raster_fully_within_distance(
@@ -6154,7 +6248,7 @@ static void testDFullyWithin() {
                5.,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -6168,7 +6262,7 @@ static void testDFullyWithin() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
 
        rtn = rt_raster_fully_within_distance(
                rast1, 0,
@@ -6176,7 +6270,7 @@ static void testDFullyWithin() {
                2.,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -6190,8 +6284,8 @@ static void testDFullyWithin() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
 
        rtn = rt_raster_fully_within_distance(
                rast1, 0,
@@ -6199,7 +6293,7 @@ static void testDFullyWithin() {
                5.,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -6213,9 +6307,9 @@ static void testDFullyWithin() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
 
        rtn = rt_raster_fully_within_distance(
                rast1, 0,
@@ -6223,7 +6317,7 @@ static void testDFullyWithin() {
                5,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -6237,10 +6331,10 @@ static void testDFullyWithin() {
                                                +-+-+
                                                                (2, 2)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
 
        rtn = rt_raster_fully_within_distance(
                rast1, 0,
@@ -6248,7 +6342,7 @@ static void testDFullyWithin() {
                10,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -6264,10 +6358,10 @@ static void testDFullyWithin() {
        */
        rt_raster_set_offsets(rast2, 2, 0);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_fully_within_distance(
                rast1, 0,
@@ -6275,7 +6369,7 @@ static void testDFullyWithin() {
                0,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        rtn = rt_raster_fully_within_distance(
@@ -6284,7 +6378,7 @@ static void testDFullyWithin() {
                5.9,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -6301,10 +6395,10 @@ static void testDFullyWithin() {
        rt_raster_set_offsets(rast2, 0.1, 0.1);
        rt_raster_set_scale(rast2, 0.4, 0.4);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
 
        rtn = rt_raster_fully_within_distance(
                rast1, 0,
@@ -6312,7 +6406,7 @@ static void testDFullyWithin() {
                3,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -6334,7 +6428,7 @@ static void testDFullyWithin() {
                2,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        deepRelease(rast2);
@@ -6358,16 +6452,16 @@ static void testDFullyWithin() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rt_band_get_nodata(band2, &nodata);
        CHECK_EQUALS(nodata, 0);
@@ -6378,7 +6472,7 @@ static void testDFullyWithin() {
                6,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -6396,15 +6490,15 @@ static void testDFullyWithin() {
        */
        rt_raster_set_offsets(rast2, -2, -2);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rtn = rt_raster_fully_within_distance(
                rast1, 0,
@@ -6412,7 +6506,7 @@ static void testDFullyWithin() {
                4.25,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -6428,15 +6522,15 @@ static void testDFullyWithin() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_fully_within_distance(
                rast1, 0,
@@ -6444,7 +6538,7 @@ static void testDFullyWithin() {
                3.5,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -6460,15 +6554,15 @@ static void testDFullyWithin() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_fully_within_distance(
                rast1, 0,
@@ -6476,7 +6570,7 @@ static void testDFullyWithin() {
                3.65,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /*
@@ -6492,15 +6586,15 @@ static void testDFullyWithin() {
                                                +-+-+-+
                                                                        (1, 1)
        */
-       rtn = rt_band_set_pixel(band2, 0, 0, 0);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 0);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 0);
-       rtn = rt_band_set_pixel(band2, 1, 2, 0);
-       rtn = rt_band_set_pixel(band2, 2, 0, 0);
-       rtn = rt_band_set_pixel(band2, 2, 1, 0);
-       rtn = rt_band_set_pixel(band2, 2, 2, 0);
+       rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
 
        rtn = rt_raster_fully_within_distance(
                rast1, 0,
@@ -6508,7 +6602,7 @@ static void testDFullyWithin() {
                3.6,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        /*
@@ -6526,15 +6620,15 @@ static void testDFullyWithin() {
        */
        rt_raster_set_offsets(rast2, -10, -1);
 
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 1);
-       rtn = rt_band_set_pixel(band2, 0, 2, 1);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 1);
-       rtn = rt_band_set_pixel(band2, 1, 2, 1);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 1);
-       rtn = rt_band_set_pixel(band2, 2, 2, 1);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
 
        rtn = rt_raster_fully_within_distance(
                rast1, 0,
@@ -6542,7 +6636,7 @@ static void testDFullyWithin() {
                5,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result != 1));
 
        rtn = rt_raster_fully_within_distance(
@@ -6551,7 +6645,7 @@ static void testDFullyWithin() {
                11.5,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        deepRelease(rast2);
@@ -6565,16 +6659,16 @@ static void testDFullyWithin() {
 
        band2 = addBand(rast2, PT_8BUI, 1, 0);
        CHECK(band2);
-       rt_band_set_nodata(band2, 0);
-       rtn = rt_band_set_pixel(band2, 0, 0, 1);
-       rtn = rt_band_set_pixel(band2, 0, 1, 2);
-       rtn = rt_band_set_pixel(band2, 0, 2, 3);
-       rtn = rt_band_set_pixel(band2, 1, 0, 1);
-       rtn = rt_band_set_pixel(band2, 1, 1, 2);
-       rtn = rt_band_set_pixel(band2, 1, 2, 3);
-       rtn = rt_band_set_pixel(band2, 2, 0, 1);
-       rtn = rt_band_set_pixel(band2, 2, 1, 2);
-       rtn = rt_band_set_pixel(band2, 2, 2, 3);
+       rt_band_set_nodata(band2, 0, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 0, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 1, 2, 3, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 1, 2, NULL);
+       rtn = rt_band_set_pixel(band2, 2, 2, 3, NULL);
 
        rtn = rt_raster_fully_within_distance(
                rast1, 0,
@@ -6582,7 +6676,7 @@ static void testDFullyWithin() {
                6.1,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /* rast2 (skewed by -1, 1) */
@@ -6594,7 +6688,7 @@ static void testDFullyWithin() {
                7.1,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        /* rast2 (skewed by 1, -1) */
@@ -6606,7 +6700,7 @@ static void testDFullyWithin() {
                8,
                &result
        );
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((result == 1));
 
        deepRelease(rast2);
@@ -6628,34 +6722,34 @@ static void testAlignment() {
        rt_raster_set_scale(rast2, 1, 1);
 
        rtn = rt_raster_same_alignment(rast1, rast2, &aligned);
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((aligned != 0));
 
        rt_raster_set_scale(rast2, 0.1, 0.1);
        rtn = rt_raster_same_alignment(rast1, rast2, &aligned);
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((aligned == 0));
        rt_raster_set_scale(rast2, 1, 1);
 
        rt_raster_set_skews(rast2, -0.5, 0.5);
        rtn = rt_raster_same_alignment(rast1, rast2, &aligned);
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((aligned == 0));
        rt_raster_set_skews(rast2, 0, 0);
 
        rt_raster_set_offsets(rast2, 1, 1);
        rtn = rt_raster_same_alignment(rast1, rast2, &aligned);
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((aligned != 0));
 
        rt_raster_set_offsets(rast2, 2, 3);
        rtn = rt_raster_same_alignment(rast1, rast2, &aligned);
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((aligned != 0));
 
        rt_raster_set_offsets(rast2, 0.1, 0.1);
        rtn = rt_raster_same_alignment(rast1, rast2, &aligned);
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK((aligned == 0));
 
        deepRelease(rast2);
@@ -6802,7 +6896,7 @@ static void testLoadOfflineBand() {
        for (x = 0; x < maxX; x++) {
                for (y = 0; y < maxY; y++) {
                        rtn = rt_band_get_pixel(band, x, y, &val, NULL);
-                       CHECK((rtn == 0));
+                       CHECK_EQUALS(rtn, ES_NONE);
                        CHECK(FLT_EQ(val, 255));
                }
        }
@@ -6830,12 +6924,12 @@ static void testCellGeoPoint() {
        xr = 0;
        yr = 0;
        rtn = rt_raster_cell_to_geopoint(raster, xr, yr, &xw, &yw, NULL);
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK(FLT_EQ(xw, gt[0]));
        CHECK(FLT_EQ(yw, gt[3]));
 
        rtn = rt_raster_geopoint_to_cell(raster, xw, yw, &xr, &yr, NULL);
-       CHECK((rtn != 0));
+       CHECK_EQUALS(rtn, ES_NONE);
        CHECK(FLT_EQ(xr, 0));
        CHECK(FLT_EQ(yr, 0));
 
@@ -6864,28 +6958,28 @@ static void testNearestPixel() {
 
        for (x = 0; x < maxX; x++) {
                for (y = 0; y < maxY; y++) {
-                       rtn = rt_band_set_pixel(band, x, y, 1);
-                       CHECK((rtn != -1));
+                       rtn = rt_band_set_pixel(band, x, y, 1, NULL);
+                       CHECK_EQUALS(rtn, ES_NONE);
                }
        }
 
-       rt_band_set_pixel(band, 0, 0, 0);
-       rt_band_set_pixel(band, 3, 0, 0);
-       rt_band_set_pixel(band, 6, 0, 0);
-       rt_band_set_pixel(band, 9, 0, 0);
-       rt_band_set_pixel(band, 1, 2, 0);
-       rt_band_set_pixel(band, 4, 2, 0);
-       rt_band_set_pixel(band, 7, 2, 0);
-       rt_band_set_pixel(band, 2, 4, 0);
-       rt_band_set_pixel(band, 5, 4, 0);
-       rt_band_set_pixel(band, 8, 4, 0);
-       rt_band_set_pixel(band, 0, 6, 0);
-       rt_band_set_pixel(band, 3, 6, 0);
-       rt_band_set_pixel(band, 6, 6, 0);
-       rt_band_set_pixel(band, 9, 6, 0);
-       rt_band_set_pixel(band, 1, 8, 0);
-       rt_band_set_pixel(band, 4, 8, 0);
-       rt_band_set_pixel(band, 7, 8, 0);
+       rt_band_set_pixel(band, 0, 0, 0, NULL);
+       rt_band_set_pixel(band, 3, 0, 0, NULL);
+       rt_band_set_pixel(band, 6, 0, 0, NULL);
+       rt_band_set_pixel(band, 9, 0, 0, NULL);
+       rt_band_set_pixel(band, 1, 2, 0, NULL);
+       rt_band_set_pixel(band, 4, 2, 0, NULL);
+       rt_band_set_pixel(band, 7, 2, 0, NULL);
+       rt_band_set_pixel(band, 2, 4, 0, NULL);
+       rt_band_set_pixel(band, 5, 4, 0, NULL);
+       rt_band_set_pixel(band, 8, 4, 0, NULL);
+       rt_band_set_pixel(band, 0, 6, 0, NULL);
+       rt_band_set_pixel(band, 3, 6, 0, NULL);
+       rt_band_set_pixel(band, 6, 6, 0, NULL);
+       rt_band_set_pixel(band, 9, 6, 0, NULL);
+       rt_band_set_pixel(band, 1, 8, 0, NULL);
+       rt_band_set_pixel(band, 4, 8, 0, NULL);
+       rt_band_set_pixel(band, 7, 8, 0, NULL);
 
        /* 0,0 */
        rtn = rt_band_get_nearest_pixel(
@@ -7001,7 +7095,8 @@ static void testNearestPixel() {
                &nodata,
                &dimx, &dimy
        );
-       CHECK((rtn != 0));
+       rtdealloc(npixels);
+       CHECK((rtn == ES_NONE));
        CHECK((dimx == 3));
        CHECK((dimy == 3));
 
@@ -7013,8 +7108,6 @@ static void testNearestPixel() {
        rtdealloc(nodata);
        rtdealloc(value);
 
-       if (rtn)
-               rtdealloc(npixels);
 
        /* -2,2 distance 1 */
        rtn = rt_band_get_nearest_pixel(
@@ -7128,28 +7221,28 @@ static void testPixelOfValue() {
 
        for (x = 0; x < maxX; x++) {
                for (y = 0; y < maxY; y++) {
-                       rtn = rt_band_set_pixel(band, x, y, 1);
-                       CHECK((rtn != -1));
+                       rtn = rt_band_set_pixel(band, x, y, 1, NULL);
+                       CHECK_EQUALS(rtn, ES_NONE);
                }
        }
 
-       rt_band_set_pixel(band, 0, 0, 0);
-       rt_band_set_pixel(band, 3, 0, 0);
-       rt_band_set_pixel(band, 6, 0, 0);
-       rt_band_set_pixel(band, 9, 0, 0);
-       rt_band_set_pixel(band, 1, 2, 0);
-       rt_band_set_pixel(band, 4, 2, 0);
-       rt_band_set_pixel(band, 7, 2, 0);
-       rt_band_set_pixel(band, 2, 4, 0);
-       rt_band_set_pixel(band, 5, 4, 0);
-       rt_band_set_pixel(band, 8, 4, 0);
-       rt_band_set_pixel(band, 0, 6, 0);
-       rt_band_set_pixel(band, 3, 6, 0);
-       rt_band_set_pixel(band, 6, 6, 0);
-       rt_band_set_pixel(band, 9, 6, 0);
-       rt_band_set_pixel(band, 1, 8, 0);
-       rt_band_set_pixel(band, 4, 8, 0);
-       rt_band_set_pixel(band, 7, 8, 0);
+       rt_band_set_pixel(band, 0, 0, 0, NULL);
+       rt_band_set_pixel(band, 3, 0, 0, NULL);
+       rt_band_set_pixel(band, 6, 0, 0, NULL);
+       rt_band_set_pixel(band, 9, 0, 0, NULL);
+       rt_band_set_pixel(band, 1, 2, 0, NULL);
+       rt_band_set_pixel(band, 4, 2, 0, NULL);
+       rt_band_set_pixel(band, 7, 2, 0, NULL);
+       rt_band_set_pixel(band, 2, 4, 0, NULL);
+       rt_band_set_pixel(band, 5, 4, 0, NULL);
+       rt_band_set_pixel(band, 8, 4, 0, NULL);
+       rt_band_set_pixel(band, 0, 6, 0, NULL);
+       rt_band_set_pixel(band, 3, 6, 0, NULL);
+       rt_band_set_pixel(band, 6, 6, 0, NULL);
+       rt_band_set_pixel(band, 9, 6, 0, NULL);
+       rt_band_set_pixel(band, 1, 8, 0, NULL);
+       rt_band_set_pixel(band, 4, 8, 0, NULL);
+       rt_band_set_pixel(band, 7, 8, 0, NULL);
 
        pixels = NULL;
        rtn = rt_band_get_pixel_of_value(
@@ -7171,9 +7264,9 @@ static void testPixelOfValue() {
        if (rtn)
                rtdealloc(pixels);
 
-       rt_band_set_pixel(band, 4, 2, 3);
-       rt_band_set_pixel(band, 7, 2, 5);
-       rt_band_set_pixel(band, 1, 8, 3);
+       rt_band_set_pixel(band, 4, 2, 3, NULL);
+       rt_band_set_pixel(band, 7, 2, 5, NULL);
+       rt_band_set_pixel(band, 1, 8, 3, NULL);
 
        pixels = NULL;
        rtn = rt_band_get_pixel_of_value(
@@ -7205,28 +7298,28 @@ static void testPixelAsPolygon() {
 
        for (x = 0; x < maxX; x++) {
                for (y = 0; y < maxY; y++) {
-                       rtn = rt_band_set_pixel(band, x, y, 1);
-                       CHECK((rtn != -1));
+                       rtn = rt_band_set_pixel(band, x, y, 1, NULL);
+                       CHECK_EQUALS(rtn, ES_NONE);
                }
        }
 
-       rt_band_set_pixel(band, 0, 0, 0);
-       rt_band_set_pixel(band, 3, 0, 0);
-       rt_band_set_pixel(band, 6, 0, 0);
-       rt_band_set_pixel(band, 9, 0, 0);
-       rt_band_set_pixel(band, 1, 2, 0);
-       rt_band_set_pixel(band, 4, 2, 0);
-       rt_band_set_pixel(band, 7, 2, 0);
-       rt_band_set_pixel(band, 2, 4, 0);
-       rt_band_set_pixel(band, 5, 4, 0);
-       rt_band_set_pixel(band, 8, 4, 0);
-       rt_band_set_pixel(band, 0, 6, 0);
-       rt_band_set_pixel(band, 3, 6, 0);
-       rt_band_set_pixel(band, 6, 6, 0);
-       rt_band_set_pixel(band, 9, 6, 0);
-       rt_band_set_pixel(band, 1, 8, 0);
-       rt_band_set_pixel(band, 4, 8, 0);
-       rt_band_set_pixel(band, 7, 8, 0);
+       rt_band_set_pixel(band, 0, 0, 0, NULL);
+       rt_band_set_pixel(band, 3, 0, 0, NULL);
+       rt_band_set_pixel(band, 6, 0, 0, NULL);
+       rt_band_set_pixel(band, 9, 0, 0, NULL);
+       rt_band_set_pixel(band, 1, 2, 0, NULL);
+       rt_band_set_pixel(band, 4, 2, 0, NULL);
+       rt_band_set_pixel(band, 7, 2, 0, NULL);
+       rt_band_set_pixel(band, 2, 4, 0, NULL);
+       rt_band_set_pixel(band, 5, 4, 0, NULL);
+       rt_band_set_pixel(band, 8, 4, 0, NULL);
+       rt_band_set_pixel(band, 0, 6, 0, NULL);
+       rt_band_set_pixel(band, 3, 6, 0, NULL);
+       rt_band_set_pixel(band, 6, 6, 0, NULL);
+       rt_band_set_pixel(band, 9, 6, 0, NULL);
+       rt_band_set_pixel(band, 1, 8, 0, NULL);
+       rt_band_set_pixel(band, 4, 8, 0, NULL);
+       rt_band_set_pixel(band, 7, 8, 0, NULL);
 
        poly = rt_raster_pixel_as_polygon(rast, 1, 1);
        CHECK((poly != NULL));
@@ -7256,7 +7349,7 @@ static void testRasterSurface() {
 
        for (y = 0; y < maxY; y++) {
                for (x = 0; x < maxX; x++) {
-                       rt_band_set_pixel(band, x, y, 1);
+                       rt_band_set_pixel(band, x, y, 1, NULL);
                }
        }
 
@@ -7270,7 +7363,7 @@ static void testRasterSurface() {
        mpoly = NULL;
 
        /* 0,0 NODATA */
-       rt_band_set_pixel(band, 0, 0, 0);
+       rt_band_set_pixel(band, 0, 0, 0, NULL);
 
        mpoly = rt_raster_surface(rast, 0, &err);
        CHECK(err);
@@ -7282,7 +7375,7 @@ static void testRasterSurface() {
        mpoly = NULL;
 
        /* plus 1,1 NODATA */
-       rt_band_set_pixel(band, 1, 1, 0);
+       rt_band_set_pixel(band, 1, 1, 0, NULL);
 
        mpoly = rt_raster_surface(rast, 0, &err);
        CHECK(err);
@@ -7294,7 +7387,7 @@ static void testRasterSurface() {
        mpoly = NULL;
 
        /* plus 2,2 NODATA */
-       rt_band_set_pixel(band, 2, 2, 0);
+       rt_band_set_pixel(band, 2, 2, 0, NULL);
 
        mpoly = rt_raster_surface(rast, 0, &err);
        CHECK(err);
@@ -7310,7 +7403,7 @@ static void testRasterSurface() {
        mpoly = NULL;
 
        /* plus 3,3 NODATA */
-       rt_band_set_pixel(band, 3, 3, 0);
+       rt_band_set_pixel(band, 3, 3, 0, NULL);
 
        mpoly = rt_raster_surface(rast, 0, &err);
        CHECK(err);
@@ -7326,7 +7419,7 @@ static void testRasterSurface() {
        mpoly = NULL;
 
        /* plus 4,4 NODATA */
-       rt_band_set_pixel(band, 4, 4, 0);
+       rt_band_set_pixel(band, 4, 4, 0, NULL);
 
        mpoly = rt_raster_surface(rast, 0, &err);
        CHECK(err);
@@ -7338,10 +7431,10 @@ static void testRasterSurface() {
        mpoly = NULL;
 
        /* a whole lot more NODATA */
-       rt_band_set_pixel(band, 4, 0, 0);
-       rt_band_set_pixel(band, 3, 1, 0);
-       rt_band_set_pixel(band, 1, 3, 0);
-       rt_band_set_pixel(band, 0, 4, 0);
+       rt_band_set_pixel(band, 4, 0, 0, NULL);
+       rt_band_set_pixel(band, 3, 1, 0, NULL);
+       rt_band_set_pixel(band, 1, 3, 0, NULL);
+       rt_band_set_pixel(band, 0, 4, 0, NULL);
 
        mpoly = rt_raster_surface(rast, 0, &err);
        CHECK(err);
@@ -7851,7 +7944,7 @@ static void testRasterIterator() {
 
        for (y = 0; y < maxY; y++) {
                for (x = 0; x < maxX; x++) {
-                       rt_band_set_pixel(band, x, y, x + (y * maxX));
+                       rt_band_set_pixel(band, x, y, x + (y * maxX), NULL);
                }
        }
 
@@ -7866,7 +7959,7 @@ static void testRasterIterator() {
 
        for (y = 0; y < maxY; y++) {
                for (x = 0; x < maxX; x++) {
-                       rt_band_set_pixel(band, x, y, (x + (y * maxX)) + 100);
+                       rt_band_set_pixel(band, x, y, (x + (y * maxX)) + 100, NULL);
                }
        }
 
@@ -8179,23 +8272,23 @@ static void testGetPixelLine() {
 
        for (y = 0; y < maxY; y++) {
                for (x = 0; x < maxX; x++)
-                       rt_band_set_pixel(band, x, y, x + (y * maxX));
+                       rt_band_set_pixel(band, x, y, x + (y * maxX), NULL);
        }
 
        err = rt_band_get_pixel_line(band, 0, 0, maxX, &vals, &nvals);
-       CHECK((err == 0));
+       CHECK_EQUALS(err, ES_NONE);
        CHECK((nvals == maxX));
        CHECK((((int8_t *) vals)[3] == 3));
        rtdealloc(vals);
        
        err = rt_band_get_pixel_line(band, 4, 4, maxX, &vals, &nvals);
-       CHECK((err == 0));
+       CHECK_EQUALS(err, ES_NONE);
        CHECK((nvals == 1));
        CHECK((((int8_t *) vals)[0] == 24));
        rtdealloc(vals);
 
        err = rt_band_get_pixel_line(band, maxX, maxY, maxX, &vals, &nvals);
-       CHECK((err != 0));
+       CHECK((err != ES_NONE));
 
        deepRelease(rast);
 }
index 76bb7c0c3bfd42dffd332cb9090fb8822ca75169..1a7865e52a5c0748c8fa629ae6802f4ae1de4bf4 100644 (file)
@@ -511,6 +511,7 @@ main()
     CHECK_EQUALS(rt_raster_get_height(raster), 2);
     {
                                double val;
+                               uint8_t bandnum = 0;
         rt_band band = rt_raster_get_band(raster, 0);
         CHECK(band);
         CHECK_EQUALS(rt_band_get_pixtype(band), PT_16BSI);
@@ -518,10 +519,9 @@ main()
         CHECK(rt_band_get_hasnodata_flag(band));
                                rt_band_get_nodata(band, &val);
         CHECK_EQUALS(val, -1);
-        printf("ext band path: %s\n", rt_band_get_ext_path(band));
-        printf("ext band  num: %u\n", rt_band_get_ext_band_num(band));
         CHECK( ! strcmp(rt_band_get_ext_path(band), "/tmp/t.tif"));
-        CHECK_EQUALS(rt_band_get_ext_band_num(band), 3);
+        CHECK_EQUALS(rt_band_get_ext_band_num(band, &bandnum), ES_NONE);
+        CHECK_EQUALS(bandnum, 3);
     }
 
     out  = rt_raster_to_hexwkb(raster, &len);