PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ rtpg_union_noarg()

static int rtpg_union_noarg ( rtpg_union_arg  arg,
rt_raster  raster 
)
static

Definition at line 2067 of file rtpg_mapalgebra.c.

2067  {
2068  int numbands;
2069  int i;
2070 
2072  return 1;
2073 
2074  numbands = rt_raster_get_num_bands(raster);
2075  if (numbands <= arg->numband)
2076  return 1;
2077 
2078  /* more bands to process */
2079  POSTGIS_RT_DEBUG(4, "input raster has more bands, adding more bandargs");
2080  if (arg->numband)
2081  arg->bandarg = repalloc(arg->bandarg, sizeof(struct rtpg_union_band_arg_t) * numbands);
2082  else
2083  arg->bandarg = palloc(sizeof(struct rtpg_union_band_arg_t) * numbands);
2084  if (arg->bandarg == NULL) {
2085  elog(ERROR, "rtpg_union_noarg: Could not reallocate memory for band information");
2086  return 0;
2087  }
2088 
2089  i = arg->numband;
2090  arg->numband = numbands;
2091  for (; i < arg->numband; i++) {
2092  POSTGIS_RT_DEBUGF(4, "Adding bandarg for band at index %d", i);
2093  arg->bandarg[i].uniontype = UT_LAST;
2094  arg->bandarg[i].nband = i;
2095  arg->bandarg[i].numraster = 1;
2096 
2097  arg->bandarg[i].raster = (rt_raster *) palloc(sizeof(rt_raster) * arg->bandarg[i].numraster);
2098  if (arg->bandarg[i].raster == NULL) {
2099  elog(ERROR, "rtpg_union_noarg: Could not allocate memory for working rasters");
2100  return 0;
2101  }
2102  memset(arg->bandarg[i].raster, 0, sizeof(rt_raster) * arg->bandarg[i].numraster);
2103 
2104  /* add new working rt_raster but only if working raster already exists */
2105  if (!rt_raster_is_empty(arg->bandarg[0].raster[0])) {
2106  arg->bandarg[i].raster[0] = rt_raster_clone(arg->bandarg[0].raster[0], 0); /* shallow clone */
2107  if (arg->bandarg[i].raster[0] == NULL) {
2108  elog(ERROR, "rtpg_union_noarg: Could not create working raster");
2109  return 0;
2110  }
2111  }
2112  }
2113 
2114  return 1;
2115 }
uint16_t rt_raster_get_num_bands(rt_raster raster)
Definition: rt_raster.c:372
rt_raster rt_raster_clone(rt_raster raster, uint8_t deep)
Clone an existing raster.
Definition: rt_raster.c:1540
int rt_raster_is_empty(rt_raster raster)
Return TRUE if the raster is empty.
Definition: rt_raster.c:1334
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
@ UT_LAST
#define POSTGIS_RT_DEBUG(level, msg)
Definition: rtpostgis.h:61
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rtpostgis.h:65
rtpg_union_band_arg bandarg
rtpg_union_type uniontype

References rtpg_union_arg_t::bandarg, rtpg_union_band_arg_t::nband, rtpg_union_arg_t::numband, rtpg_union_band_arg_t::numraster, POSTGIS_RT_DEBUG, POSTGIS_RT_DEBUGF, rtpg_union_band_arg_t::raster, rtrowdump::raster, rt_raster_clone(), rt_raster_get_num_bands(), rt_raster_is_empty(), rtpg_union_band_arg_t::uniontype, and UT_LAST.

Referenced by RASTER_union_transfn().

Here is the call graph for this function:
Here is the caller graph for this function: