PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ rt_band_new_inline()

rt_band rt_band_new_inline ( uint16_t  width,
uint16_t  height,
rt_pixtype  pixtype,
uint32_t  hasnodata,
double  nodataval,
uint8_t data 
)

Create an in-db rt_band with no data.

Parameters
width: number of pixel columns
height: number of pixel rows
pixtype: pixel type for the band
hasnodata: indicates if the band has nodata value
nodataval: the nodata value, will be appropriately truncated to fit the pixtype size.
data: pointer to actual band data, required to be aligned accordingly to rt_pixtype_aligment(pixtype) and big enough to hold raster width*height values. Data will NOT be copied, ownership is left to caller which is responsible to keep it allocated for the whole lifetime of the returned rt_band.
Returns
an rt_band, or 0 on failure

Definition at line 63 of file rt_band.c.

References ovdump::band, ovdump::data, rt_band_t::data, ES_NONE, FALSE, rt_band_t::hasnodata, rt_band_t::height, rt_band_t::isnodata, rt_band_t::mem, rt_band_t::nodataval, rt_band_t::offline, rt_band_t::ownsdata, rt_band_t::pixtype, rt_band_t::raster, RASTER_DEBUGF, rt_band_destroy(), rt_band_set_nodata(), rt_pixtype_name(), rtalloc(), rterror(), and rt_band_t::width.

Referenced by cu_add_band(), rt_band_duplicate(), rt_band_reclass(), rt_raster_gdal_rasterize(), rt_raster_generate_new_band(), test_band_metadata(), test_band_pixtype_16BSI(), test_band_pixtype_16BUI(), test_band_pixtype_1BB(), test_band_pixtype_2BUI(), test_band_pixtype_32BF(), test_band_pixtype_32BSI(), test_band_pixtype_32BUI(), test_band_pixtype_4BUI(), test_band_pixtype_64BF(), test_band_pixtype_8BSI(), test_band_pixtype_8BUI(), and test_raster_replace_band().

68  {
69  rt_band band = NULL;
70 
71  assert(NULL != data);
72 
73  band = rtalloc(sizeof(struct rt_band_t));
74  if (band == NULL) {
75  rterror("rt_band_new_inline: Out of memory allocating rt_band");
76  return NULL;
77  }
78 
79  RASTER_DEBUGF(3, "Created rt_band @ %p with pixtype %s", band, rt_pixtype_name(pixtype));
80 
81  band->pixtype = pixtype;
82  band->offline = 0;
83  band->width = width;
84  band->height = height;
85  band->hasnodata = hasnodata ? 1 : 0;
86  band->isnodata = FALSE; /* we don't know what is in data, so must be FALSE */
87  band->nodataval = 0;
88  band->data.mem = data;
89  band->ownsdata = 0; /* we do NOT own this data!!! */
90  band->raster = NULL;
91 
92  RASTER_DEBUGF(3, "Created rt_band with dimensions %d x %d", band->width, band->height);
93 
94  /* properly set nodataval as it may need to be constrained to the data type */
95  if (hasnodata && rt_band_set_nodata(band, nodataval, NULL) != ES_NONE) {
96  rterror("rt_band_new_inline: Could not set NODATA value");
97  rt_band_destroy(band);
98  return NULL;
99  }
100 
101  return band;
102 }
rt_errorstate rt_band_set_nodata(rt_band band, double val, int *converted)
Set nodata value.
Definition: rt_band.c:733
rt_raster raster
Definition: librtcore.h:2324
rt_pixtype pixtype
Definition: librtcore.h:2314
band
Definition: ovdump.py:57
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
data
Definition: ovdump.py:103
uint16_t height
Definition: librtcore.h:2317
int8_t ownsdata
Definition: librtcore.h:2322
double nodataval
Definition: librtcore.h:2321
#define RASTER_DEBUGF(level, msg,...)
Definition: librtcore.h:299
uint16_t width
Definition: librtcore.h:2316
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition: rt_band.c:340
int32_t offline
Definition: librtcore.h:2315
int32_t isnodata
Definition: librtcore.h:2319
#define FALSE
Definition: dbfopen.c:168
const char * rt_pixtype_name(rt_pixtype pixtype)
Definition: rt_pixel.c:110
void * mem
Definition: librtcore.h:2327
int32_t hasnodata
Definition: librtcore.h:2318
union rt_band_t::@8 data
Here is the call graph for this function:
Here is the caller graph for this function: