PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ rt_raster_clone()

rt_raster rt_raster_clone ( rt_raster  raster,
uint8_t  deep 
)

Clone an existing raster.

Parameters
raster: raster to clone
deep: flag indicating if bands should be cloned
Returns
a new rt_raster or NULL on error

Definition at line 1544 of file rt_raster.c.

References window::gt, pixval::nband, rt_raster_from_band(), rt_raster_get_geotransform_matrix(), rt_raster_get_height(), rt_raster_get_num_bands(), rt_raster_get_srid(), rt_raster_get_width(), rt_raster_new(), rt_raster_set_geotransform_matrix(), rt_raster_set_srid(), rtalloc(), rtdealloc(), and rterror().

Referenced by _rti_colormap_arg_init(), RASTER_colorMap(), RASTER_union_transfn(), rtpg_union_noarg(), and test_raster_clone().

1544  {
1545  rt_raster rtn = NULL;
1546  double gt[6] = {0};
1547 
1548  assert(NULL != raster);
1549 
1550  if (deep) {
1551  int numband = rt_raster_get_num_bands(raster);
1552  uint32_t *nband = NULL;
1553  int i = 0;
1554 
1555  nband = rtalloc(sizeof(uint32_t) * numband);
1556  if (nband == NULL) {
1557  rterror("rt_raster_clone: Could not allocate memory for deep clone");
1558  return NULL;
1559  }
1560  for (i = 0; i < numband; i++)
1561  nband[i] = i;
1562 
1563  rtn = rt_raster_from_band(raster, nband, numband);
1564  rtdealloc(nband);
1565 
1566  return rtn;
1567  }
1568 
1569  rtn = rt_raster_new(
1570  rt_raster_get_width(raster),
1571  rt_raster_get_height(raster)
1572  );
1573  if (rtn == NULL) {
1574  rterror("rt_raster_clone: Could not create cloned raster");
1575  return NULL;
1576  }
1577 
1580  rt_raster_set_srid(rtn, rt_raster_get_srid(raster));
1581 
1582  return rtn;
1583 }
int rt_raster_get_num_bands(rt_raster raster)
Definition: rt_raster.c:372
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
void rt_raster_set_srid(rt_raster raster, int32_t srid)
Set raster&#39;s SRID.
Definition: rt_raster.c:363
gt
Definition: window.py:77
void rt_raster_set_geotransform_matrix(rt_raster raster, double *gt)
Set raster&#39;s geotransform using 6-element array.
Definition: rt_raster.c:727
unsigned int uint32_t
Definition: uthash.h:78
nband
Definition: pixval.py:52
void rt_raster_get_geotransform_matrix(rt_raster raster, double *gt)
Get 6-element array of raster geotransform matrix.
Definition: rt_raster.c:706
int32_t rt_raster_get_srid(rt_raster raster)
Get raster&#39;s SRID.
Definition: rt_raster.c:356
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_raster.c:48
void rtdealloc(void *mem)
Definition: rt_context.c:186
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.
Definition: rt_raster.c:1439
uint16_t rt_raster_get_height(rt_raster raster)
Definition: rt_raster.c:129
uint16_t rt_raster_get_width(rt_raster raster)
Definition: rt_raster.c:121
Here is the call graph for this function:
Here is the caller graph for this function: