PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ rtpg_union_noarg()

static int rtpg_union_noarg ( rtpg_union_arg  arg,
rt_raster  raster 
)
static

Definition at line 2021 of file rtpg_mapalgebra.c.

2021  {
2022  int numbands;
2023  int i;
2024 
2026  return 1;
2027 
2028  numbands = rt_raster_get_num_bands(raster);
2029  if (numbands <= arg->numband)
2030  return 1;
2031 
2032  /* more bands to process */
2033  POSTGIS_RT_DEBUG(4, "input raster has more bands, adding more bandargs");
2034  if (arg->numband)
2035  arg->bandarg = repalloc(arg->bandarg, sizeof(struct rtpg_union_band_arg_t) * numbands);
2036  else
2037  arg->bandarg = palloc(sizeof(struct rtpg_union_band_arg_t) * numbands);
2038  if (arg->bandarg == NULL) {
2039  elog(ERROR, "rtpg_union_noarg: Could not reallocate memory for band information");
2040  return 0;
2041  }
2042 
2043  i = arg->numband;
2044  arg->numband = numbands;
2045  for (; i < arg->numband; i++) {
2046  POSTGIS_RT_DEBUGF(4, "Adding bandarg for band at index %d", i);
2047  arg->bandarg[i].uniontype = UT_LAST;
2048  arg->bandarg[i].nband = i;
2049  arg->bandarg[i].numraster = 1;
2050 
2051  arg->bandarg[i].raster = (rt_raster *) palloc(sizeof(rt_raster) * arg->bandarg[i].numraster);
2052  if (arg->bandarg[i].raster == NULL) {
2053  elog(ERROR, "rtpg_union_noarg: Could not allocate memory for working rasters");
2054  return 0;
2055  }
2056  memset(arg->bandarg[i].raster, 0, sizeof(rt_raster) * arg->bandarg[i].numraster);
2057 
2058  /* add new working rt_raster but only if working raster already exists */
2059  if (!rt_raster_is_empty(arg->bandarg[0].raster[0])) {
2060  arg->bandarg[i].raster[0] = rt_raster_clone(arg->bandarg[0].raster[0], 0); /* shallow clone */
2061  if (arg->bandarg[i].raster[0] == NULL) {
2062  elog(ERROR, "rtpg_union_noarg: Could not create working raster");
2063  return 0;
2064  }
2065  }
2066  }
2067 
2068  return 1;
2069 }
uint16_t rt_raster_get_num_bands(rt_raster raster)
Definition: rt_raster.c:376
rt_raster rt_raster_clone(rt_raster raster, uint8_t deep)
Clone an existing raster.
Definition: rt_raster.c:1568
int rt_raster_is_empty(rt_raster raster)
Return TRUE if the raster is empty.
Definition: rt_raster.c:1362
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:65
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rtpostgis.h:69
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: