25 #include "CUnit/Basic.h"
36 char *path =
"../regress/loader/testraster.tif";
43 CU_ASSERT(
data != NULL);
52 CU_ASSERT(
band != NULL);
84 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
90 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
111 CU_ASSERT(
band != NULL);
114 CU_ASSERT(
rast != NULL);
129 CU_ASSERT_EQUAL(extband, 2);
135 for (
x = 0;
x < width;
x++) {
136 for (
y = 0;
y < height;
y++) {
138 CU_ASSERT_DOUBLE_EQUAL(val, 0, 1.);
144 band->data.offline.mem = NULL;
164 CU_ASSERT(
data != NULL);
173 CU_ASSERT(
band != NULL);
182 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
187 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
211 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
217 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
238 CU_ASSERT(
data != NULL);
247 CU_ASSERT(
band != NULL);
255 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
261 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
267 CU_ASSERT_DOUBLE_EQUAL(val, 2, DBL_EPSILON);
273 CU_ASSERT_DOUBLE_EQUAL(val, 3, DBL_EPSILON);
297 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
303 CU_ASSERT_DOUBLE_EQUAL(val, 2, DBL_EPSILON);
309 CU_ASSERT_DOUBLE_EQUAL(val, 3, DBL_EPSILON);
330 CU_ASSERT(
data != NULL);
339 CU_ASSERT(
band != NULL);
347 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
353 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
359 CU_ASSERT_DOUBLE_EQUAL(val, 2, DBL_EPSILON);
365 CU_ASSERT_DOUBLE_EQUAL(val, 4, DBL_EPSILON);
371 CU_ASSERT_DOUBLE_EQUAL(val, 8, DBL_EPSILON);
377 CU_ASSERT_DOUBLE_EQUAL(val, 15, DBL_EPSILON);
397 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
403 CU_ASSERT_DOUBLE_EQUAL(val, 3, DBL_EPSILON);
409 CU_ASSERT_DOUBLE_EQUAL(val, 7, DBL_EPSILON);
415 CU_ASSERT_DOUBLE_EQUAL(val, 15, DBL_EPSILON);
436 CU_ASSERT(
data != NULL);
445 CU_ASSERT(
band != NULL);
453 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
459 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
465 CU_ASSERT_DOUBLE_EQUAL(val, 2, DBL_EPSILON);
471 CU_ASSERT_DOUBLE_EQUAL(val, 4, DBL_EPSILON);
477 CU_ASSERT_DOUBLE_EQUAL(val, 8, DBL_EPSILON);
483 CU_ASSERT_DOUBLE_EQUAL(val, 15, DBL_EPSILON);
489 CU_ASSERT_DOUBLE_EQUAL(val, 31, DBL_EPSILON);
495 CU_ASSERT_DOUBLE_EQUAL(val, 255, DBL_EPSILON);
511 CU_ASSERT_DOUBLE_EQUAL(val, 31, DBL_EPSILON);
517 CU_ASSERT_DOUBLE_EQUAL(val, 255, DBL_EPSILON);
523 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
544 CU_ASSERT(
data != NULL);
553 CU_ASSERT(
band != NULL);
561 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
567 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
573 CU_ASSERT_DOUBLE_EQUAL(val, 2, DBL_EPSILON);
579 CU_ASSERT_DOUBLE_EQUAL(val, 4, DBL_EPSILON);
585 CU_ASSERT_DOUBLE_EQUAL(val, 8, DBL_EPSILON);
591 CU_ASSERT_DOUBLE_EQUAL(val, 15, DBL_EPSILON);
597 CU_ASSERT_DOUBLE_EQUAL(val, 31, DBL_EPSILON);
603 CU_ASSERT_DOUBLE_EQUAL(val, -127, DBL_EPSILON);
609 CU_ASSERT_DOUBLE_EQUAL(val, 127, DBL_EPSILON);
637 CU_ASSERT_DOUBLE_EQUAL(val, 31, DBL_EPSILON);
643 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
649 CU_ASSERT_DOUBLE_EQUAL(val, -127, DBL_EPSILON);
655 CU_ASSERT_DOUBLE_EQUAL(val, 127, DBL_EPSILON);
676 CU_ASSERT(
data != NULL);
685 CU_ASSERT(
band != NULL);
693 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
699 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
705 CU_ASSERT_DOUBLE_EQUAL(val, 31, DBL_EPSILON);
711 CU_ASSERT_DOUBLE_EQUAL(val, 255, DBL_EPSILON);
717 CU_ASSERT_DOUBLE_EQUAL(val, 65535, DBL_EPSILON);
738 CU_ASSERT_DOUBLE_EQUAL(val, 255, DBL_EPSILON);
744 CU_ASSERT_DOUBLE_EQUAL(val, 65535, DBL_EPSILON);
765 CU_ASSERT(
data != NULL);
774 CU_ASSERT(
band != NULL);
782 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
788 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
794 CU_ASSERT_DOUBLE_EQUAL(val, 31, DBL_EPSILON);
800 CU_ASSERT_DOUBLE_EQUAL(val, 255, DBL_EPSILON);
806 CU_ASSERT_DOUBLE_EQUAL(val, -32767, DBL_EPSILON);
812 CU_ASSERT_DOUBLE_EQUAL(val, 32767, DBL_EPSILON);
844 CU_ASSERT_DOUBLE_EQUAL(val, 255, DBL_EPSILON);
850 CU_ASSERT_DOUBLE_EQUAL(val, -32767, DBL_EPSILON);
856 CU_ASSERT_DOUBLE_EQUAL(val, 32767, DBL_EPSILON);
877 CU_ASSERT(
data != NULL);
886 CU_ASSERT(
band != NULL);
894 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
900 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
906 CU_ASSERT_DOUBLE_EQUAL(val, 65535, DBL_EPSILON);
912 CU_ASSERT_DOUBLE_EQUAL(val, 4294967295UL, DBL_EPSILON);
934 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
940 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
946 CU_ASSERT_DOUBLE_EQUAL(val, 65535, DBL_EPSILON);
952 CU_ASSERT_DOUBLE_EQUAL(val, 4294967295UL, DBL_EPSILON);
973 CU_ASSERT(
data != NULL);
982 CU_ASSERT(
band != NULL);
990 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
996 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
1000 CU_ASSERT(!clamped);
1002 CU_ASSERT_DOUBLE_EQUAL(val, 65535, DBL_EPSILON);
1005 CU_ASSERT_EQUAL(err,
ES_NONE);
1006 CU_ASSERT(!clamped);
1009 CU_ASSERT_DOUBLE_EQUAL(val, 2147483647, DBL_EPSILON);
1013 CU_ASSERT_EQUAL(err,
ES_NONE);
1018 CU_ASSERT_EQUAL(err,
ES_NONE);
1028 CU_ASSERT_EQUAL(err,
ES_NONE);
1030 CU_ASSERT_EQUAL(err,
ES_NONE);
1031 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
1034 CU_ASSERT_EQUAL(err,
ES_NONE);
1036 CU_ASSERT_EQUAL(err,
ES_NONE);
1037 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
1040 CU_ASSERT_EQUAL(err,
ES_NONE);
1042 CU_ASSERT_EQUAL(err,
ES_NONE);
1043 CU_ASSERT_DOUBLE_EQUAL(val, 65535, DBL_EPSILON);
1046 CU_ASSERT_EQUAL(err,
ES_NONE);
1048 CU_ASSERT_EQUAL(err,
ES_NONE);
1049 CU_ASSERT_DOUBLE_EQUAL(val, 2147483647, DBL_EPSILON);
1070 CU_ASSERT(
data != NULL);
1079 CU_ASSERT(
band != NULL);
1084 CU_ASSERT_EQUAL(err,
ES_NONE);
1085 CU_ASSERT(!clamped);
1087 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
1090 CU_ASSERT_EQUAL(err,
ES_NONE);
1091 CU_ASSERT(!clamped);
1093 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
1096 CU_ASSERT_EQUAL(err,
ES_NONE);
1097 CU_ASSERT(!clamped);
1099 CU_ASSERT_DOUBLE_EQUAL(val, 65535.5, DBL_EPSILON);
1102 CU_ASSERT_EQUAL(err,
ES_NONE);
1103 CU_ASSERT(!clamped);
1105 CU_ASSERT_DOUBLE_EQUAL(val, 0.0060000000521540, DBL_EPSILON);
1110 CU_ASSERT_EQUAL(err,
ES_NONE);
1112 CU_ASSERT_EQUAL(err,
ES_NONE);
1113 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
1116 CU_ASSERT_EQUAL(err,
ES_NONE);
1118 CU_ASSERT_EQUAL(err,
ES_NONE);
1119 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
1122 CU_ASSERT_EQUAL(err,
ES_NONE);
1124 CU_ASSERT_EQUAL(err,
ES_NONE);
1125 CU_ASSERT_DOUBLE_EQUAL(val, 65535.5, DBL_EPSILON);
1128 CU_ASSERT_EQUAL(err,
ES_NONE);
1130 CU_ASSERT_EQUAL(err,
ES_NONE);
1131 CU_ASSERT_DOUBLE_EQUAL(val, 0.0060000000521540, DBL_EPSILON);
1152 CU_ASSERT(
data != NULL);
1161 CU_ASSERT(
band != NULL);
1166 CU_ASSERT_EQUAL(err,
ES_NONE);
1167 CU_ASSERT(!clamped);
1169 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
1172 CU_ASSERT_EQUAL(err,
ES_NONE);
1173 CU_ASSERT(!clamped);
1175 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
1178 CU_ASSERT_EQUAL(err,
ES_NONE);
1179 CU_ASSERT(!clamped);
1181 CU_ASSERT_DOUBLE_EQUAL(val, 65535.56, DBL_EPSILON);
1184 CU_ASSERT_EQUAL(err,
ES_NONE);
1185 CU_ASSERT(!clamped);
1187 CU_ASSERT_DOUBLE_EQUAL(val, 0.006, DBL_EPSILON);
1192 CU_ASSERT_EQUAL(err,
ES_NONE);
1194 CU_ASSERT_EQUAL(err,
ES_NONE);
1195 CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
1198 CU_ASSERT_EQUAL(err,
ES_NONE);
1200 CU_ASSERT_EQUAL(err,
ES_NONE);
1201 CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
1204 CU_ASSERT_EQUAL(err,
ES_NONE);
1206 CU_ASSERT_EQUAL(err,
ES_NONE);
1207 CU_ASSERT_DOUBLE_EQUAL(val, 65535.56, DBL_EPSILON);
1210 CU_ASSERT_EQUAL(err,
ES_NONE);
1212 CU_ASSERT_EQUAL(err,
ES_NONE);
1213 CU_ASSERT_DOUBLE_EQUAL(val, 0.006, DBL_EPSILON);
1232 CU_ASSERT(
rast != NULL);
1237 CU_ASSERT(
band != NULL);
1239 for (
y = 0;
y < maxY;
y++) {
1240 for (
x = 0;
x < maxX;
x++)
1245 CU_ASSERT_EQUAL(err,
ES_NONE);
1246 CU_ASSERT_EQUAL(nvals, maxX);
1247 CU_ASSERT_EQUAL(((int8_t *) vals)[3], 3);
1251 CU_ASSERT_EQUAL(err,
ES_NONE);
1252 CU_ASSERT_EQUAL(nvals, 1);
1253 CU_ASSERT_EQUAL(((int8_t *) vals)[0], 24);
1257 CU_ASSERT_NOT_EQUAL(err,
ES_NONE);
1266 char *path =
"../regress/loader/testraster.tif";
1276 CU_ASSERT(
band != NULL);
1286 CU_ASSERT_EQUAL(extband, 1);
1302 CU_pSuite suite = CU_add_suite(
"band_basics", NULL, NULL);
static void test_band_pixtype_32BF()
void band_basics_suite_setup(void)
static void test_band_pixtype_2BUI()
static void test_band_pixtype_32BUI()
static void test_band_pixtype_16BUI()
static void test_band_pixtype_4BUI()
static void test_band_new_offline_from_path()
static void test_band_pixtype_16BSI()
static void test_band_pixtype_1BB()
static void test_band_pixtype_8BSI()
static void test_band_pixtype_32BSI()
static void test_band_get_pixel_line()
static void test_band_metadata()
static void test_band_pixtype_64BF()
static void test_band_pixtype_8BUI()
#define PG_ADD_TEST(suite, testfunc)
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.
void rt_band_set_ownsdata_flag(rt_band band, int flag)
void * rtalloc(size_t size)
Wrappers used for managing memory.
uint16_t rt_band_get_width(rt_band band)
Return width of this band.
void rt_band_set_hasnodata_flag(rt_band band, int flag)
Set hasnodata flag value.
const char * rt_band_get_ext_path(rt_band band)
Return band's external path (only valid when rt_band_is_offline returns non-zero).
rt_errorstate rt_band_load_offline_data(rt_band band)
Load offline band's data.
void rt_raster_set_scale(rt_raster raster, double scaleX, double scaleY)
Set scale in projection units.
int rt_raster_add_band(rt_raster raster, rt_band band, int index)
Add band data to a raster.
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
int rt_band_get_isnodata_flag(rt_band band)
Get isnodata flag value.
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
uint64_t rt_band_get_file_size(rt_band band)
Return file size in bytes.
int rt_band_check_is_nodata(rt_band band)
Returns TRUE if the band is only nodata values.
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.
void rt_band_destroy(rt_band band)
Destroy a raster band.
rt_band rt_band_new_offline(uint16_t width, uint16_t height, rt_pixtype pixtype, uint32_t hasnodata, double nodataval, uint8_t bandNum, const char *path)
Create an out-db rt_band.
rt_errorstate rt_band_get_ext_band_num(rt_band band, uint8_t *bandnum)
Return bands' external band number (only valid when rt_band_is_offline returns non-zero).
uint64_t rt_band_get_file_timestamp(rt_band band)
Return file timestamp.
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
rt_pixtype rt_band_get_pixtype(rt_band band)
Return pixeltype of this band.
rt_band rt_band_new_offline_from_path(uint16_t width, uint16_t height, int hasnodata, double nodataval, uint8_t bandNum, const char *path, int force)
Create an out-db rt_band from path.
void rtdealloc(void *mem)
void * rt_band_get_data(rt_band band)
Get pointer to raster band data.
int rt_band_get_ownsdata_flag(rt_band band)
Return 0 (FALSE) or non-zero (TRUE) indicating if rt_band is responsible for managing the memory for ...
int rt_band_is_offline(rt_band band)
Return non-zero if the given band data is on the filesystem.
void rt_raster_set_offsets(rt_raster raster, double x, double y)
Set insertion points in projection units.
uint16_t rt_band_get_height(rt_band band)
Return height of this band.
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
rt_errorstate rt_band_get_pixel_line(rt_band band, int x, int y, uint16_t len, void **vals, uint16_t *nvals)
Get values of multiple pixels.
rt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)
void cu_free_raster(rt_raster raster)