PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_raster_replace_band()

static void test_raster_replace_band ( )
static

Definition at line 172 of file cu_raster_basics.c.

172  {
174  rt_band band;
175  rt_band rband;
176  void* mem;
177  size_t datasize;
178  uint16_t width;
179  uint16_t height;
180  double nodata;
181 
182  raster = rt_raster_new(10, 10);
183  CU_ASSERT(raster != NULL); /* or we're out of virtual memory */
184  band = cu_add_band(raster, PT_8BUI, 0, 0);
185  CU_ASSERT(band != NULL);
186  band = cu_add_band(raster, PT_8BUI, 1, 255);
187  CU_ASSERT(band != NULL);
188 
189  width = rt_raster_get_width(raster);
190  height = rt_raster_get_height(raster);
191 
192  datasize = rt_pixtype_size(PT_8BUI) * width * height;
193  mem = rtalloc(datasize);
194  band = rt_band_new_inline(width, height, PT_8BUI, 1, 1, mem);
195  CU_ASSERT(band != NULL);
197 
198  rband = rt_raster_replace_band(raster, band, 0);
199  CU_ASSERT(rband != NULL);
201  CU_ASSERT_DOUBLE_EQUAL(nodata, 1, DBL_EPSILON);
202 
203  rt_band_destroy(rband);
205 }
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
void rt_band_set_ownsdata_flag(rt_band band, int flag)
Definition: rt_band.c:667
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
@ PT_8BUI
Definition: librtcore.h:190
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_raster.c:48
rt_band rt_raster_replace_band(rt_raster raster, rt_band band, int index)
Replace band at provided index with new band.
Definition: rt_raster.c:1498
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition: rt_band.c:340
uint16_t rt_raster_get_height(rt_raster raster)
Definition: rt_raster.c:129
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
Definition: rt_band.c:1730
uint16_t rt_raster_get_width(rt_raster raster)
Definition: rt_raster.c:121
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
Definition: rt_pixel.c:39
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
Definition: rt_raster.c:381
band
Definition: ovdump.py:57
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
rt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)
void cu_free_raster(rt_raster raster)

References ovdump::band, cu_add_band(), cu_free_raster(), PT_8BUI, rtrowdump::raster, rt_band_destroy(), rt_band_get_nodata(), rt_band_new_inline(), rt_band_set_ownsdata_flag(), rt_pixtype_size(), rt_raster_get_band(), rt_raster_get_height(), rt_raster_get_width(), rt_raster_new(), rt_raster_replace_band(), and rtalloc().

Referenced by raster_basics_suite_setup().

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