PostGIS  2.1.10dev-r@@SVN_REVISION@@
int rt_band_check_is_nodata ( rt_band  band)

Returns TRUE if the band is only nodata values.

Parameters
band: the band to get info from
Returns
TRUE if the band is only nodata values, FALSE otherwise

Definition at line 3080 of file rt_api.c.

References rt_context_t::err, ES_NONE, FALSE, rt_band_t::hasnodata, rt_band_t::height, rt_band_t::isnodata, rt_band_t::nodataval, RASTER_DEBUG, rt_band_get_pixel(), rterror(), TRUE, and rt_band_t::width.

Referenced by convert_raster(), RASTER_bandIsNoData(), RASTER_setBandNoDataValue(), test_band_metadata(), and test_raster_to_gdal().

3080  {
3081  int i, j, err;
3082  double pxValue;
3083  int isnodata = 0;
3084 
3085  assert(NULL != band);
3086 
3087  /* Check if band has nodata value */
3088  if (!band->hasnodata) {
3089  RASTER_DEBUG(3, "Band has no NODATA value");
3090  band->isnodata = FALSE;
3091  return FALSE;
3092  }
3093 
3094  pxValue = band->nodataval;
3095 
3096  /* Check all pixels */
3097  for (i = 0; i < band->width; i++) {
3098  for (j = 0; j < band->height; j++) {
3099  err = rt_band_get_pixel(band, i, j, &pxValue, &isnodata);
3100  if (err != ES_NONE) {
3101  rterror("rt_band_check_is_nodata: Cannot get band pixel");
3102  return FALSE;
3103  }
3104  else if (!isnodata) {
3105  band->isnodata = FALSE;
3106  return FALSE;
3107  }
3108  }
3109  }
3110 
3111  band->isnodata = TRUE;
3112  return TRUE;
3113 }
uint16_t height
Definition: rt_api.h:2242
#define RASTER_DEBUG(level, msg)
Definition: rt_api.h:281
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
Definition: rt_api.c:2549
double nodataval
Definition: rt_api.h:2246
uint16_t width
Definition: rt_api.h:2241
void rterror(const char *fmt,...)
Raster core error and info handlers.
Definition: rt_api.c:895
int32_t isnodata
Definition: rt_api.h:2244
#define FALSE
Definition: dbfopen.c:169
int32_t hasnodata
Definition: rt_api.h:2243
#define TRUE
Definition: dbfopen.c:170

Here is the call graph for this function:

Here is the caller graph for this function: