PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_band_get_pixel_line()

static void test_band_get_pixel_line ( )
static

Definition at line 1213 of file cu_band_basics.c.

References ovdump::band, band_basics_suite_setup(), cu_add_band(), cu_free_raster(), ES_NONE, PT_8BSI, rtpixdump::rast, rt_band_get_pixel_line(), rt_band_set_pixel(), rt_raster_new(), rt_raster_set_scale(), rtdealloc(), pixval::x, and pixval::y.

Referenced by band_basics_suite_setup().

1213  {
1214  rt_raster rast;
1215  rt_band band;
1216  int maxX = 5;
1217  int maxY = 5;
1218  int x = 0;
1219  int y = 0;
1220  void *vals = NULL;
1221  uint16_t nvals = 0;
1222  int err = 0;
1223 
1224  rast = rt_raster_new(maxX, maxY);
1225  CU_ASSERT(rast != NULL);
1226 
1227  rt_raster_set_scale(rast, 1, -1);
1228 
1229  band = cu_add_band(rast, PT_8BSI, 0, 0);
1230  CU_ASSERT(band != NULL);
1231 
1232  for (y = 0; y < maxY; y++) {
1233  for (x = 0; x < maxX; x++)
1234  rt_band_set_pixel(band, x, y, x + (y * maxX), NULL);
1235  }
1236 
1237  err = rt_band_get_pixel_line(band, 0, 0, maxX, &vals, &nvals);
1238  CU_ASSERT_EQUAL(err, ES_NONE);
1239  CU_ASSERT_EQUAL(nvals, maxX);
1240  CU_ASSERT_EQUAL(((int8_t *) vals)[3], 3);
1241  rtdealloc(vals);
1242 
1243  err = rt_band_get_pixel_line(band, 4, 4, maxX, &vals, &nvals);
1244  CU_ASSERT_EQUAL(err, ES_NONE);
1245  CU_ASSERT_EQUAL(nvals, 1);
1246  CU_ASSERT_EQUAL(((int8_t *) vals)[0], 24);
1247  rtdealloc(vals);
1248 
1249  err = rt_band_get_pixel_line(band, maxX, maxY, maxX, &vals, &nvals);
1250  CU_ASSERT_NOT_EQUAL(err, ES_NONE);
1251 
1252  cu_free_raster(rast);
1253 }
band
Definition: ovdump.py:57
void cu_free_raster(rt_raster raster)
rt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)
void rt_raster_set_scale(rt_raster raster, double scaleX, double scaleY)
Set scale in projection units.
Definition: rt_raster.c:137
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.
Definition: rt_band.c:1004
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_raster.c:48
void rtdealloc(void *mem)
Definition: rt_context.c:186
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
Here is the call graph for this function:
Here is the caller graph for this function: