PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ rtpg_union_mean_callback()

static int rtpg_union_mean_callback ( rt_iterator_arg  arg,
void *  userarg,
double *  value,
int *  nodata 
)
static

Definition at line 1825 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().

1828  {
1829  if (arg == NULL)
1830  return 0;
1831 
1832  if (
1833  arg->rasters != 2 ||
1834  arg->rows != 1 ||
1835  arg->columns != 1
1836  ) {
1837  elog(ERROR, "rtpg_union_mean_callback: Invalid arguments passed to callback");
1838  return 0;
1839  }
1840 
1841  *value = 0;
1842  *nodata = 1;
1843 
1844  POSTGIS_RT_DEBUGF(4, "rast0: %f %d", arg->values[0][0][0], arg->nodata[0][0][0]);
1845  POSTGIS_RT_DEBUGF(4, "rast1: %f %d", arg->values[1][0][0], arg->nodata[1][0][0]);
1846 
1847  if (
1848  !arg->nodata[0][0][0] &&
1849  FLT_NEQ(arg->values[0][0][0], 0) &&
1850  !arg->nodata[1][0][0]
1851  ) {
1852  *value = arg->values[1][0][0] / arg->values[0][0][0];
1853  *nodata = 0;
1854  }
1855 
1856  POSTGIS_RT_DEBUGF(4, "value, nodata = (%f, %d)", *value, *nodata);
1857 
1858  return 1;
1859 }
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rtpostgis.h:65
uint32_t columns
Definition: librtcore.h:2435
uint16_t rasters
Definition: librtcore.h:2431
#define FLT_NEQ(x, y)
Definition: librtcore.h:2213
double *** values
Definition: librtcore.h:2439
int value
Definition: genraster.py:61
Here is the caller graph for this function: