PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ rtpg_union_noarg()

static int rtpg_union_noarg ( rtpg_union_arg  arg,
rt_raster  raster 
)
static

Definition at line 2027 of file rtpg_mapalgebra.c.

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