Set values of multiple pixels.
Unlike rt_band_set_pixel, values in vals are expected to be of the band's pixel type as this function uses memcpy.
It is important to be careful when using this function as the number of values being set may exceed a pixel "row". Remember that the band values are stored in a stream (1-D array) regardless of what the raster's width and height might be. So, setting a number of values may cross multiple pixel "rows".
- Parameters
-
band | : the band to set value to |
x | : X coordinate (0-based) |
y | : Y coordinate (0-based) |
vals | : the pixel values to apply |
len | : # of elements in vals |
- Returns
- ES_NONE on success, ES_ERROR on error
Definition at line 720 of file rt_band.c.
References ovdump::data, ES_ERROR, ES_NONE, rt_band_t::height, rt_band_t::offline, rt_band_t::pixtype, PT_16BSI, PT_16BUI, PT_1BB, PT_2BUI, PT_32BF, PT_32BSI, PT_32BUI, PT_4BUI, PT_64BF, PT_8BSI, PT_8BUI, PT_END, RASTER_DEBUGF, rt_band_get_data(), rt_band_get_hasnodata_flag(), rt_band_get_pixel(), rt_band_set_isnodata_flag(), rt_pixtype_size(), rterror(), genraster::value, and rt_band_t::width.
Referenced by RASTER_tile(), RASTER_union_transfn(), and rt_raster_from_gdal_dataset().
730 assert(NULL != band);
731 assert(vals != NULL && len > 0);
736 rterror(
"rt_band_set_pixel_line not implemented yet for OFFDB bands");
744 x < 0 || x >= band->
width ||
745 y < 0 || y >= band->
height 747 rterror(
"rt_band_set_pixel_line: Coordinates out of range (%d, %d) vs (%d, %d)",
x,
y, band->
width, band->
height);
752 offset =
x + (
y * band->
width);
757 rterror(
"rt_band_set_pixel_line: Could not apply pixels as values length exceeds end of data");
769 memcpy(ptr, vals, size * len);
773 uint16_t *ptr = (uint16_t *) data;
775 memcpy(ptr, vals, size * len);
779 int16_t *ptr = (int16_t *) data;
781 memcpy(ptr, vals, size * len);
787 memcpy(ptr, vals, size * len);
791 int32_t *ptr = (int32_t *) data;
793 memcpy(ptr, vals, size * len);
797 float *ptr = (
float *) data;
799 memcpy(ptr, vals, size * len);
803 double *ptr = (
double *) data;
805 memcpy(ptr, vals, size * len);
809 rterror(
"rt_band_set_pixel_line: Unknown pixeltype %d", pixtype);
814 #if POSTGIS_DEBUG_LEVEL > 0
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
#define RASTER_DEBUGF(level, msg,...)
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
rt_errorstate rt_band_set_isnodata_flag(rt_band band, int flag)
Set isnodata flag value.
void * rt_band_get_data(rt_band band)
Get pointer to raster band data.