440 double values[width][height];
444 GDALDriverH gddrv = NULL;
446 GDALDatasetH gdds = NULL;
449 CU_ASSERT(
raster != NULL);
452 CU_ASSERT(
band != NULL);
454 for (
x = 0;
x < width;
x++) {
455 for (
y = 0;
y < height;
y++) {
456 values[
x][
y] = (((double)
x *
y) + (
x +
y) + (
x +
y *
x)) / (
x +
y + 1);
462 CU_ASSERT(gddrv != NULL);
463 CU_ASSERT_EQUAL(destroy, 0);
464 CU_ASSERT(gdds != NULL);
465 CU_ASSERT_EQUAL((
uint32_t)GDALGetRasterXSize(gdds), width);
466 CU_ASSERT_EQUAL((
uint32_t)GDALGetRasterYSize(gdds), height);
469 CU_ASSERT(
rast != NULL);
473 CU_ASSERT(
band != NULL);
475 for (
x = 0;
x < width;
x++) {
476 for (
y = 0;
y < height;
y++) {
479 CU_ASSERT_DOUBLE_EQUAL(
value, values[
x][
y], DBL_EPSILON);
491 CU_ASSERT(
raster != NULL);
495 CU_ASSERT(
band != NULL);
498 for (
x = 0;
x < width;
x++) {
499 for (
y = 0;
y < height;
y++) {
508 CU_ASSERT(gddrv != NULL);
509 CU_ASSERT_EQUAL(destroy, 0);
510 CU_ASSERT(gdds != NULL);
511 CU_ASSERT_EQUAL((
uint32_t)GDALGetRasterXSize(gdds), width);
512 CU_ASSERT_EQUAL((
uint32_t)GDALGetRasterYSize(gdds), height);
515 CU_ASSERT(
rast != NULL);
519 CU_ASSERT(
band != NULL);
522 for (
x = 0;
x < width;
x++) {
523 for (
y = 0;
y < height;
y++) {
526 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)