PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ test_raster_replace_band()

static void test_raster_replace_band ( )
static

Definition at line 172 of file cu_raster_basics.c.

172 {
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);
200 rt_band_get_nodata(rt_raster_get_band(raster, 0), &nodata);
201 CU_ASSERT_DOUBLE_EQUAL(nodata, 1, DBL_EPSILON);
202
203 rt_band_destroy(rband);
204 cu_free_raster(raster);
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:64
void rt_band_set_ownsdata_flag(rt_band band, int flag)
Definition rt_band.c:826
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition rt_context.c:191
@ PT_8BUI
Definition librtcore.h:193
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition rt_raster.c:52
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:1404
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition rt_band.c:499
uint16_t rt_raster_get_height(rt_raster raster)
Definition rt_raster.c:133
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
Definition rt_band.c:2067
uint16_t rt_raster_get_width(rt_raster raster)
Definition rt_raster.c:125
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
Definition rt_pixel.c:40
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
Definition rt_raster.c:385
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition rtrowdump.py:125
rt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)
void cu_free_raster(rt_raster raster)

References cu_add_band(), cu_free_raster(), PT_8BUI, 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: