PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ rt_band_check_is_nodata()

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 1704 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(), test_band_new_offline_from_path(), and test_raster_to_gdal().

1704  {
1705  int i, j, err;
1706  double pxValue;
1707  int isnodata = 0;
1708 
1709  assert(NULL != band);
1710 
1711  /* Check if band has nodata value */
1712  if (!band->hasnodata) {
1713  RASTER_DEBUG(3, "Band has no NODATA value");
1714  band->isnodata = FALSE;
1715  return FALSE;
1716  }
1717 
1718  pxValue = band->nodataval;
1719 
1720  /* Check all pixels */
1721  for (i = 0; i < band->width; i++) {
1722  for (j = 0; j < band->height; j++) {
1723  err = rt_band_get_pixel(band, i, j, &pxValue, &isnodata);
1724  if (err != ES_NONE) {
1725  rterror("rt_band_check_is_nodata: Cannot get band pixel");
1726  return FALSE;
1727  }
1728  else if (!isnodata) {
1729  band->isnodata = FALSE;
1730  return FALSE;
1731  }
1732  }
1733  }
1734 
1735  band->isnodata = TRUE;
1736  return TRUE;
1737 }
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
uint16_t height
Definition: librtcore.h:2297
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
Definition: rt_band.c:1173
double nodataval
Definition: librtcore.h:2301
uint16_t width
Definition: librtcore.h:2296
int32_t isnodata
Definition: librtcore.h:2299
#define FALSE
Definition: dbfopen.c:168
#define RASTER_DEBUG(level, msg)
Definition: librtcore.h:295
int32_t hasnodata
Definition: librtcore.h:2298
#define TRUE
Definition: dbfopen.c:169
Here is the call graph for this function:
Here is the caller graph for this function: