PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_band_pixtype_32BF()

static void test_band_pixtype_32BF ( )
static

Definition at line 1049 of file cu_band_basics.c.

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().

1049  {
1050  rt_pixtype pixtype = PT_32BF;
1051  uint8_t *data = NULL;
1052  rt_band band = NULL;
1053  int width = 5;
1054  int height = 5;
1055  int err = 0;
1056  int clamped = 0;
1057  double val = 0;
1058  int x;
1059  int y;
1060 
1061  /* inline band */
1062  data = rtalloc(rt_pixtype_size(pixtype) * width * height);
1063  CU_ASSERT(data != NULL);
1064  memset(data, 0, rt_pixtype_size(pixtype) * width * height);
1065 
1066  band = rt_band_new_inline(
1067  width, height,
1068  pixtype,
1069  0, 0,
1070  data
1071  );
1072  CU_ASSERT(band != NULL);
1073  rt_band_set_ownsdata_flag(band, 1);
1074  CU_ASSERT(rt_band_get_ownsdata_flag(band));
1075 
1076  err = rt_band_set_nodata(band, 1, &clamped);
1077  CU_ASSERT_EQUAL(err, ES_NONE);
1078  CU_ASSERT(!clamped);
1079  rt_band_get_nodata(band, &val);
1080  CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
1081 
1082  err = rt_band_set_nodata(band, 0, &clamped);
1083  CU_ASSERT_EQUAL(err, ES_NONE);
1084  CU_ASSERT(!clamped);
1085  rt_band_get_nodata(band, &val);
1086  CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
1087 
1088  err = rt_band_set_nodata(band, 65535.5, &clamped);
1089  CU_ASSERT_EQUAL(err, ES_NONE);
1090  CU_ASSERT(!clamped);
1091  rt_band_get_nodata(band, &val);
1092  CU_ASSERT_DOUBLE_EQUAL(val, 65535.5, DBL_EPSILON);
1093 
1094  err = rt_band_set_nodata(band, 0.006, &clamped);
1095  CU_ASSERT_EQUAL(err, ES_NONE);
1096  CU_ASSERT(!clamped);
1097  rt_band_get_nodata(band, &val);
1098  CU_ASSERT_DOUBLE_EQUAL(val, 0.0060000000521540, DBL_EPSILON);
1099 
1100  for (x=0; x<rt_band_get_width(band); ++x) {
1101  for (y=0; y<rt_band_get_height(band); ++y) {
1102  err = rt_band_set_pixel(band, x, y, 1, NULL);
1103  CU_ASSERT_EQUAL(err, ES_NONE);
1104  err = rt_band_get_pixel(band, x, y, &val, NULL);
1105  CU_ASSERT_EQUAL(err, ES_NONE);
1106  CU_ASSERT_DOUBLE_EQUAL(val, 1, DBL_EPSILON);
1107 
1108  err = rt_band_set_pixel(band, x, y, 0, NULL);
1109  CU_ASSERT_EQUAL(err, ES_NONE);
1110  err = rt_band_get_pixel(band, x, y, &val, NULL);
1111  CU_ASSERT_EQUAL(err, ES_NONE);
1112  CU_ASSERT_DOUBLE_EQUAL(val, 0, DBL_EPSILON);
1113 
1114  err = rt_band_set_pixel(band, x, y, 65535.5, NULL);
1115  CU_ASSERT_EQUAL(err, ES_NONE);
1116  err = rt_band_get_pixel(band, x, y, &val, NULL);
1117  CU_ASSERT_EQUAL(err, ES_NONE);
1118  CU_ASSERT_DOUBLE_EQUAL(val, 65535.5, DBL_EPSILON);
1119 
1120  err = rt_band_set_pixel(band, x, y, 0.006, NULL);
1121  CU_ASSERT_EQUAL(err, ES_NONE);
1122  err = rt_band_get_pixel(band, x, y, &val, NULL);
1123  CU_ASSERT_EQUAL(err, ES_NONE);
1124  CU_ASSERT_DOUBLE_EQUAL(val, 0.0060000000521540, DBL_EPSILON);
1125  }
1126  }
1127 
1128  rt_band_destroy(band);
1129 }
band
Definition: ovdump.py:57
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
data
Definition: ovdump.py:103
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
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&#39;s value.
Definition: rt_band.c:841
unsigned char uint8_t
Definition: uthash.h:79
Here is the call graph for this function:
Here is the caller graph for this function: