PostGIS  2.4.9dev-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 1878 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().

1881  {
1882  if (arg == NULL)
1883  return 0;
1884 
1885  if (
1886  arg->rasters != 2 ||
1887  arg->rows != 1 ||
1888  arg->columns != 1
1889  ) {
1890  elog(ERROR, "rtpg_union_mean_callback: Invalid arguments passed to callback");
1891  return 0;
1892  }
1893 
1894  *value = 0;
1895  *nodata = 1;
1896 
1897  POSTGIS_RT_DEBUGF(4, "rast0: %f %d", arg->values[0][0][0], arg->nodata[0][0][0]);
1898  POSTGIS_RT_DEBUGF(4, "rast1: %f %d", arg->values[1][0][0], arg->nodata[1][0][0]);
1899 
1900  if (
1901  !arg->nodata[0][0][0] &&
1902  FLT_NEQ(arg->values[0][0][0], 0) &&
1903  !arg->nodata[1][0][0]
1904  ) {
1905  *value = arg->values[1][0][0] / arg->values[0][0][0];
1906  *nodata = 0;
1907  }
1908 
1909  POSTGIS_RT_DEBUGF(4, "value, nodata = (%f, %d)", *value, *nodata);
1910 
1911  return 1;
1912 }
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rtpostgis.h:65
uint32_t columns
Definition: librtcore.h:2406
uint16_t rasters
Definition: librtcore.h:2402
#define FLT_NEQ(x, y)
Definition: librtcore.h:2184
double *** values
Definition: librtcore.h:2410
int value
Definition: genraster.py:61
Here is the caller graph for this function: