PostGIS  2.5.0dev-r@@SVN_REVISION@@
static void test_band_pixtype_64BF ( )
static

Definition at line 1131 of file cu_band_basics.c.

References ovdump::band, ovdump::data, ES_NONE, PT_64BF, 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().

1131  {
1132  rt_pixtype pixtype = PT_64BF;
1133  uint8_t *data = NULL;
1134  rt_band band = NULL;
1135  int width = 5;
1136  int height = 5;
1137  int err = 0;
1138  int clamped = 0;
1139  double val = 0;
1140  int x;
1141  int y;
1142 
1143  /* inline band */
1144  data = rtalloc(rt_pixtype_size(pixtype) * width * height);
1145  CU_ASSERT(data != NULL);
1146  memset(data, 0, rt_pixtype_size(pixtype) * width * height);
1147 
1148  band = rt_band_new_inline(
1149  width, height,
1150  pixtype,
1151  0, 0,
1152  data
1153  );
1154  CU_ASSERT(band != NULL);
1155  rt_band_set_ownsdata_flag(band, 1);
1156  CU_ASSERT(rt_band_get_ownsdata_flag(band));
1157 
1158  err = rt_band_set_nodata(band, 1, &clamped);
1159  CU_ASSERT_EQUAL(err, ES_NONE);
1160  CU_ASSERT(!clamped);
1161  rt_band_get_nodata(band, &val);
1162  CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
1163 
1164  err = rt_band_set_nodata(band, 0, &clamped);
1165  CU_ASSERT_EQUAL(err, ES_NONE);
1166  CU_ASSERT(!clamped);
1167  rt_band_get_nodata(band, &val);
1168  CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
1169 
1170  err = rt_band_set_nodata(band, 65535.56, &clamped);
1171  CU_ASSERT_EQUAL(err, ES_NONE);
1172  CU_ASSERT(!clamped);
1173  rt_band_get_nodata(band, &val);
1174  CU_ASSERT_DOUBLE_EQUAL(val, 65535.56, DBL_EPSILON);
1175 
1176  err = rt_band_set_nodata(band, 0.006, &clamped);
1177  CU_ASSERT_EQUAL(err, ES_NONE);
1178  CU_ASSERT(!clamped);
1179  rt_band_get_nodata(band, &val);
1180  CU_ASSERT_DOUBLE_EQUAL(val, 0.006, DBL_EPSILON);
1181 
1182  for (x=0; x<rt_band_get_width(band); ++x) {
1183  for (y=0; y<rt_band_get_height(band); ++y) {
1184  err = rt_band_set_pixel(band, x, y, 1, NULL);
1185  CU_ASSERT_EQUAL(err, ES_NONE);
1186  err = rt_band_get_pixel(band, x, y, &val, NULL);
1187  CU_ASSERT_EQUAL(err, ES_NONE);
1188  CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
1189 
1190  err = rt_band_set_pixel(band, x, y, 0, NULL);
1191  CU_ASSERT_EQUAL(err, ES_NONE);
1192  err = rt_band_get_pixel(band, x, y, &val, NULL);
1193  CU_ASSERT_EQUAL(err, ES_NONE);
1194  CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
1195 
1196  err = rt_band_set_pixel(band, x, y, 65535.56, NULL);
1197  CU_ASSERT_EQUAL(err, ES_NONE);
1198  err = rt_band_get_pixel(band, x, y, &val, NULL);
1199  CU_ASSERT_EQUAL(err, ES_NONE);
1200  CU_ASSERT_DOUBLE_EQUAL(val, 65535.56, DBL_EPSILON);
1201 
1202  err = rt_band_set_pixel(band, x, y, 0.006, NULL);
1203  CU_ASSERT_EQUAL(err, ES_NONE);
1204  err = rt_band_get_pixel(band, x, y, &val, NULL);
1205  CU_ASSERT_EQUAL(err, ES_NONE);
1206  CU_ASSERT_DOUBLE_EQUAL(val, 0.006, DBL_EPSILON);
1207  }
1208  }
1209 
1210  rt_band_destroy(band);
1211 }
tuple data
Definition: ovdump.py:103
tuple band
Definition: ovdump.py:57
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
rt_errorstate rt_band_set_nodata(rt_band band, double val, int *converted)
Set nodata value.
Definition: rt_band.c:600
rt_pixtype
Definition: librtcore.h:185
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition: rt_band.c:242
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
Definition: rt_band.c:1597
void rt_band_set_ownsdata_flag(rt_band band, int flag)
Definition: rt_band.c:534
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:526
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
Definition: rt_band.c:1088
uint16_t rt_band_get_width(rt_band band)
Return width of this band.
Definition: rt_band.c:507
uint16_t rt_band_get_height(rt_band band)
Return height of this band.
Definition: rt_band.c:516
tuple x
Definition: pixval.py:53
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:58
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
Definition: rt_pixel.c:39
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:841
unsigned char uint8_t
Definition: uthash.h:79
tuple y
Definition: pixval.py:54

Here is the call graph for this function:

Here is the caller graph for this function: