PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ rtpg_union_callback()

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

Definition at line 1794 of file rtpg_mapalgebra.c.

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

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

Referenced by RASTER_union_transfn().

Here is the caller graph for this function: