PostGIS  3.4.0dev-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 1753 of file rtpg_mapalgebra.c.

1756  {
1757  rtpg_union_type *utype = (rtpg_union_type *) userarg;
1758 
1759  if (arg == NULL)
1760  return 0;
1761 
1762  if (
1763  arg->rasters != 2 ||
1764  arg->rows != 1 ||
1765  arg->columns != 1
1766  ) {
1767  elog(ERROR, "rtpg_union_callback: Invalid arguments passed to callback");
1768  return 0;
1769  }
1770 
1771  *value = 0;
1772  *nodata = 0;
1773 
1774  /* handle NODATA situations except for COUNT, which is a special case */
1775  if (*utype != UT_COUNT) {
1776  /* both NODATA */
1777  if (arg->nodata[0][0][0] && arg->nodata[1][0][0]) {
1778  *nodata = 1;
1779  POSTGIS_RT_DEBUGF(4, "value, nodata = %f, %d", *value, *nodata);
1780  return 1;
1781  }
1782  /* second NODATA */
1783  else if (!arg->nodata[0][0][0] && arg->nodata[1][0][0]) {
1784  *value = arg->values[0][0][0];
1785  POSTGIS_RT_DEBUGF(4, "value, nodata = %f, %d", *value, *nodata);
1786  return 1;
1787  }
1788  /* first NODATA */
1789  else if (arg->nodata[0][0][0] && !arg->nodata[1][0][0]) {
1790  *value = arg->values[1][0][0];
1791  POSTGIS_RT_DEBUGF(4, "value, nodata = %f, %d", *value, *nodata);
1792  return 1;
1793  }
1794  }
1795 
1796  switch (*utype) {
1797  case UT_FIRST:
1798  *value = arg->values[0][0][0];
1799  break;
1800  case UT_MIN:
1801  if (arg->values[0][0][0] < arg->values[1][0][0])
1802  *value = arg->values[0][0][0];
1803  else
1804  *value = arg->values[1][0][0];
1805  break;
1806  case UT_MAX:
1807  if (arg->values[0][0][0] > arg->values[1][0][0])
1808  *value = arg->values[0][0][0];
1809  else
1810  *value = arg->values[1][0][0];
1811  break;
1812  case UT_COUNT:
1813  /* both NODATA */
1814  if (arg->nodata[0][0][0] && arg->nodata[1][0][0])
1815  *value = 0;
1816  /* second NODATA */
1817  else if (!arg->nodata[0][0][0] && arg->nodata[1][0][0])
1818  *value = arg->values[0][0][0];
1819  /* first NODATA */
1820  else if (arg->nodata[0][0][0] && !arg->nodata[1][0][0])
1821  *value = 1;
1822  /* has value, increment */
1823  else
1824  *value = arg->values[0][0][0] + 1;
1825  break;
1826  case UT_SUM:
1827  *value = arg->values[0][0][0] + arg->values[1][0][0];
1828  break;
1829  case UT_MEAN:
1830  case UT_RANGE:
1831  break;
1832  case UT_LAST:
1833  default:
1834  *value = arg->values[1][0][0];
1835  break;
1836  }
1837 
1838  POSTGIS_RT_DEBUGF(4, "value, nodata = %f, %d", *value, *nodata);
1839 
1840 
1841  return 1;
1842 }
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:69
double *** values
Definition: librtcore.h:2612
uint32_t columns
Definition: librtcore.h:2608
uint16_t rasters
Definition: librtcore.h:2604

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: