PostGIS  2.5.0dev-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 1619 of file rt_band.c.

References 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().

1619  {
1620  int i, j, err;
1621  double pxValue;
1622  int isnodata = 0;
1623 
1624  assert(NULL != band);
1625 
1626  /* Check if band has nodata value */
1627  if (!band->hasnodata) {
1628  RASTER_DEBUG(3, "Band has no NODATA value");
1629  band->isnodata = FALSE;
1630  return FALSE;
1631  }
1632 
1633  pxValue = band->nodataval;
1634 
1635  /* Check all pixels */
1636  for (i = 0; i < band->width; i++) {
1637  for (j = 0; j < band->height; j++) {
1638  err = rt_band_get_pixel(band, i, j, &pxValue, &isnodata);
1639  if (err != ES_NONE) {
1640  rterror("rt_band_check_is_nodata: Cannot get band pixel");
1641  return FALSE;
1642  }
1643  else if (!isnodata) {
1644  band->isnodata = FALSE;
1645  return FALSE;
1646  }
1647  }
1648  }
1649 
1650  band->isnodata = TRUE;
1651  return TRUE;
1652 }
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
uint16_t height
Definition: librtcore.h:2268
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
Definition: rt_band.c:1088
double nodataval
Definition: librtcore.h:2272
uint16_t width
Definition: librtcore.h:2267
int32_t isnodata
Definition: librtcore.h:2270
#define FALSE
Definition: dbfopen.c:168
#define RASTER_DEBUG(level, msg)
Definition: librtcore.h:295
int32_t hasnodata
Definition: librtcore.h:2269
#define TRUE
Definition: dbfopen.c:169

Here is the call graph for this function:

Here is the caller graph for this function: