PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ test_band_get_pixel_line()

static void test_band_get_pixel_line ( )
static

Definition at line 1214 of file cu_band_basics.c.

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

1214  {
1215  rt_raster rast;
1216  rt_band band;
1217  int maxX = 5;
1218  int maxY = 5;
1219  int x = 0;
1220  int y = 0;
1221  void *vals = NULL;
1222  uint16_t nvals = 0;
1223  int err = 0;
1224 
1225  rast = rt_raster_new(maxX, maxY);
1226  CU_ASSERT(rast != NULL);
1227 
1228  rt_raster_set_scale(rast, 1, -1);
1229 
1230  band = cu_add_band(rast, PT_8BSI, 0, 0);
1231  CU_ASSERT(band != NULL);
1232 
1233  for (y = 0; y < maxY; y++) {
1234  for (x = 0; x < maxX; x++)
1235  rt_band_set_pixel(band, x, y, x + (y * maxX), NULL);
1236  }
1237 
1238  err = rt_band_get_pixel_line(band, 0, 0, maxX, &vals, &nvals);
1239  CU_ASSERT_EQUAL(err, ES_NONE);
1240  CU_ASSERT_EQUAL(nvals, maxX);
1241  CU_ASSERT_EQUAL(((int8_t *) vals)[3], 3);
1242  rtdealloc(vals);
1243 
1244  err = rt_band_get_pixel_line(band, 4, 4, maxX, &vals, &nvals);
1245  CU_ASSERT_EQUAL(err, ES_NONE);
1246  CU_ASSERT_EQUAL(nvals, 1);
1247  CU_ASSERT_EQUAL(((int8_t *) vals)[0], 24);
1248  rtdealloc(vals);
1249 
1250  err = rt_band_get_pixel_line(band, maxX, maxY, maxX, &vals, &nvals);
1251  CU_ASSERT_NOT_EQUAL(err, ES_NONE);
1252 
1253  cu_free_raster(rast);
1254 }
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:1089
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:926
Here is the call graph for this function:
Here is the caller graph for this function: