2800{
2805
2806 int i = 0;
2807 int j = 0;
2810 int noerr = 1;
2811 int status = 0;
2813 int hasnodata = 0;
2814 double nodataval = 0;
2815
2817
2818
2819 if (!AggCheckCallContext(fcinfo, NULL)) {
2820 elog(ERROR, "RASTER_union_finalfn: Cannot be called in a non-aggregate context");
2821 PG_RETURN_NULL();
2822 }
2823
2824
2825 if (PG_ARGISNULL(0))
2826 PG_RETURN_NULL();
2827
2829
2830
2832 if (itrset == NULL) {
2834 elog(ERROR, "RASTER_union_finalfn: Could not allocate memory for iterator arguments");
2835 PG_RETURN_NULL();
2836 }
2837
2838 for (i = 0; i < iwr->
numband; i++) {
2839 if (
2842 ) {
2843
2845
2848 if (hasnodata)
2851
2853 itrset[0].
nband = 0;
2855 itrset[1].
nband = 0;
2856
2857
2860 itrset, 2,
2862 pixtype,
2863 hasnodata, nodataval,
2864 0, 0,
2865 NULL,
2866 NULL,
2868 &_raster
2869 );
2870 }
2873 itrset, 2,
2875 pixtype,
2876 hasnodata, nodataval,
2877 0, 0,
2878 NULL,
2879 NULL,
2881 &_raster
2882 );
2883 }
2884
2886 pfree(itrset);
2888 if (_rtn != NULL)
2890 elog(ERROR, "RASTER_union_finalfn: Could not run raster iterator function");
2891 PG_RETURN_NULL();
2892 }
2893 }
2894 else {
2896 if (_raster == NULL)
2897 continue;
2898 }
2899
2900
2901 if (i < 1) {
2902 uint32_t bandNums[1] = {0};
2904 status = (_rtn == NULL) ? -1 : 0;
2905 }
2906 else
2908
2910
2911
2912 if (
2915 ) {
2917 }
2918
2921 continue;
2924 }
2925
2926 if (status < 0) {
2929 elog(ERROR, "RASTER_union_finalfn: Could not add band to final raster");
2930 PG_RETURN_NULL();
2931 }
2932 }
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942 if (!_rtn) PG_RETURN_NULL();
2943
2946
2948
2949 if (!pgraster)
2950 PG_RETURN_NULL();
2951
2952 SET_VARSIZE(pgraster, pgraster->
size);
2953 PG_RETURN_POINTER(pgraster);
2954}
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
const char * rt_pixtype_name(rt_pixtype pixtype)
rt_errorstate rt_raster_iterator(rt_iterator itrset, uint16_t itrcount, rt_extenttype extenttype, rt_raster customextent, rt_pixtype pixtype, uint8_t hasnodata, double nodataval, uint16_t distancex, uint16_t distancey, rt_mask mask, void *userarg, int(*callback)(rt_iterator_arg arg, void *userarg, double *value, int *nodata), rt_raster *rtnraster)
n-raster iterator.
rt_raster rt_raster_from_band(rt_raster raster, uint32_t *bandNums, int count)
Construct a new rt_raster from an existing rt_raster and an array of band numbers.
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
rt_pixtype rt_band_get_pixtype(rt_band band)
Return pixeltype of this band.
void * rt_raster_serialize(rt_raster raster)
Return this raster in serialized form.
int rt_raster_copy_band(rt_raster torast, rt_raster fromrast, int fromindex, int toindex)
Copy one band from one raster to another.
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
static int rtpg_union_mean_callback(rt_iterator_arg arg, void *userarg, double *value, int *nodata)
static int rtpg_union_range_callback(rt_iterator_arg arg, void *userarg, double *value, int *nodata)
static void rtpg_union_arg_destroy(rtpg_union_arg arg)
struct rtpg_union_arg_t * rtpg_union_arg
#define POSTGIS_RT_DEBUG(level, msg)
#define POSTGIS_RT_DEBUGF(level, msg,...)
rtpg_union_band_arg bandarg
rtpg_union_type uniontype