PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_band_value_count()

static void test_band_value_count ( )
static

Definition at line 212 of file cu_band_stats.c.

212  {
213  rt_valuecount vcnts = NULL;
214 
216  rt_band band;
217  uint32_t x;
218  uint32_t xmax = 100;
219  uint32_t y;
220  uint32_t ymax = 100;
221  uint32_t rtn = 0;
222 
223  double count[] = {3, 4, 5};
224 
225  raster = rt_raster_new(xmax, ymax);
226  CU_ASSERT(raster != NULL); /* or we're out of virtual memory */
227  band = cu_add_band(raster, PT_64BF, 0, 0);
228  CU_ASSERT(band != NULL);
229  rt_band_set_nodata(band, 0, NULL);
230 
231  for (x = 0; x < xmax; x++) {
232  for (y = 0; y < ymax; y++) {
233  rt_band_set_pixel(band, x, y, (((double) x * y) + (x + y) + (x + y * x)) / (x + y + 1), NULL);
234  }
235  }
236  vcnts = rt_band_get_value_count(band, 1, NULL, 0, 0, NULL, &rtn);
237  CU_ASSERT(vcnts != NULL);
238  CU_ASSERT_NOT_EQUAL(rtn, 0);
239  rtdealloc(vcnts);
240 
241  vcnts = rt_band_get_value_count(band, 1, NULL, 0, 0.01, NULL, &rtn);
242  CU_ASSERT(vcnts != NULL);
243  CU_ASSERT_NOT_EQUAL(rtn, 0);
244  rtdealloc(vcnts);
245 
246  vcnts = rt_band_get_value_count(band, 1, NULL, 0, 0.1, NULL, &rtn);
247  CU_ASSERT(vcnts != NULL);
248  CU_ASSERT_NOT_EQUAL(rtn, 0);
249  rtdealloc(vcnts);
250 
251  vcnts = rt_band_get_value_count(band, 1, NULL, 0, 1, NULL, &rtn);
252  CU_ASSERT(vcnts != NULL);
253  CU_ASSERT_NOT_EQUAL(rtn, 0);
254  rtdealloc(vcnts);
255 
256  vcnts = rt_band_get_value_count(band, 1, NULL, 0, 10, NULL, &rtn);
257  CU_ASSERT(vcnts != NULL);
258  CU_ASSERT_NOT_EQUAL(rtn, 0);
259  rtdealloc(vcnts);
260 
261  vcnts = rt_band_get_value_count(band, 1, count, 3, 1, NULL, &rtn);
262  CU_ASSERT(vcnts != NULL);
263  CU_ASSERT_NOT_EQUAL(rtn, 0);
264  rtdealloc(vcnts);
265 
267 }
@ PT_64BF
Definition: librtcore.h:196
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_raster.c:48
rt_errorstate rt_band_set_nodata(rt_band band, double val, int *converted)
Set nodata value.
Definition: rt_band.c:733
rt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel's value.
Definition: rt_band.c:974
void rtdealloc(void *mem)
Definition: rt_context.c:186
rt_valuecount rt_band_get_value_count(rt_band band, int exclude_nodata_value, double *search_values, uint32_t search_values_count, double roundto, uint32_t *rtn_total, uint32_t *rtn_count)
Count the number of times provided value(s) occur in the band.
int count
Definition: genraster.py:56
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)
unsigned int uint32_t
Definition: uthash.h:78

References ovdump::band, genraster::count, cu_add_band(), cu_free_raster(), PT_64BF, rtrowdump::raster, rt_band_get_value_count(), rt_band_set_nodata(), rt_band_set_pixel(), rt_raster_new(), rtdealloc(), pixval::x, and pixval::y.

Referenced by band_stats_suite_setup().

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