PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_band_pixtype_32BF()

static void test_band_pixtype_32BF ( )
static

Definition at line 1056 of file cu_band_basics.c.

1056  {
1057  rt_pixtype pixtype = PT_32BF;
1058  uint8_t *data = NULL;
1059  rt_band band = NULL;
1060  int width = 5;
1061  int height = 5;
1062  int err = 0;
1063  int clamped = 0;
1064  double val = 0;
1065  int x;
1066  int y;
1067 
1068  /* inline band */
1069  data = rtalloc(rt_pixtype_size(pixtype) * width * height);
1070  CU_ASSERT(data != NULL);
1071  memset(data, 0, rt_pixtype_size(pixtype) * width * height);
1072 
1074  width, height,
1075  pixtype,
1076  0, 0,
1077  data
1078  );
1079  CU_ASSERT(band != NULL);
1081  CU_ASSERT(rt_band_get_ownsdata_flag(band));
1082 
1083  err = rt_band_set_nodata(band, 1, &clamped);
1084  CU_ASSERT_EQUAL(err, ES_NONE);
1085  CU_ASSERT(!clamped);
1086  rt_band_get_nodata(band, &val);
1087  CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
1088 
1089  err = rt_band_set_nodata(band, 0, &clamped);
1090  CU_ASSERT_EQUAL(err, ES_NONE);
1091  CU_ASSERT(!clamped);
1092  rt_band_get_nodata(band, &val);
1093  CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
1094 
1095  err = rt_band_set_nodata(band, 65535.5, &clamped);
1096  CU_ASSERT_EQUAL(err, ES_NONE);
1097  CU_ASSERT(!clamped);
1098  rt_band_get_nodata(band, &val);
1099  CU_ASSERT_DOUBLE_EQUAL(val, 65535.5, DBL_EPSILON);
1100 
1101  err = rt_band_set_nodata(band, 0.006, &clamped);
1102  CU_ASSERT_EQUAL(err, ES_NONE);
1103  CU_ASSERT(!clamped);
1104  rt_band_get_nodata(band, &val);
1105  CU_ASSERT_DOUBLE_EQUAL(val, 0.0060000000521540, DBL_EPSILON);
1106 
1107  for (x=0; x<rt_band_get_width(band); ++x) {
1108  for (y=0; y<rt_band_get_height(band); ++y) {
1109  err = rt_band_set_pixel(band, x, y, 1, NULL);
1110  CU_ASSERT_EQUAL(err, ES_NONE);
1111  err = rt_band_get_pixel(band, x, y, &val, NULL);
1112  CU_ASSERT_EQUAL(err, ES_NONE);
1113  CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
1114 
1115  err = rt_band_set_pixel(band, x, y, 0, NULL);
1116  CU_ASSERT_EQUAL(err, ES_NONE);
1117  err = rt_band_get_pixel(band, x, y, &val, NULL);
1118  CU_ASSERT_EQUAL(err, ES_NONE);
1119  CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
1120 
1121  err = rt_band_set_pixel(band, x, y, 65535.5, NULL);
1122  CU_ASSERT_EQUAL(err, ES_NONE);
1123  err = rt_band_get_pixel(band, x, y, &val, NULL);
1124  CU_ASSERT_EQUAL(err, ES_NONE);
1125  CU_ASSERT_DOUBLE_EQUAL(val, 65535.5, DBL_EPSILON);
1126 
1127  err = rt_band_set_pixel(band, x, y, 0.006, NULL);
1128  CU_ASSERT_EQUAL(err, ES_NONE);
1129  err = rt_band_get_pixel(band, x, y, &val, NULL);
1130  CU_ASSERT_EQUAL(err, ES_NONE);
1131  CU_ASSERT_DOUBLE_EQUAL(val, 0.0060000000521540, DBL_EPSILON);
1132  }
1133  }
1134 
1136 }
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.
Definition: rt_band.c:63
void rt_band_set_ownsdata_flag(rt_band band, int flag)
Definition: rt_band.c:667
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
uint16_t rt_band_get_width(rt_band band)
Return width of this band.
Definition: rt_band.c:640
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
Definition: rt_band.c:1221
rt_pixtype
Definition: librtcore.h:185
@ PT_32BF
Definition: librtcore.h:195
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
@ ES_NONE
Definition: librtcore.h:180
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition: rt_band.c:340
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
Definition: rt_band.c:1730
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 ...
Definition: rt_band.c:659
uint16_t rt_band_get_height(rt_band band)
Return height of this band.
Definition: rt_band.c:649
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
Definition: rt_pixel.c:39
band
Definition: ovdump.py:57
data
Definition: ovdump.py:103
unsigned char uint8_t
Definition: uthash.h:79

References ovdump::band, ovdump::data, ES_NONE, PT_32BF, rt_band_destroy(), rt_band_get_height(), rt_band_get_nodata(), rt_band_get_ownsdata_flag(), rt_band_get_pixel(), rt_band_get_width(), rt_band_new_inline(), rt_band_set_nodata(), rt_band_set_ownsdata_flag(), rt_band_set_pixel(), rt_pixtype_size(), rtalloc(), pixval::x, and pixval::y.

Referenced by band_basics_suite_setup().

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