2765{
2770
2771 int i = 0;
2772 int j = 0;
2775 int noerr = 1;
2776 int status = 0;
2778 int hasnodata = 0;
2779 double nodataval = 0;
2780
2782
2783
2784 if (!AggCheckCallContext(fcinfo, NULL)) {
2785 elog(ERROR, "RASTER_union_finalfn: Cannot be called in a non-aggregate context");
2786 PG_RETURN_NULL();
2787 }
2788
2789
2790 if (PG_ARGISNULL(0))
2791 PG_RETURN_NULL();
2792
2794
2795
2797 if (itrset == NULL) {
2799 elog(ERROR, "RASTER_union_finalfn: Could not allocate memory for iterator arguments");
2800 PG_RETURN_NULL();
2801 }
2802
2803 for (i = 0; i < iwr->
numband; i++) {
2804 if (
2807 ) {
2808
2810
2813 if (hasnodata)
2816
2818 itrset[0].
nband = 0;
2820 itrset[1].
nband = 0;
2821
2822
2825 itrset, 2,
2827 pixtype,
2828 hasnodata, nodataval,
2829 0, 0,
2830 NULL,
2831 NULL,
2833 &_raster
2834 );
2835 }
2838 itrset, 2,
2840 pixtype,
2841 hasnodata, nodataval,
2842 0, 0,
2843 NULL,
2844 NULL,
2846 &_raster
2847 );
2848 }
2849
2851 pfree(itrset);
2853 if (_rtn != NULL)
2855 elog(ERROR, "RASTER_union_finalfn: Could not run raster iterator function");
2856 PG_RETURN_NULL();
2857 }
2858 }
2859 else {
2861 if (_raster == NULL)
2862 continue;
2863 }
2864
2865
2866 if (i < 1) {
2867 uint32_t bandNums[1] = {0};
2869 status = (_rtn == NULL) ? -1 : 0;
2870 }
2871 else
2873
2875
2876
2877 if (
2880 ) {
2882 }
2883
2886 continue;
2889 }
2890
2891 if (status < 0) {
2894 elog(ERROR, "RASTER_union_finalfn: Could not add band to final raster");
2895 PG_RETURN_NULL();
2896 }
2897 }
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907 if (!_rtn) PG_RETURN_NULL();
2908
2911
2913
2914 if (!pgraster)
2915 PG_RETURN_NULL();
2916
2917 SET_VARSIZE(pgraster, pgraster->
size);
2918 PG_RETURN_POINTER(pgraster);
2919}
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