359 const uint32_t width = 100;
360 const uint32_t height = 100;
364 double values[width][height];
368 GDALDriverH gddrv = NULL;
370 GDALDatasetH gdds = NULL;
373 CU_ASSERT(
raster != NULL);
376 CU_ASSERT(
band != NULL);
378 for (
x = 0;
x < width;
x++) {
379 for (
y = 0;
y < height;
y++) {
380 values[
x][
y] = (((double)
x *
y) + (
x +
y) + (
x +
y *
x)) / (
x +
y + 1);
386 CU_ASSERT(gddrv != NULL);
387 CU_ASSERT_EQUAL(destroy, 0);
388 CU_ASSERT(gdds != NULL);
389 CU_ASSERT_EQUAL((uint32_t)GDALGetRasterXSize(gdds), width);
390 CU_ASSERT_EQUAL((uint32_t)GDALGetRasterYSize(gdds), height);
393 CU_ASSERT(
rast != NULL);
397 CU_ASSERT(
band != NULL);
399 for (
x = 0;
x < width;
x++) {
400 for (
y = 0;
y < height;
y++) {
403 CU_ASSERT_DOUBLE_EQUAL(
value, values[
x][
y], DBL_EPSILON);
415 CU_ASSERT(
raster != NULL);
419 CU_ASSERT(
band != NULL);
422 for (
x = 0;
x < width;
x++) {
423 for (
y = 0;
y < height;
y++) {
432 CU_ASSERT(gddrv != NULL);
433 CU_ASSERT_EQUAL(destroy, 0);
434 CU_ASSERT(gdds != NULL);
435 CU_ASSERT_EQUAL((uint32_t)GDALGetRasterXSize(gdds), width);
436 CU_ASSERT_EQUAL((uint32_t)GDALGetRasterYSize(gdds), height);
439 CU_ASSERT(
rast != NULL);
443 CU_ASSERT(
band != NULL);
446 for (
x = 0;
x < width;
x++) {
447 for (
y = 0;
y < height;
y++) {
450 CU_ASSERT_DOUBLE_EQUAL(
value, values[
x][
y], 1.);
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
rt_raster rt_raster_from_gdal_dataset(GDALDatasetH ds)
Return a raster from a GDAL dataset.
rt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel's value.
uint16_t rt_raster_get_num_bands(rt_raster raster)
rt_pixtype rt_band_get_pixtype(rt_band band)
Return pixeltype of this band.
GDALDatasetH rt_raster_to_gdal_mem(rt_raster raster, const char *srs, uint32_t *bandNums, int *excludeNodataValues, int count, GDALDriverH *rtn_drv, int *destroy_rtn_drv)
Return GDAL dataset using GDAL MEM driver from raster.
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
rt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)
void cu_free_raster(rt_raster raster)