PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_band_get_pixel_of_value()

static void test_band_get_pixel_of_value ( )
static

Definition at line 290 of file cu_band_misc.c.

References ovdump::band, cu_add_band(), cu_free_raster(), FALSE, PT_32BUI, rtpixdump::rast, rt_band_get_pixel_of_value(), rt_band_set_pixel(), rt_raster_new(), rtdealloc(), TRUE, pixval::x, and pixval::y.

Referenced by band_misc_suite_setup().

290  {
291  rt_raster rast;
292  rt_band band;
293  uint32_t x, y;
294  int rtn;
295  const int maxX = 10;
296  const int maxY = 10;
297  rt_pixel pixels = NULL;
298 
299  double search0[1] = {0};
300  double search1[1] = {1};
301  double search2[2] = {3, 5};
302 
303  rast = rt_raster_new(maxX, maxY);
304  CU_ASSERT(rast != NULL);
305 
306  band = cu_add_band(rast, PT_32BUI, 1, 0);
307  CU_ASSERT(band != NULL);
308 
309  for (x = 0; x < maxX; x++) {
310  for (y = 0; y < maxY; y++) {
311  rtn = rt_band_set_pixel(band, x, y, 1, NULL);
312  }
313  }
314 
315  rt_band_set_pixel(band, 0, 0, 0, NULL);
316  rt_band_set_pixel(band, 3, 0, 0, NULL);
317  rt_band_set_pixel(band, 6, 0, 0, NULL);
318  rt_band_set_pixel(band, 9, 0, 0, NULL);
319  rt_band_set_pixel(band, 1, 2, 0, NULL);
320  rt_band_set_pixel(band, 4, 2, 0, NULL);
321  rt_band_set_pixel(band, 7, 2, 0, NULL);
322  rt_band_set_pixel(band, 2, 4, 0, NULL);
323  rt_band_set_pixel(band, 5, 4, 0, NULL);
324  rt_band_set_pixel(band, 8, 4, 0, NULL);
325  rt_band_set_pixel(band, 0, 6, 0, NULL);
326  rt_band_set_pixel(band, 3, 6, 0, NULL);
327  rt_band_set_pixel(band, 6, 6, 0, NULL);
328  rt_band_set_pixel(band, 9, 6, 0, NULL);
329  rt_band_set_pixel(band, 1, 8, 0, NULL);
330  rt_band_set_pixel(band, 4, 8, 0, NULL);
331  rt_band_set_pixel(band, 7, 8, 0, NULL);
332 
333  pixels = NULL;
335  band, TRUE,
336  search1, 1,
337  &pixels
338  );
339  CU_ASSERT_EQUAL(rtn, 83);
340  if (rtn)
341  rtdealloc(pixels);
342 
343  pixels = NULL;
345  band, FALSE,
346  search0, 1,
347  &pixels
348  );
349  CU_ASSERT_EQUAL(rtn, 17);
350  if (rtn)
351  rtdealloc(pixels);
352 
353  rt_band_set_pixel(band, 4, 2, 3, NULL);
354  rt_band_set_pixel(band, 7, 2, 5, NULL);
355  rt_band_set_pixel(band, 1, 8, 3, NULL);
356 
357  pixels = NULL;
359  band, TRUE,
360  search2, 2,
361  &pixels
362  );
363  CU_ASSERT_EQUAL(rtn, 3);
364  if (rtn)
365  rtdealloc(pixels);
366 
367  cu_free_raster(rast);
368 }
band
Definition: ovdump.py:57
int rt_band_get_pixel_of_value(rt_band band, int exclude_nodata_value, double *searchset, int searchcount, rt_pixel *pixels)
Search band for pixel(s) with search values.
Definition: rt_band.c:1519
unsigned int uint32_t
Definition: uthash.h:78
void cu_free_raster(rt_raster raster)
rt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)
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
#define FALSE
Definition: dbfopen.c:168
rt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel&#39;s value.
Definition: rt_band.c:841
#define TRUE
Definition: dbfopen.c:169
Here is the call graph for this function:
Here is the caller graph for this function: