]> granicus.if.org Git - postgis/commitdiff
Changed function signature for core API function rt_band_get_pixel() to
authorBborie Park <bkpark at ucdavis.edu>
Mon, 22 Oct 2012 17:19:04 +0000 (17:19 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Mon, 22 Oct 2012 17:19:04 +0000 (17:19 +0000)
indicate if pixel is NODATA

git-svn-id: http://svn.osgeo.org/postgis/trunk@10510 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 a87512888eef4f0e07a0029e0901761b204bb984..9b27b21668fededa875e7b1c5a6007a386814a20 100644 (file)
@@ -1321,10 +1321,10 @@ rt_band_new_inline(
        band->width = width;
        band->height = height;
        band->hasnodata = hasnodata;
+       band->isnodata = FALSE; /* we don't know what is in data, so must be FALSE */
        band->nodataval = 0;
        band->data.mem = data;
        band->ownsdata = 0; /* we do NOT own this data!!! */
-       band->isnodata = FALSE;
        band->raster = NULL;
 
        RASTER_DEBUGF(3, "Created rt_band with dimensions %d x %d", band->width, band->height);
@@ -2067,7 +2067,7 @@ rt_band_set_pixel_line(
 #if POSTGIS_DEBUG_LEVEL > 0
        {
                double value;
-               rt_band_get_pixel(band, x, y, &value);
+               rt_band_get_pixel(band, x, y, &value, NULL);
                RASTER_DEBUGF(4, "pixel at (%d, %d) = %f", x, y, value);
        }
 #endif
@@ -2237,7 +2237,8 @@ rt_band_set_pixel(
  * @param band : the band to set nodata value to
  * @param x : x ordinate (0-based)
  * @param y : x ordinate (0-based)
- * @param *result: result if there is a value
+ * @param *value: pixel value
+ * @param *nodata: flag (0 or 1) indicating if pixel is NODATA
  *
  * @return 0 on success, -1 on error (value out of valid range).
  */
@@ -2245,126 +2246,142 @@ int
 rt_band_get_pixel(
        rt_band band,
        int x, int y,
-       double *result
+       double *value,
+       int *nodata
 ) {
-    rt_pixtype pixtype = PT_END;
-    uint8_t* data = NULL;
-    uint32_t offset = 0;
+       rt_pixtype pixtype = PT_END;
+       uint8_t* data = NULL;
+       uint32_t offset = 0; 
 
-    assert(NULL != band);
+       assert(NULL != band);
 
-    pixtype = band->pixtype;
+       /* set nodata to 0 */
+       if (nodata != NULL)
+               *nodata = 0;
 
-    if (
-                       x < 0 || x >= band->width ||
-                       y < 0 || y >= band->height
-               ) {
-        rtwarn("Attempting to get pixel value with out of range raster coordinates: (%d, %d)", x, y);
-        return -1;
-    }
+       if (
+               x < 0 || x >= band->width ||
+               y < 0 || y >= band->height
+       ) {
+               rtwarn("Attempting to get pixel value with out of range raster coordinates: (%d, %d)", x, y);
+               return -1;
+       }
 
-    data = rt_band_get_data(band);
-               if (data == NULL) {
-                       rterror("rt_band_get_pixel: Cannot get band data");
-                       return -1;
-               }
+       /* band is NODATA */
+       if (band->hasnodata && band->isnodata) {
+               rtinfo("Band's isnodata flag is TRUE. Returning NODATA value");
+               *value = band->nodataval;
+               if (nodata != NULL) *nodata = 1;
+               return 0;
+       }
 
-    offset = x + (y * band->width); /* +1 for the nodata value */
+       data = rt_band_get_data(band);
+       if (data == NULL) {
+               rterror("rt_band_get_pixel: Cannot get band data");
+               return -1;
+       }
 
-    switch (pixtype) {
-        case PT_1BB:
-#ifdef OPTIMIZE_SPACE
-        {
-            int byteOffset = offset / 8;
-            int bitOffset = offset % 8;
-            data += byteOffset;
+       /* +1 for the nodata value */
+       offset = x + (y * band->width);
 
-            /* Bit to set is bitOffset into data */
-            *result = getBits(data, val, 1, bitOffset);
-            return 0;
-        }
-#endif
+       pixtype = band->pixtype;
 
-        case PT_2BUI:
+       switch (pixtype) {
+               case PT_1BB:
 #ifdef OPTIMIZE_SPACE
-        {
-            int byteOffset = offset / 4;
-            int bitOffset = offset % 4;
-            data += byteOffset;
+                       {
+                               int byteOffset = offset / 8;
+                               int bitOffset = offset % 8;
+                               data += byteOffset;
 
-            /* Bits to set start at bitOffset into data */
-            *result = getBits(data, val, 2, bitOffset);
-            return 0;
-        }
+                               /* Bit to set is bitOffset into data */
+                               *value = getBits(data, val, 1, bitOffset);
+                               break;
+                       }
 #endif
+               case PT_2BUI:
+#ifdef OPTIMIZE_SPACE
+                       {
+                               int byteOffset = offset / 4;
+                               int bitOffset = offset % 4;
+                               data += byteOffset;
 
-        case PT_4BUI:
+                               /* Bits to set start at bitOffset into data */
+                               *value = getBits(data, val, 2, bitOffset);
+                               break;
+                       }
+#endif
+               case PT_4BUI:
 #ifdef OPTIMIZE_SPACE
-        {
-            int byteOffset = offset / 2;
-            int bitOffset = offset % 2;
-            data += byteOffset;
+                       {
+                               int byteOffset = offset / 2;
+                               int bitOffset = offset % 2;
+                               data += byteOffset;
 
-            /* Bits to set start at bitOffset into data */
-            *result = getBits(data, val, 2, bitOffset);
-            return 0;
-        }
+                               /* Bits to set start at bitOffset into data */
+                               *value = getBits(data, val, 2, bitOffset);
+                               break;
+                       }
 #endif
+               case PT_8BSI: {
+                       int8_t val = data[offset];
+                       *value = val;
+                       break;
+               }
+               case PT_8BUI: {
+                       uint8_t val = data[offset];
+                       *value = val;
+                       break;
+               }
+               case PT_16BSI: {
+                       int16_t *ptr = (int16_t*) data; /* we assume correct alignment */
+                       *value = ptr[offset];
+                       break;
+               }
+               case PT_16BUI: {
+                       uint16_t *ptr = (uint16_t*) data; /* we assume correct alignment */
+                       *value = ptr[offset];
+                       break;
+               }
+               case PT_32BSI: {
+                       int32_t *ptr = (int32_t*) data; /* we assume correct alignment */
+                       *value = ptr[offset];
+                       break;
+               }
+               case PT_32BUI: {
+                       uint32_t *ptr = (uint32_t*) data; /* we assume correct alignment */
+                       *value = ptr[offset];
+                       break;
+               }
+               case PT_32BF: {
+                       float *ptr = (float*) data; /* we assume correct alignment */
+                       *value = ptr[offset];
+                       break;
+               }
+               case PT_64BF: {
+                       double *ptr = (double*) data; /* we assume correct alignment */
+                       *value = ptr[offset];
+                       break;
+               }
+               default: {
+                       rterror("rt_band_get_pixel: Unknown pixeltype %d", pixtype);
+                       return -1;
+               }
+       }
 
-        case PT_8BSI:
-        {
-            int8_t val = data[offset];
-            *result = val;
-            return 0;
-        }
-        case PT_8BUI:
-        {
-            uint8_t val = data[offset];
-            *result = val;
-            return 0;
-        }
-        case PT_16BSI:
-        {
-            int16_t *ptr = (int16_t*) data; /* we assume correct alignment */
-            *result = ptr[offset];
-            return 0;
-        }
-        case PT_16BUI:
-        {
-            uint16_t *ptr = (uint16_t*) data; /* we assume correct alignment */
-            *result = ptr[offset];
-            return 0;
-        }
-        case PT_32BSI:
-        {
-            int32_t *ptr = (int32_t*) data; /* we assume correct alignment */
-            *result = ptr[offset];
-            return 0;
-        }
-        case PT_32BUI:
-        {
-            uint32_t *ptr = (uint32_t*) data; /* we assume correct alignment */
-            *result = ptr[offset];
-            return 0;
-        }
-        case PT_32BF:
-        {
-            float *ptr = (float*) data; /* we assume correct alignment */
-            *result = ptr[offset];
-            return 0;
-        }
-        case PT_64BF:
-        {
-            double *ptr = (double*) data; /* we assume correct alignment */
-            *result = ptr[offset];
-            return 0;
-        }
-        default:
-        {
-            rterror("rt_band_get_pixel: Unknown pixeltype %d", pixtype);
-            return -1;
-        }
-    }
+       /* set NODATA flag */
+       if (band->hasnodata && nodata != NULL) {
+               if (
+                       FLT_EQ(*value, band->nodataval) ||
+                       rt_band_clamped_value_is_nodata(band, *value) == 1
+               ) {
+                       *nodata = 1;
+               }
+               else
+                       *nodata = 0;
+       }
+
+       return 0;
 }
 
 /**
@@ -2587,7 +2604,8 @@ int rt_band_get_nearest_pixel(
                                                if (rt_band_get_pixel(
                                                        band,
                                                        _x, _y,
-                                                       &pixval
+                                                       &pixval,
+                                                       NULL
                                                ) < 0) {
                                                        rterror("rt_band_get_nearest_pixel: Unable to get pixel value");
                                                        if (count) rtdealloc(*npixels);
@@ -2684,7 +2702,7 @@ rt_band_get_pixel_of_value(
 
        for (x = 0; x < band->width; x++) {
                for (y = 0; y < band->height; y++) {
-                       err = rt_band_get_pixel(band, x, y, &pixval);
+                       err = rt_band_get_pixel(band, x, y, &pixval, NULL);
                        if (err != 0) {
                                rterror("rt_band_get_pixel_of_value: Cannot get band pixel");
                                return -1;
@@ -2769,7 +2787,7 @@ rt_band_check_is_nodata(rt_band band) {
        /* Check all pixels */
        for (i = 0; i < band->width; i++) {
                for (j = 0; j < band->height; j++) {
-                       err = rt_band_get_pixel(band, i, j, &pxValue);
+                       err = rt_band_get_pixel(band, i, j, &pxValue, NULL);
                        if (err != 0) {
                                rterror("rt_band_check_is_nodata: Cannot get band pixel");
                                return FALSE;
@@ -3101,7 +3119,7 @@ rt_band_get_summary_stats(
                        RASTER_DEBUGF(5, "(x, y, z) = (%d, %d, %d)", x, y, z);
                        if (y >= band->height || z > sample_per) break;
 
-                       rtn = rt_band_get_pixel(band, x, y, &value);
+                       rtn = rt_band_get_pixel(band, x, y, &value, NULL);
 #if POSTGIS_DEBUG_LEVEL > 0
                        if (rtn != -1) {
                                RASTER_DEBUGF(5, "(x, y, value) = (%d,%d, %f)", x, y, value);
@@ -4006,7 +4024,7 @@ rt_band_get_quantiles_stream(rt_band band,
                        RASTER_DEBUGF(5, "(x, y, z) = (%d, %d, %d)", x, y, z);
                        if (y >= band->height || z > sample_per) break;
 
-                       status = rt_band_get_pixel(band, x, y, &value);
+                       status = rt_band_get_pixel(band, x, y, &value, NULL);
 
                        j++;
                        if (
@@ -4596,7 +4614,7 @@ rt_band_get_value_count(rt_band band, int exclude_nodata_value,
 
        for (x = 0; x < band->width; x++) {
                for (y = 0; y < band->height; y++) {
-                       rtn = rt_band_get_pixel(band, x, y, &pxlval);
+                       rtn = rt_band_get_pixel(band, x, y, &pxlval, NULL);
 
                        /* error getting value, continue */
                        if (rtn == -1) continue;
@@ -4864,7 +4882,7 @@ rt_band_reclass(rt_band srcband, rt_pixtype pixtype,
 
        for (x = 0; x < width; x++) {
                for (y = 0; y < height; y++) {
-                       rtn = rt_band_get_pixel(srcband, x, y, &ov);
+                       rtn = rt_band_get_pixel(srcband, x, y, &ov, NULL);
 
                        /* error getting value, skip */
                        if (rtn == -1) {
@@ -8759,7 +8777,7 @@ rt_raster_to_gdal_mem(
                                        iXMax = x + nXValid;
                                        for (iY = y; iY < iYMax; iY++)  {
                                                for (iX = x; iX < iXMax; iX++)  {
-                                                       if (rt_band_get_pixel(rtband, iX, iY, &value) != 0) {
+                                                       if (rt_band_get_pixel(rtband, iX, iY, &value, NULL) != 0) {
                                                                rterror("rt_raster_to_gdal_mem: Could not get pixel value to convert from 8BSI to 16BSI");
                                                                rtdealloc(values);
                                                                if (allocBandNums) rtdealloc(bandNums);
@@ -11246,7 +11264,7 @@ int rt_raster_intersects_algorithm(
                                                        else if (hasnodata1 == FALSE)
                                                                val1 = 1;
                                                        /* unable to get value at cell */
-                                                       else if (rt_band_get_pixel(band1, Qr[pX], Qr[pY], &val1) < 0)
+                                                       else if (rt_band_get_pixel(band1, Qr[pX], Qr[pY], &val1, NULL) < 0)
                                                                noval1 = 1;
 
                                                        /* unable to convert point to cell */
@@ -11269,7 +11287,7 @@ int rt_raster_intersects_algorithm(
                                                        else if (hasnodata2 == FALSE)
                                                                val2 = 1;
                                                        /* unable to get value at cell */
-                                                       else if (rt_band_get_pixel(band2, Qr[pX], Qr[pY], &val2) < 0)
+                                                       else if (rt_band_get_pixel(band2, Qr[pX], Qr[pY], &val2, NULL) < 0)
                                                                noval2 = 1;
 
                                                        if (!noval1) {
@@ -11588,7 +11606,7 @@ rt_raster_intersects(
                                        for (row = rowoffset; row < *heightS; row += 3) {
                                                if (hasnodataS == FALSE)
                                                        valS = 1;
-                                               else if (rt_band_get_pixel(bandS, col, row, &valS) < 0)
+                                               else if (rt_band_get_pixel(bandS, col, row, &valS, NULL) < 0)
                                                        continue;
 
                                                if ((hasnodataS == FALSE) || (
@@ -11620,7 +11638,7 @@ rt_raster_intersects(
 
                                                        if (hasnodataS == FALSE)
                                                                valL = 1;
-                                                       else if (rt_band_get_pixel(bandL, Qr[pX], Qr[pY], &valL) < 0)
+                                                       else if (rt_band_get_pixel(bandL, Qr[pX], Qr[pY], &valL, NULL) < 0)
                                                                continue;
 
                                                        if ((hasnodataL == FALSE) || (
@@ -13714,7 +13732,8 @@ rt_raster_iterator(
                                        if (rt_band_get_pixel(
                                                _param->band[i],
                                                x, y,
-                                               &value
+                                               &value,
+                                               NULL
                                        ) < 0) {
                                                rterror("rt_raster_iterator: Unable to get the pixel value of band");
 
index 83bd94fc4168ebc4e29624e5cc9967e50d0ea24e..3380ea9e204af7ef8475a0232e0dbb4e281c8a89 100644 (file)
@@ -603,14 +603,16 @@ int rt_band_set_pixel(
  * @param band : the band to get pixel value from
  * @param x : x ordinate (0-based)
  * @param y : x ordinate (0-based)
- * @param *result: result if there is a value
+ * @param *value: pixel value
+ * @param *nodata: flag (0 or 1) indicating if pixel is NODATA
  *
  * @return 0 on success, -1 on error (value out of valid range).
  */
 int rt_band_get_pixel(
        rt_band band,
        int x, int y,
-       double *result
+       double *value,
+       int *nodata
 );
 
 /**
@@ -2045,7 +2047,7 @@ struct rt_band_t {
     uint16_t height;
     int32_t hasnodata; /* a flag indicating if this band contains nodata values */
     int32_t isnodata;   /* a flag indicating if this band is filled only with
-                           nodata values */
+                           nodata values. flag CANNOT be TRUE if hasnodata is FALSE */
     double nodataval; /* int will be converted ... */
     int8_t ownsdata; /* 0, externally owned. 1, internally owned. only applies to data.mem */
 
index a10cf66f2194a3f38a46b920a7a99ff6abe93222..b0a9fcd16c8d4dba318afe5f1fdd7012c16014b1 100644 (file)
@@ -2415,7 +2415,7 @@ Datum RASTER_getPixelValue(PG_FUNCTION_ARGS)
         PG_RETURN_NULL();
     }
     /* Fetch pixel using 0-based coordinates */
-    result = rt_band_get_pixel(band, x - 1, y - 1, &pixvalue);
+    result = rt_band_get_pixel(band, x - 1, y - 1, &pixvalue, NULL);
 
     /* If the result is -1 or the value is nodata and we take nodata into account
      * then return nodata = NULL */
@@ -2735,7 +2735,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) != 0) {
+                                       if (rt_band_get_pixel(band, x, y, &val, NULL) != 0) {
                                                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);
@@ -3332,7 +3332,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);
+                       rtn = rt_band_get_pixel(band, pixval[i].x, pixval[i].y, &val, NULL);
                        if (rtn != 0) {
                                elog(ERROR, "Cannot get value of pixel.  Returning NULL");
                                pfree(pixval);
@@ -3769,7 +3769,7 @@ Datum RASTER_setPixelValuesGeomval(PG_FUNCTION_ARGS)
                                }
 
                                /* get pixel value */
-                               if (rt_band_get_pixel(band, xy[0], xy[1], &value) != 0) {
+                               if (rt_band_get_pixel(band, xy[0], xy[1], &value, NULL) != 0) {
                                        elog(ERROR, "RASTER_setPixelValuesGeomval: Unable to get pixel value");
                                        rtpg_setvaluesgv_arg_destroy(arg);
                                        rt_raster_destroy(raster);
@@ -4063,7 +4063,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)) != 0) {
+                                       if (rt_band_get_pixel(band, x - 1, y - 1, &(pix[pixcount].value), NULL) != 0) {
                                                elog(ERROR, "RASTER_getPixelPolygons: Could not get pixel value");
 
                                                for (i = 0; i < pixcount; i++)
@@ -4580,7 +4580,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) < 0) {
+               if (rt_band_get_pixel(band, x, y, &value, NULL) < 0) {
                        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);
@@ -4814,7 +4814,8 @@ Datum RASTER_neighborhood(PG_FUNCTION_ARGS)
                if (rt_band_get_pixel(
                        band,
                        _x, _y,
-                       &pixval
+                       &pixval,
+                       NULL
                ) < 0) {
                        elog(NOTICE, "Unable to get the pixel of band at index %d. Returning NULL", bandindex);
                        rt_band_destroy(band);
@@ -6070,7 +6071,7 @@ Datum RASTER_mapAlgebraExpr(PG_FUNCTION_ARGS)
 
     for (x = 0; x < width; x++) {
         for(y = 0; y < height; y++) {
-            ret = rt_band_get_pixel(band, x, y, &r);
+            ret = rt_band_get_pixel(band, x, y, &r, NULL);
 
             /**
              * We compute a value only for the withdata value pixel since the
@@ -6554,7 +6555,7 @@ Datum RASTER_mapAlgebraFct(PG_FUNCTION_ARGS)
 
     for (x = 0; x < width; x++) {
         for(y = 0; y < height; y++) {
-            ret = rt_band_get_pixel(band, x, y, &r);
+            ret = rt_band_get_pixel(band, x, y, &r, NULL);
 
             /**
              * We compute a value only for the withdata value pixel since the
@@ -13606,7 +13607,7 @@ Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS)
                                                (_x >= 0 && _x < _dim[i][0]) &&
                                                (_y >= 0 && _y < _dim[i][1])
                                        ) {
-                                               err = rt_band_get_pixel(_band[i], _x, _y, &(_pixel[i]));
+                                               err = rt_band_get_pixel(_band[i], _x, _y, &(_pixel[i]), NULL);
                                                if (err < 0) {
                                                        elog(ERROR, "RASTER_mapAlgebra2: Unable to get pixel of %s raster", (i < 1 ? "FIRST" : "SECOND"));
 
@@ -14367,14 +14368,14 @@ Datum RASTER_mapAlgebraFctNgb(PG_FUNCTION_ARGS)
             nNodataOnly = true;
             pixelreplace = false;
             if (valuereplace) {
-                ret = rt_band_get_pixel(band, x, y, &rpix);
+                ret = rt_band_get_pixel(band, x, y, &rpix, NULL);
                 if (ret != -1 && 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);
+                    ret = rt_band_get_pixel(band, u, v, &r, NULL);
                     if (ret != -1) {
                         if (FLT_NEQ(r, newnodatavalue)) {
                             /* If the pixel value for this neighbor cell is not NODATA */
index 56538dead2b981f7c80e1b4bdfc4afc2342d779a..42f274298da309f03046bc33973847f6f5fd19f9 100644 (file)
@@ -399,13 +399,13 @@ static void testBand1BB(rt_band band)
             {
                 failure = rt_band_set_pixel(band, x, y, 1);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 1);
 
                 failure = rt_band_set_pixel(band, x, y, 0);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 0);
 
@@ -461,19 +461,19 @@ static void testBand2BUI(rt_band band)
             {
                 failure = rt_band_set_pixel(band, x, y, 1);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 1);
 
                 failure = rt_band_set_pixel(band, x, y, 2);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 2);
 
                 failure = rt_band_set_pixel(band, x, y, 3);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 3);
             }
@@ -536,25 +536,25 @@ static void testBand4BUI(rt_band band)
             {
                 failure = rt_band_set_pixel(band, x, y, 1);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 1);
 
                 failure = rt_band_set_pixel(band, x, y, 3);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 3);
 
                 failure = rt_band_set_pixel(band, x, y, 7);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 7);
 
                 failure = rt_band_set_pixel(band, x, y, 15);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 15);
             }
@@ -622,19 +622,19 @@ static void testBand8BUI(rt_band band)
             {
                 failure = rt_band_set_pixel(band, x, y, 31);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 31);
 
                 failure = rt_band_set_pixel(band, x, y, 255);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 255);
 
                 failure = rt_band_set_pixel(band, x, y, 1);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 1);
             }
@@ -716,25 +716,25 @@ static void testBand8BSI(rt_band band)
             {
                 failure = rt_band_set_pixel(band, x, y, 31);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 31);
 
                 failure = rt_band_set_pixel(band, x, y, 1);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 1);
 
                 failure = rt_band_set_pixel(band, x, y, -127);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, -127);
 
                 failure = rt_band_set_pixel(band, x, y, 127);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 127);
 
@@ -793,13 +793,13 @@ static void testBand16BUI(rt_band band)
             {
                 failure = rt_band_set_pixel(band, x, y, 255);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 255);
 
                 failure = rt_band_set_pixel(band, x, y, 65535);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 65535);
             }
@@ -872,19 +872,19 @@ static void testBand16BSI(rt_band band)
             {
                 failure = rt_band_set_pixel(band, x, y, 255);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 255);
 
                 failure = rt_band_set_pixel(band, x, y, -32767);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, -32767);
 
                 failure = rt_band_set_pixel(band, x, y, 32767);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 32767);
             }
@@ -938,25 +938,25 @@ static void testBand32BUI(rt_band band)
             {
                 failure = rt_band_set_pixel(band, x, y, 1);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 1);
 
                 failure = rt_band_set_pixel(band, x, y, 0);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 0);
 
                 failure = rt_band_set_pixel(band, x, y, 65535);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 65535);
 
                 failure = rt_band_set_pixel(band, x, y, 4294967295UL);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 4294967295UL);
             }
@@ -1011,25 +1011,25 @@ static void testBand32BSI(rt_band band)
             {
                 failure = rt_band_set_pixel(band, x, y, 1);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 1);
 
                 failure = rt_band_set_pixel(band, x, y, 0);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 0);
 
                 failure = rt_band_set_pixel(band, x, y, 65535);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 65535);
 
                 failure = rt_band_set_pixel(band, x, y, 2147483647);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 2147483647);
             }
@@ -1071,25 +1071,25 @@ static void testBand32BF(rt_band band)
             {
                 failure = rt_band_set_pixel(band, x, y, 1);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 1);
 
                 failure = rt_band_set_pixel(band, x, y, 0);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 0);
 
                 failure = rt_band_set_pixel(band, x, y, 65535.5);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS_DOUBLE(val, 65535.5);
 
                 failure = rt_band_set_pixel(band, x, y, 0.006);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS_DOUBLE(val, 0.0060000000521540);
 
@@ -1131,25 +1131,25 @@ static void testBand64BF(rt_band band)
             {
                 failure = rt_band_set_pixel(band, x, y, 1);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 1);
 
                 failure = rt_band_set_pixel(band, x, y, 0);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 0);
 
                 failure = rt_band_set_pixel(band, x, y, 65535.56);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 65535.56);
 
                 failure = rt_band_set_pixel(band, x, y, 0.006);
                 CHECK(!failure);
-                failure = rt_band_get_pixel(band, x, y, &val);
+                failure = rt_band_get_pixel(band, x, y, &val, NULL);
                 CHECK(!failure);
                 CHECK_EQUALS(val, 0.006);
 
@@ -1502,15 +1502,15 @@ static void testBandReclass() {
        newband = rt_band_reclass(band, PT_8BUI, 0, 0, exprset, cnt);
        CHECK(newband);
 
-       rtn = rt_band_get_pixel(newband, 0, 0, &val);
+       rtn = rt_band_get_pixel(newband, 0, 0, &val, NULL);
        CHECK((rtn != -1));
        CHECK_EQUALS(val, 0);
 
-       rtn = rt_band_get_pixel(newband, 49, 5, &val);
+       rtn = rt_band_get_pixel(newband, 49, 5, &val, NULL);
        CHECK((rtn != -1));
        CHECK_EQUALS(val, 77);
 
-       rtn = rt_band_get_pixel(newband, 99, 9, &val);
+       rtn = rt_band_get_pixel(newband, 99, 9, &val, NULL);
        CHECK((rtn != -1));
        CHECK_EQUALS(val, 255);
 
@@ -1716,7 +1716,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);
+                       rtn = rt_band_get_pixel(band, x, y, &value, NULL);
                        CHECK((rtn != -1));
                        CHECK(FLT_EQ(value, values[x][y]));
                }
@@ -1760,7 +1760,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);
+                       rtn = rt_band_get_pixel(band, x, y, &value, NULL);
                        CHECK((rtn != -1));
                        CHECK(FLT_EQ(value, values[x][y]));
                }
@@ -1824,7 +1824,7 @@ static void testGDALWarp() {
        CHECK(rt_band_get_hasnodata_flag(band));
        CHECK(FLT_EQ(rt_band_get_nodata(band), 0.));
 
-       CHECK(rt_band_get_pixel(band, 0, 0, &value) == 0);
+       CHECK(rt_band_get_pixel(band, 0, 0, &value, NULL) == 0);
        CHECK(FLT_EQ(value, 0.));
 
        deepRelease(rast);
@@ -6763,7 +6763,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);
+                       rtn = rt_band_get_pixel(band, x, y, &val, NULL);
                        CHECK((rtn == 0));
                        CHECK(FLT_EQ(val, 255));
                }
index e1e7ae068dc629773cfe123d380d5489e72dc98b..16d100f069b18e09335f88f66e89738e0f2c087e 100644 (file)
@@ -188,7 +188,7 @@ main()
         CHECK(!rt_band_is_offline(band));
         CHECK(rt_band_get_hasnodata_flag(band));
         CHECK_EQUALS(rt_band_get_nodata(band), 0);
-        failure = rt_band_get_pixel(band, 0, 0, &val);
+        failure = rt_band_get_pixel(band, 0, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 1);
     }
@@ -254,27 +254,27 @@ main()
         CHECK(rt_band_get_hasnodata_flag(band));
         CHECK_EQUALS(rt_band_get_nodata(band), -1);
 
-        failure = rt_band_get_pixel(band, 0, 0, &val);
+        failure = rt_band_get_pixel(band, 0, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, -1);
 
-        failure = rt_band_get_pixel(band, 1, 0, &val);
+        failure = rt_band_get_pixel(band, 1, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 0);
 
-        failure = rt_band_get_pixel(band, 2, 0, &val);
+        failure = rt_band_get_pixel(band, 2, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 1);
 
-        failure = rt_band_get_pixel(band, 0, 1, &val);
+        failure = rt_band_get_pixel(band, 0, 1, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 127);
 
-        failure = rt_band_get_pixel(band, 1, 1, &val);
+        failure = rt_band_get_pixel(band, 1, 1, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 10);
 
-        failure = rt_band_get_pixel(band, 2, 1, &val);
+        failure = rt_band_get_pixel(band, 2, 1, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 2);
     }
@@ -352,27 +352,27 @@ main()
         CHECK(!rt_band_get_hasnodata_flag(band));
         CHECK_EQUALS(rt_band_get_nodata(band), -1);
 
-        failure = rt_band_get_pixel(band, 0, 0, &val);
+        failure = rt_band_get_pixel(band, 0, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, -1);
 
-        failure = rt_band_get_pixel(band, 1, 0, &val);
+        failure = rt_band_get_pixel(band, 1, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 0);
 
-        failure = rt_band_get_pixel(band, 2, 0, &val);
+        failure = rt_band_get_pixel(band, 2, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, -16);
 
-        failure = rt_band_get_pixel(band, 0, 1, &val);
+        failure = rt_band_get_pixel(band, 0, 1, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 127);
 
-        failure = rt_band_get_pixel(band, 1, 1, &val);
+        failure = rt_band_get_pixel(band, 1, 1, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 10);
 
-        failure = rt_band_get_pixel(band, 2, 1, &val);
+        failure = rt_band_get_pixel(band, 2, 1, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 2);
     }
@@ -437,27 +437,27 @@ main()
         CHECK(!rt_band_get_hasnodata_flag(band));
         CHECK_EQUALS(rt_band_get_nodata(band), -1);
 
-        failure = rt_band_get_pixel(band, 0, 0, &val);
+        failure = rt_band_get_pixel(band, 0, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, -1);
 
-        failure = rt_band_get_pixel(band, 1, 0, &val);
+        failure = rt_band_get_pixel(band, 1, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 0);
 
-        failure = rt_band_get_pixel(band, 2, 0, &val);
+        failure = rt_band_get_pixel(band, 2, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, -16);
 
-        failure = rt_band_get_pixel(band, 0, 1, &val);
+        failure = rt_band_get_pixel(band, 0, 1, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 127);
 
-        failure = rt_band_get_pixel(band, 1, 1, &val);
+        failure = rt_band_get_pixel(band, 1, 1, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 10);
 
-        failure = rt_band_get_pixel(band, 2, 1, &val);
+        failure = rt_band_get_pixel(band, 2, 1, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 2);
     }
@@ -579,15 +579,15 @@ main()
         CHECK(rt_band_get_hasnodata_flag(band));
         CHECK_EQUALS(rt_band_get_nodata(band), 1);
 
-        failure = rt_band_get_pixel(band, 0, 0, &val);
+        failure = rt_band_get_pixel(band, 0, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 1);
 
-        failure = rt_band_get_pixel(band, 1, 0, &val);
+        failure = rt_band_get_pixel(band, 1, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 436);
 
-        failure = rt_band_get_pixel(band, 2, 0, &val);
+        failure = rt_band_get_pixel(band, 2, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 431);
     }
@@ -674,23 +674,23 @@ main()
         CHECK(rt_band_get_hasnodata_flag(band));
         CHECK_EQUALS(rt_band_get_nodata(band), 0);
 
-        failure = rt_band_get_pixel(band, 0, 0, &val);
+        failure = rt_band_get_pixel(band, 0, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 253);
 
-        failure = rt_band_get_pixel(band, 1, 0, &val);
+        failure = rt_band_get_pixel(band, 1, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 254);
 
-        failure = rt_band_get_pixel(band, 2, 0, &val);
+        failure = rt_band_get_pixel(band, 2, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 253);
 
-        failure = rt_band_get_pixel(band, 3, 0, &val);
+        failure = rt_band_get_pixel(band, 3, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 254);
 
-        failure = rt_band_get_pixel(band, 4, 0, &val);
+        failure = rt_band_get_pixel(band, 4, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 254);
     }
@@ -706,23 +706,23 @@ main()
         CHECK(rt_band_get_hasnodata_flag(band));
         CHECK_EQUALS(rt_band_get_nodata(band), 0);
 
-        failure = rt_band_get_pixel(band, 0, 0, &val);
+        failure = rt_band_get_pixel(band, 0, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 78);
 
-        failure = rt_band_get_pixel(band, 1, 0, &val);
+        failure = rt_band_get_pixel(band, 1, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 98);
 
-        failure = rt_band_get_pixel(band, 2, 0, &val);
+        failure = rt_band_get_pixel(band, 2, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 122);
 
-        failure = rt_band_get_pixel(band, 3, 0, &val);
+        failure = rt_band_get_pixel(band, 3, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 173);
 
-        failure = rt_band_get_pixel(band, 4, 0, &val);
+        failure = rt_band_get_pixel(band, 4, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 209);
     }
@@ -738,23 +738,23 @@ main()
         CHECK(rt_band_get_hasnodata_flag(band));
         CHECK_EQUALS(rt_band_get_nodata(band), 0);
 
-        failure = rt_band_get_pixel(band, 0, 0, &val);
+        failure = rt_band_get_pixel(band, 0, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 70);
 
-        failure = rt_band_get_pixel(band, 1, 0, &val);
+        failure = rt_band_get_pixel(band, 1, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 86);
 
-        failure = rt_band_get_pixel(band, 2, 0, &val);
+        failure = rt_band_get_pixel(band, 2, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 100);
 
-        failure = rt_band_get_pixel(band, 3, 0, &val);
+        failure = rt_band_get_pixel(band, 3, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 135);
 
-        failure = rt_band_get_pixel(band, 4, 0, &val);
+        failure = rt_band_get_pixel(band, 4, 0, &val, NULL);
         CHECK(!failure);
         CHECK_EQUALS(val, 161);
     }