PostGIS  2.1.10dev-r@@SVN_REVISION@@
static int _rti_iterator_arg_populate ( _rti_iterator_arg  _param,
rt_iterator  itrset,
uint16_t  itrcount,
uint16_t  distancex,
uint16_t  distancey,
int *  allnull,
int *  allempty 
)
static

Definition at line 13647 of file rt_api.c.

References _rti_iterator_arg_t::band, _rti_iterator_arg_t::columns, _rti_iterator_arg_t::count, _rti_iterator_arg_t::dimension, _rti_iterator_arg_t::distance, _rti_iterator_arg_t::hasnodata, _rti_iterator_arg_t::height, _rti_iterator_arg_t::isempty, _rti_iterator_arg_t::isnodata, _rti_iterator_arg_t::minval, pixval::nband, _rti_iterator_arg_t::nodataval, _rti_iterator_arg_t::offset, rtrowdump::raster, rt_iterator_t::raster, _rti_iterator_arg_t::raster, RASTER_DEBUGF, _rti_iterator_arg_t::rows, rt_band_get_hasnodata_flag(), rt_band_get_isnodata_flag(), rt_band_get_min_value(), rt_band_get_nodata(), rt_raster_get_band(), rt_raster_get_height(), rt_raster_get_width(), rt_raster_has_band(), rt_raster_is_empty(), rtalloc(), _rti_iterator_arg_t::rtband, rterror(), _rti_iterator_arg_t::width, _rti_iterator_arg_t::x, and _rti_iterator_arg_t::y.

Referenced by rt_raster_iterator().

13652  {
13653  int i = 0;
13654  int hasband = 0;
13655 
13656  _param->count = itrcount;
13657  _param->distance.x = distancex;
13658  _param->distance.y = distancey;
13659  _param->dimension.columns = distancex * 2 + 1;
13660  _param->dimension.rows = distancey * 2 + 1;
13661 
13662  /* allocate memory for children */
13663  _param->raster = rtalloc(sizeof(rt_raster) * itrcount);
13664  _param->isempty = rtalloc(sizeof(int) * itrcount);
13665  _param->width = rtalloc(sizeof(int) * itrcount);
13666  _param->height = rtalloc(sizeof(int) * itrcount);
13667 
13668  _param->offset = rtalloc(sizeof(double *) * itrcount);
13669 
13670  _param->band.rtband = rtalloc(sizeof(rt_band) * itrcount);
13671  _param->band.hasnodata = rtalloc(sizeof(int) * itrcount);
13672  _param->band.isnodata = rtalloc(sizeof(int) * itrcount);
13673  _param->band.nodataval = rtalloc(sizeof(double) * itrcount);
13674  _param->band.minval = rtalloc(sizeof(double) * itrcount);
13675 
13676  if (
13677  _param->raster == NULL ||
13678  _param->isempty == NULL ||
13679  _param->width == NULL ||
13680  _param->height == NULL ||
13681  _param->offset == NULL ||
13682  _param->band.rtband == NULL ||
13683  _param->band.hasnodata == NULL ||
13684  _param->band.isnodata == NULL ||
13685  _param->band.nodataval == NULL ||
13686  _param->band.minval == NULL
13687  ) {
13688  rterror("_rti_iterator_arg_populate: Could not allocate memory for children of _rti_iterator_arg");
13689  return 0;
13690  }
13691 
13692  *allnull = 0;
13693  *allempty = 0;
13694 
13695  /*
13696  check input rasters
13697  not empty, band # is valid
13698  copy raster pointers and set flags
13699  */
13700  for (i = 0; i < itrcount; i++) {
13701  /* initialize elements */
13702  _param->raster[i] = NULL;
13703  _param->isempty[i] = 0;
13704  _param->width[i] = 0;
13705  _param->height[i] = 0;
13706 
13707  _param->offset[i] = NULL;
13708 
13709  _param->band.rtband[i] = NULL;
13710  _param->band.hasnodata[i] = 0;
13711  _param->band.isnodata[i] = 0;
13712  _param->band.nodataval[i] = 0;
13713  _param->band.minval[i] = 0;
13714 
13715  /* set isempty */
13716  if (itrset[i].raster == NULL) {
13717  _param->isempty[i] = 1;
13718 
13719  (*allnull)++;
13720  (*allempty)++;
13721 
13722  continue;
13723  }
13724  else if (rt_raster_is_empty(itrset[i].raster)) {
13725  _param->isempty[i] = 1;
13726 
13727  (*allempty)++;
13728 
13729  continue;
13730  }
13731 
13732  /* check band number */
13733  hasband = rt_raster_has_band(itrset[i].raster, itrset[i].nband);
13734  if (!hasband) {
13735  if (!itrset[i].nbnodata) {
13736  rterror("_rti_iterator_arg_populate: Band %d not found for raster %d", itrset[i].nband, i);
13737  return 0;
13738  }
13739  else {
13740  RASTER_DEBUGF(4, "Band %d not found for raster %d. Using NODATA", itrset[i].nband, i);
13741  }
13742  }
13743 
13744  _param->raster[i] = itrset[i].raster;
13745  if (hasband) {
13746  _param->band.rtband[i] = rt_raster_get_band(itrset[i].raster, itrset[i].nband);
13747  if (_param->band.rtband[i] == NULL) {
13748  rterror("_rti_iterator_arg_populate: Could not get band %d for raster %d", itrset[i].nband, i);
13749  return 0;
13750  }
13751 
13752  /* hasnodata */
13753  _param->band.hasnodata[i] = rt_band_get_hasnodata_flag(_param->band.rtband[i]);
13754 
13755  /* hasnodata = TRUE */
13756  if (_param->band.hasnodata[i]) {
13757  /* nodataval */
13758  rt_band_get_nodata(_param->band.rtband[i], &(_param->band.nodataval[i]));
13759 
13760  /* isnodata */
13761  _param->band.isnodata[i] = rt_band_get_isnodata_flag(_param->band.rtband[i]);
13762  }
13763  /* hasnodata = FALSE */
13764  else {
13765  /* minval */
13766  _param->band.minval[i] = rt_band_get_min_value(_param->band.rtband[i]);
13767  }
13768  }
13769 
13770  /* width, height */
13771  _param->width[i] = rt_raster_get_width(_param->raster[i]);
13772  _param->height[i] = rt_raster_get_height(_param->raster[i]);
13773 
13774  /* init offset */
13775  _param->offset[i] = rtalloc(sizeof(double) * 2);
13776  if (_param->offset[i] == NULL) {
13777  rterror("_rti_iterator_arg_populate: Could not allocate memory for offsets");
13778  return 0;
13779  }
13780  }
13781 
13782  return 1;
13783 }
rt_band * rtband
Definition: rt_api.c:13512
rt_raster * raster
Definition: rt_api.c:13505
int rt_raster_has_band(rt_raster raster, int nband)
Return TRUE if the raster has a band of this number.
Definition: rt_api.c:8563
tuple raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:123
int rt_band_get_isnodata_flag(rt_band band)
Get isnodata flag value.
Definition: rt_api.c:2042
#define RASTER_DEBUGF(level, msg,...)
Definition: rt_api.h:285
tuple nband
Definition: pixval.py:52
double rt_band_get_min_value(rt_band band)
Returns the minimal possible value for the band according to the pixel type.
Definition: rt_api.c:3073
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
Definition: rt_api.c:3058
double * nodataval
Definition: rt_api.c:13515
struct _rti_iterator_arg_t::@10 band
rt_raster raster
Definition: rt_api.h:2360
double ** offset
Definition: rt_api.c:13507
uint16_t rt_raster_get_height(rt_raster raster)
Definition: rt_api.c:5434
uint32_t columns
Definition: rt_api.c:13526
void * rtalloc(size_t size)
Raster core memory management functions.
Definition: rt_api.c:867
void rterror(const char *fmt,...)
Raster core error and info handlers.
Definition: rt_api.c:895
rt_band rt_raster_get_band(rt_raster raster, int n)
Return Nth band, or NULL if unavailable.
Definition: rt_api.c:5686
struct _rti_iterator_arg_t::@11 distance
int rt_raster_is_empty(rt_raster raster)
Return TRUE if the raster is empty.
Definition: rt_api.c:8550
struct _rti_iterator_arg_t::@12 dimension
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
Definition: rt_api.c:2002
uint16_t rt_raster_get_width(rt_raster raster)
Definition: rt_api.c:5426

Here is the call graph for this function:

Here is the caller graph for this function: