PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ cu_add_band()

rt_band cu_add_band ( rt_raster  raster,
rt_pixtype  pixtype,
int  hasnodata,
double  nodataval 
)

Definition at line 222 of file raster/test/cunit/cu_tester.c.

References ovdump::band, rt_band_new_inline(), rt_band_set_ownsdata_flag(), rt_pixtype_size(), rt_raster_add_band(), rt_raster_get_height(), rt_raster_get_num_bands(), rt_raster_get_width(), and rtalloc().

Referenced by fillRasterToPolygonize(), test_band_get_nearest_pixel(), test_band_get_pixel_line(), test_band_get_pixel_of_value(), test_band_reclass(), test_band_stats(), test_band_value_count(), test_gdal_to_raster(), test_gdal_warp(), test_pixel_set_to_array(), test_raster_clone(), test_raster_colormap(), test_raster_from_band(), test_raster_fully_within_distance(), test_raster_geos_contains(), test_raster_geos_contains_properly(), test_raster_geos_covered_by(), test_raster_geos_covers(), test_raster_geos_overlaps(), test_raster_geos_touches(), test_raster_intersects(), test_raster_iterator(), test_raster_perimeter(), test_raster_pixel_as_polygon(), test_raster_replace_band(), test_raster_surface(), test_raster_to_gdal(), and test_raster_within_distance().

222  {
223  void* mem = NULL;
224  int32_t bandNum = 0;
225  size_t datasize = 0;
226  rt_band band = NULL;
227  uint16_t width = 0;
228  uint16_t height = 0;
229 
230  width = rt_raster_get_width(raster);
231  height = rt_raster_get_height(raster);
232 
233  datasize = rt_pixtype_size(pixtype) * width * height;
234  mem = rtalloc(datasize);
235  CU_ASSERT(mem != NULL);
236 
237  if (hasnodata)
238  memset(mem, nodataval, datasize);
239  else
240  memset(mem, 0, datasize);
241 
242  band = rt_band_new_inline(width, height, pixtype, hasnodata, nodataval, mem);
243  CU_ASSERT(band != NULL);
244  rt_band_set_ownsdata_flag(band, 1);
245 
246  bandNum = rt_raster_add_band(raster, band, rt_raster_get_num_bands(raster));
247  CU_ASSERT(bandNum >= 0);
248 
249  return band;
250 }
uint16_t rt_raster_get_num_bands(rt_raster raster)
Definition: rt_raster.c:372
band
Definition: ovdump.py:57
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
void rt_band_set_ownsdata_flag(rt_band band, int flag)
Definition: rt_band.c:667
rt_band rt_band_new_inline(uint16_t width, uint16_t height, rt_pixtype pixtype, uint32_t hasnodata, double nodataval, uint8_t *data)
Create an in-db rt_band with no data.
Definition: rt_band.c:63
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
Definition: rt_pixel.c:39
uint16_t rt_raster_get_width(rt_raster raster)
Definition: rt_raster.c:121
int rt_raster_add_band(rt_raster raster, rt_band band, int index)
Add band data to a raster.
Definition: rt_raster.c:405
uint16_t rt_raster_get_height(rt_raster raster)
Definition: rt_raster.c:129
Here is the call graph for this function:
Here is the caller graph for this function: