PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ rtpg_union_callback()

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

Definition at line 1799 of file rtpg_mapalgebra.c.

1802  {
1803  rtpg_union_type *utype = (rtpg_union_type *) userarg;
1804 
1805  if (arg == NULL)
1806  return 0;
1807 
1808  if (
1809  arg->rasters != 2 ||
1810  arg->rows != 1 ||
1811  arg->columns != 1
1812  ) {
1813  elog(ERROR, "rtpg_union_callback: Invalid arguments passed to callback");
1814  return 0;
1815  }
1816 
1817  *value = 0;
1818  *nodata = 0;
1819 
1820  /* handle NODATA situations except for COUNT, which is a special case */
1821  if (*utype != UT_COUNT) {
1822  /* both NODATA */
1823  if (arg->nodata[0][0][0] && arg->nodata[1][0][0]) {
1824  *nodata = 1;
1825  POSTGIS_RT_DEBUGF(4, "value, nodata = %f, %d", *value, *nodata);
1826  return 1;
1827  }
1828  /* second NODATA */
1829  else if (!arg->nodata[0][0][0] && arg->nodata[1][0][0]) {
1830  *value = arg->values[0][0][0];
1831  POSTGIS_RT_DEBUGF(4, "value, nodata = %f, %d", *value, *nodata);
1832  return 1;
1833  }
1834  /* first NODATA */
1835  else if (arg->nodata[0][0][0] && !arg->nodata[1][0][0]) {
1836  *value = arg->values[1][0][0];
1837  POSTGIS_RT_DEBUGF(4, "value, nodata = %f, %d", *value, *nodata);
1838  return 1;
1839  }
1840  }
1841 
1842  switch (*utype) {
1843  case UT_FIRST:
1844  *value = arg->values[0][0][0];
1845  break;
1846  case UT_MIN:
1847  if (arg->values[0][0][0] < arg->values[1][0][0])
1848  *value = arg->values[0][0][0];
1849  else
1850  *value = arg->values[1][0][0];
1851  break;
1852  case UT_MAX:
1853  if (arg->values[0][0][0] > arg->values[1][0][0])
1854  *value = arg->values[0][0][0];
1855  else
1856  *value = arg->values[1][0][0];
1857  break;
1858  case UT_COUNT:
1859  /* both NODATA */
1860  if (arg->nodata[0][0][0] && arg->nodata[1][0][0])
1861  *value = 0;
1862  /* second NODATA */
1863  else if (!arg->nodata[0][0][0] && arg->nodata[1][0][0])
1864  *value = arg->values[0][0][0];
1865  /* first NODATA */
1866  else if (arg->nodata[0][0][0] && !arg->nodata[1][0][0])
1867  *value = 1;
1868  /* has value, increment */
1869  else
1870  *value = arg->values[0][0][0] + 1;
1871  break;
1872  case UT_SUM:
1873  *value = arg->values[0][0][0] + arg->values[1][0][0];
1874  break;
1875  case UT_MEAN:
1876  case UT_RANGE:
1877  break;
1878  case UT_LAST:
1879  default:
1880  *value = arg->values[1][0][0];
1881  break;
1882  }
1883 
1884  POSTGIS_RT_DEBUGF(4, "value, nodata = %f, %d", *value, *nodata);
1885 
1886 
1887  return 1;
1888 }
int value
Definition: genraster.py:62
rtpg_union_type
@ UT_MIN
@ UT_MEAN
@ UT_COUNT
@ UT_LAST
@ UT_SUM
@ UT_FIRST
@ UT_MAX
@ UT_RANGE
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rtpostgis.h:73
double *** values
Definition: librtcore.h:2605
uint32_t columns
Definition: librtcore.h:2601
uint16_t rasters
Definition: librtcore.h:2597

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, genraster::value, and rt_iterator_arg_t::values.

Referenced by RASTER_union_transfn().

Here is the caller graph for this function: