PostGIS 3.6.2dev-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 0 on failure

Definition at line 275 of file rt_band.c.

280 {
281 rt_band band = NULL;
282 int pathlen = 0;
283
284 assert(NULL != path);
285
286 band = rtalloc(sizeof(struct rt_band_t));
287 if (band == NULL) {
288 rterror("rt_band_new_offline: Out of memory allocating rt_band");
289 return NULL;
290 }
291
292 RASTER_DEBUGF(3, "Created rt_band @ %p with pixtype %s",
293 band, rt_pixtype_name(pixtype)
294 );
295
296 band->pixtype = pixtype;
297 band->offline = 1;
298 band->width = width;
299 band->height = height;
300 band->hasnodata = hasnodata ? 1 : 0;
301 band->nodataval = 0;
302 band->isnodata = FALSE; /* we don't know if the offline band is NODATA */
303 band->ownsdata = 0; /* offline, flag is useless as all offline data cache is owned internally */
304 band->raster = NULL;
305
306 /* properly set nodataval as it may need to be constrained to the data type */
307 if (hasnodata && rt_band_set_nodata(band, nodataval, NULL) != ES_NONE) {
308 rterror("rt_band_new_offline: Could not set NODATA value");
309 rt_band_destroy(band);
310 return NULL;
311 }
312
313 band->data.offline.bandNum = bandNum;
314
315 /* memory for data.offline.path is managed internally */
316 pathlen = strlen(path);
317 band->data.offline.path = rtalloc(sizeof(char) * (pathlen + 1));
318 if (band->data.offline.path == NULL) {
319 rterror("rt_band_new_offline: Out of memory allocating offline path");
320 rt_band_destroy(band);
321 return NULL;
322 }
323 memcpy(band->data.offline.path, path, pathlen);
324 band->data.offline.path[pathlen] = '\0';
325
326 band->data.offline.mem = NULL;
327
328 return band;
329}
#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:306
const char * rt_pixtype_name(rt_pixtype pixtype)
Definition rt_pixel.c:110
@ 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:884
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition rt_band.c:491

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: