PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ rt_band_new_offline()

rt_band rt_band_new_offline ( uint16_t  width,
uint16_t  height,
rt_pixtype  pixtype,
uint32_t  hasnodata,
double  nodataval,
uint8_t  bandNum,
const char *  path 
)

Create an out-db rt_band.

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.
bandNum: 0-based band number in the external file to associate this band with.
path: NULL-terminated path string pointing to the file containing band data. The string 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 NULL on failure
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.
bandNum: 0-based band number in the external file to associate this band with.
path: NULL-terminated path string pointing to the file containing band data. The string 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 283 of file rt_band.c.

288 {
289 rt_band band = NULL;
290 int pathlen = 0;
291
292 assert(NULL != path);
293
294 band = rtalloc(sizeof(struct rt_band_t));
295 if (band == NULL) {
296 rterror("rt_band_new_offline: Out of memory allocating rt_band");
297 return NULL;
298 }
299
300 RASTER_DEBUGF(3, "Created rt_band @ %p with pixtype %s",
301 band, rt_pixtype_name(pixtype)
302 );
303
304 band->pixtype = pixtype;
305 band->offline = 1;
306 band->width = width;
307 band->height = height;
308 band->hasnodata = hasnodata ? 1 : 0;
309 band->nodataval = 0;
310 band->isnodata = FALSE; /* we don't know if the offline band is NODATA */
311 band->ownsdata = 0; /* offline, flag is useless as all offline data cache is owned internally */
312 band->raster = NULL;
313
314 /* properly set nodataval as it may need to be constrained to the data type */
315 if (hasnodata && rt_band_set_nodata(band, nodataval, NULL) != ES_NONE) {
316 rterror("rt_band_new_offline: Could not set NODATA value");
317 rt_band_destroy(band);
318 return NULL;
319 }
320
321 band->data.offline.bandNum = bandNum;
322
323 /* memory for data.offline.path is managed internally */
324 pathlen = strlen(path);
325 band->data.offline.path = rtalloc(sizeof(char) * (pathlen + 1));
326 if (band->data.offline.path == NULL) {
327 rterror("rt_band_new_offline: Out of memory allocating offline path");
328 rt_band_destroy(band);
329 return NULL;
330 }
331 memcpy(band->data.offline.path, path, pathlen);
332 band->data.offline.path[pathlen] = '\0';
333
334 band->data.offline.mem = NULL;
335
336 return band;
337}
#define FALSE
Definition dbfopen.c:72
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition rt_context.c:191
#define RASTER_DEBUGF(level, msg,...)
Definition librtcore.h:308
const char * rt_pixtype_name(rt_pixtype pixtype)
Definition rt_pixel.c:114
@ ES_NONE
Definition librtcore.h:182
rt_errorstate rt_band_set_nodata(rt_band band, double val, int *converted)
Set nodata value.
Definition rt_band.c:892
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition rt_band.c:499

References ES_NONE, FALSE, RASTER_DEBUGF, rt_band_destroy(), rt_band_set_nodata(), rt_pixtype_name(), rtalloc(), and rterror().

Referenced by convert_raster(), RASTER_tile(), rt_band_duplicate(), rt_band_new_offline_from_path(), and test_band_metadata().

Here is the call graph for this function:
Here is the caller graph for this function: