27 {
30 double bin_width[] = {100};
31 double quantiles[] = {0.1, 0.3, 0.5, 0.7, 0.9};
32 double quantiles2[] = {0.66666667};
35
39 uint32_t xmax = 100;
41 uint32_t ymax = 100;
42 uint32_t max_run;
43 double nodata;
44
45 uint32_t values[] = {0, 91, 55, 86, 76, 41, 36, 97, 25, 63, 68, 2, 78, 15, 82, 47};
47 uint32_t qlls_count;
48
50 CU_ASSERT(raster != NULL);
52 CU_ASSERT(band != NULL);
53
54 for (x = 0;
x < xmax;
x++) {
55 for (y = 0;
y < ymax;
y++) {
57 }
58 }
59
61 CU_ASSERT_DOUBLE_EQUAL(nodata, 0, DBL_EPSILON);
62
64 CU_ASSERT(stats != NULL);
65 CU_ASSERT_DOUBLE_EQUAL(stats->
min, 1, DBL_EPSILON);
66 CU_ASSERT_DOUBLE_EQUAL(stats->
max, 198, DBL_EPSILON);
67
71
73 CU_ASSERT(histogram != NULL);
75
77 CU_ASSERT(histogram != NULL);
79
81 CU_ASSERT(histogram != NULL);
83
86
88 CU_ASSERT(stats != NULL);
89
93
96 CU_ASSERT_EQUAL(
count, 5);
98
100 CU_ASSERT(histogram != NULL);
102
105
107 CU_ASSERT(stats != NULL);
109
111 CU_ASSERT(stats != NULL);
113
115 CU_ASSERT(stats != NULL);
117
119 CU_ASSERT(stats != NULL);
120 CU_ASSERT_DOUBLE_EQUAL(stats->
min, 0, DBL_EPSILON);
121 CU_ASSERT_DOUBLE_EQUAL(stats->
max, 198, DBL_EPSILON);
122
126
129
131 CU_ASSERT(stats != NULL);
132
136
139
141
142 xmax = 4;
143 ymax = 4;
145 CU_ASSERT(raster != NULL);
147 CU_ASSERT(band != NULL);
149
150 for (x = 0;
x < xmax;
x++) {
151 for (y = 0;
y < ymax;
y++) {
153 }
154 }
155
157 CU_ASSERT_DOUBLE_EQUAL(nodata, 0, DBL_EPSILON);
158
160 band, 1, 1, 15,
161 &qlls, &qlls_count,
162 quantiles2, 1,
165 CU_ASSERT_NOT_EQUAL(
count, 0);
166 CU_ASSERT_NOT_EQUAL(qlls_count, 0);
167 CU_ASSERT_DOUBLE_EQUAL(
quantile[0].value, 78, DBL_EPSILON);
170 qlls = NULL;
171 qlls_count = 0;
172
174
175 xmax = 100;
176 ymax = 100;
178 CU_ASSERT(raster != NULL);
180 CU_ASSERT(band != NULL);
182
183 for (x = 0;
x < xmax;
x++) {
184 for (y = 0;
y < ymax;
y++) {
185 rt_band_set_pixel(band, x, y, (((
double) x * y) + (x + y) + (x + y * x)) / (x + y + 1), NULL);
186 }
187 }
188
190 CU_ASSERT_DOUBLE_EQUAL(nodata, 0, DBL_EPSILON);
191
192 max_run = 5;
193 for (x = 0;
x < max_run;
x++) {
195 band, 1, 1, xmax * ymax * max_run,
196 &qlls, &qlls_count,
197 quantiles2, 1,
200 CU_ASSERT_NOT_EQUAL(
count, 0);
201 CU_ASSERT_NOT_EQUAL(qlls_count, 0);
203 }
204
206 qlls = NULL;
207 qlls_count = 0;
208
210}
struct rt_quantile_t * rt_quantile
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
rt_quantile rt_band_get_quantiles_stream(rt_band band, int exclude_nodata_value, double sample, uint64_t cov_count, struct quantile_llist **qlls, uint32_t *qlls_count, double *quantiles, uint32_t quantiles_count, uint32_t *rtn_count)
Compute the default set of or requested quantiles for a coverage.
struct rt_bandstats_t * rt_bandstats
int quantile_llist_destroy(struct quantile_llist **list, uint32_t list_count)
rt_errorstate rt_band_set_nodata(rt_band band, double val, int *converted)
Set nodata value.
rt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel's value.
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
rt_histogram rt_band_get_histogram(rt_bandstats stats, uint32_t bin_count, double *bin_widths, uint32_t bin_widths_count, int right, double min, double max, uint32_t *rtn_count)
Count the distribution of data.
void rtdealloc(void *mem)
rt_quantile rt_band_get_quantiles(rt_bandstats stats, double *quantiles, int quantiles_count, uint32_t *rtn_count)
Compute the default set of or requested quantiles for a set of data the quantile formula used is same...
rt_bandstats rt_band_get_summary_stats(rt_band band, int exclude_nodata_value, double sample, int inc_vals, uint64_t *cK, double *cM, double *cQ)
Compute summary statistics for a band.
struct rt_histogram_t * rt_histogram
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
rt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)
void cu_free_raster(rt_raster raster)