PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void test_raster_replace_band ( )
static

Definition at line 172 of file cu_raster_basics.c.

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().

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);
196  rt_band_set_ownsdata_flag(band, 1);
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_raster_replace_band(rt_raster raster, rt_band band, int index)
Replace band at provided index with new band.
Definition: rt_api.c:8702
tuple band
Definition: ovdump.py:57
tuple raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:123
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_api.c:1466
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
Definition: rt_api.c:1097
void cu_free_raster(rt_raster raster)
rt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)
void rt_band_set_ownsdata_flag(rt_band band, int flag)
Definition: rt_api.c:1936
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
Definition: rt_api.c:3058
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition: rt_api.c:1650
uint16_t rt_raster_get_height(rt_raster raster)
Definition: rt_api.c:5434
void * rtalloc(size_t size)
Raster core memory management functions.
Definition: rt_api.c:867
rt_band rt_raster_get_band(rt_raster raster, int n)
Return Nth band, or NULL if unavailable.
Definition: rt_api.c:5686
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_api.c:5353
uint16_t rt_raster_get_width(rt_raster raster)
Definition: rt_api.c:5426

Here is the call graph for this function:

Here is the caller graph for this function: