PostGIS  2.5.0beta1dev-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 1752 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().

1752  {
1753  int i, j, err;
1754  double pxValue;
1755  int isnodata = 0;
1756 
1757  assert(NULL != band);
1758 
1759  /* Check if band has nodata value */
1760  if (!band->hasnodata) {
1761  RASTER_DEBUG(3, "Band has no NODATA value");
1762  band->isnodata = FALSE;
1763  return FALSE;
1764  }
1765 
1766  pxValue = band->nodataval;
1767 
1768  /* Check all pixels */
1769  for (i = 0; i < band->width; i++) {
1770  for (j = 0; j < band->height; j++) {
1771  err = rt_band_get_pixel(band, i, j, &pxValue, &isnodata);
1772  if (err != ES_NONE) {
1773  rterror("rt_band_check_is_nodata: Cannot get band pixel");
1774  return FALSE;
1775  }
1776  else if (!isnodata) {
1777  band->isnodata = FALSE;
1778  return FALSE;
1779  }
1780  }
1781  }
1782 
1783  band->isnodata = TRUE;
1784  return TRUE;
1785 }
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
uint16_t height
Definition: librtcore.h:2317
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
Definition: rt_band.c:1221
double nodataval
Definition: librtcore.h:2321
uint16_t width
Definition: librtcore.h:2316
int32_t isnodata
Definition: librtcore.h:2319
#define FALSE
Definition: dbfopen.c:168
#define RASTER_DEBUG(level, msg)
Definition: librtcore.h:295
int32_t hasnodata
Definition: librtcore.h:2318
#define TRUE
Definition: dbfopen.c:169
Here is the call graph for this function:
Here is the caller graph for this function: