PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ test_band_get_pixel_line()

static void test_band_get_pixel_line ( )
static

Definition at line 1220 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().

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