PostGIS  2.1.10dev-r@@SVN_REVISION@@
static int rtpg_union_callback ( rt_iterator_arg  arg,
void *  userarg,
double *  value,
int *  nodata 
)
static

Definition at line 17795 of file rt_pg.c.

References rt_iterator_arg_t::columns, rt_iterator_arg_t::nodata, POSTGIS_RT_DEBUGF, rt_iterator_arg_t::rasters, rt_iterator_arg_t::rows, UT_COUNT, UT_FIRST, UT_LAST, UT_MAX, UT_MEAN, UT_MIN, UT_RANGE, UT_SUM, and rt_iterator_arg_t::values.

Referenced by RASTER_union_transfn().

17798  {
17799  rtpg_union_type *utype = (rtpg_union_type *) userarg;
17800 
17801  if (arg == NULL)
17802  return 0;
17803 
17804  if (
17805  arg->rasters != 2 ||
17806  arg->rows != 1 ||
17807  arg->columns != 1
17808  ) {
17809  elog(ERROR, "rtpg_union_callback: Invalid arguments passed to callback");
17810  return 0;
17811  }
17812 
17813  *value = 0;
17814  *nodata = 0;
17815 
17816  /* handle NODATA situations except for COUNT, which is a special case */
17817  if (*utype != UT_COUNT) {
17818  /* both NODATA */
17819  if (arg->nodata[0][0][0] && arg->nodata[1][0][0]) {
17820  *nodata = 1;
17821  POSTGIS_RT_DEBUGF(4, "value, nodata = %f, %d", *value, *nodata);
17822  return 1;
17823  }
17824  /* second NODATA */
17825  else if (!arg->nodata[0][0][0] && arg->nodata[1][0][0]) {
17826  *value = arg->values[0][0][0];
17827  POSTGIS_RT_DEBUGF(4, "value, nodata = %f, %d", *value, *nodata);
17828  return 1;
17829  }
17830  /* first NODATA */
17831  else if (arg->nodata[0][0][0] && !arg->nodata[1][0][0]) {
17832  *value = arg->values[1][0][0];
17833  POSTGIS_RT_DEBUGF(4, "value, nodata = %f, %d", *value, *nodata);
17834  return 1;
17835  }
17836  }
17837 
17838  switch (*utype) {
17839  case UT_FIRST:
17840  *value = arg->values[0][0][0];
17841  break;
17842  case UT_MIN:
17843  if (arg->values[0][0][0] < arg->values[1][0][0])
17844  *value = arg->values[0][0][0];
17845  else
17846  *value = arg->values[1][0][0];
17847  break;
17848  case UT_MAX:
17849  if (arg->values[0][0][0] > arg->values[1][0][0])
17850  *value = arg->values[0][0][0];
17851  else
17852  *value = arg->values[1][0][0];
17853  break;
17854  case UT_COUNT:
17855  /* both NODATA */
17856  if (arg->nodata[0][0][0] && arg->nodata[1][0][0])
17857  *value = 0;
17858  /* second NODATA */
17859  else if (!arg->nodata[0][0][0] && arg->nodata[1][0][0])
17860  *value = arg->values[0][0][0];
17861  /* first NODATA */
17862  else if (arg->nodata[0][0][0] && !arg->nodata[1][0][0])
17863  *value = 1;
17864  /* has value, increment */
17865  else
17866  *value = arg->values[0][0][0] + 1;
17867  break;
17868  case UT_SUM:
17869  *value = arg->values[0][0][0] + arg->values[1][0][0];
17870  break;
17871  case UT_MEAN:
17872  case UT_RANGE:
17873  break;
17874  case UT_LAST:
17875  default:
17876  *value = arg->values[1][0][0];
17877  break;
17878  }
17879 
17880  POSTGIS_RT_DEBUGF(4, "value, nodata = %f, %d", *value, *nodata);
17881 
17882 
17883  return 1;
17884 }
rtpg_union_type
Definition: rt_pg.c:17717
uint32_t rows
Definition: rt_api.h:2370
uint32_t columns
Definition: rt_api.h:2372
uint16_t rasters
Definition: rt_api.h:2368
double *** values
Definition: rt_api.h:2376
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rt_pg.h:62
int *** nodata
Definition: rt_api.h:2378

Here is the caller graph for this function: