PostGIS  2.5.7dev-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 1796 of file rtpg_mapalgebra.c.

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

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: