PostGIS  3.7.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 1759 of file rtpg_mapalgebra.c.

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

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: