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

Definition at line 1828 of file rtpg_mapalgebra.c.

References rt_iterator_arg_t::columns, FLT_NEQ, rt_iterator_arg_t::nodata, POSTGIS_RT_DEBUGF, rt_iterator_arg_t::rasters, rt_iterator_arg_t::rows, and rt_iterator_arg_t::values.

Referenced by RASTER_union_finalfn().

1831  {
1832  if (arg == NULL)
1833  return 0;
1834 
1835  if (
1836  arg->rasters != 2 ||
1837  arg->rows != 1 ||
1838  arg->columns != 1
1839  ) {
1840  elog(ERROR, "rtpg_union_mean_callback: Invalid arguments passed to callback");
1841  return 0;
1842  }
1843 
1844  *value = 0;
1845  *nodata = 1;
1846 
1847  POSTGIS_RT_DEBUGF(4, "rast0: %f %d", arg->values[0][0][0], arg->nodata[0][0][0]);
1848  POSTGIS_RT_DEBUGF(4, "rast1: %f %d", arg->values[1][0][0], arg->nodata[1][0][0]);
1849 
1850  if (
1851  !arg->nodata[0][0][0] &&
1852  FLT_NEQ(arg->values[0][0][0], 0) &&
1853  !arg->nodata[1][0][0]
1854  ) {
1855  *value = arg->values[1][0][0] / arg->values[0][0][0];
1856  *nodata = 0;
1857  }
1858 
1859  POSTGIS_RT_DEBUGF(4, "value, nodata = (%f, %d)", *value, *nodata);
1860 
1861  return 1;
1862 }
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rtpostgis.h:57
uint32_t columns
Definition: librtcore.h:2418
uint16_t rasters
Definition: librtcore.h:2414
#define FLT_NEQ(x, y)
Definition: librtcore.h:2196
double *** values
Definition: librtcore.h:2422

Here is the caller graph for this function: