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

◆ 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
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
266 cu_free_raster(raster);
267}
@ PT_64BF
Definition librtcore.h:200
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition rt_raster.c:52
rt_errorstate rt_band_set_nodata(rt_band band, double val, int *converted)
Set nodata value.
Definition rt_band.c:892
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:1140
void rtdealloc(void *mem)
Definition rt_context.c:206
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:57
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 quantile_llist::count, cu_add_band(), cu_free_raster(), PT_64BF, rt_band_get_value_count(), rt_band_set_nodata(), rt_band_set_pixel(), rt_raster_new(), and rtdealloc().

Referenced by band_stats_suite_setup().

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