PostGIS  2.1.10dev-r@@SVN_REVISION@@
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 1527 of file rt_api.c.

References ovdump::band, rt_band_t::data, ES_NONE, FALSE, rt_band_t::hasnodata, rt_band_t::height, rt_band_t::isnodata, 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 convert_raster(), RASTER_addBandOutDB(), RASTER_tile(), rt_band_duplicate(), and test_band_metadata().

1532  {
1533  rt_band band = NULL;
1534  int pathlen = 0;
1535 
1536  assert(NULL != path);
1537 
1538  band = rtalloc(sizeof(struct rt_band_t));
1539  if (band == NULL) {
1540  rterror("rt_band_new_offline: Out of memory allocating rt_band");
1541  return NULL;
1542  }
1543 
1544  RASTER_DEBUGF(3, "Created rt_band @ %p with pixtype %s",
1545  band, rt_pixtype_name(pixtype)
1546  );
1547 
1548  band->pixtype = pixtype;
1549  band->offline = 1;
1550  band->width = width;
1551  band->height = height;
1552  band->hasnodata = hasnodata ? 1 : 0;
1553  band->nodataval = 0;
1554  band->isnodata = FALSE; /* we don't know if the offline band is NODATA */
1555  band->ownsdata = 0; /* offline, flag is useless as all offline data cache is owned internally */
1556  band->raster = NULL;
1557 
1558  /* properly set nodataval as it may need to be constrained to the data type */
1559  if (hasnodata && rt_band_set_nodata(band, nodataval, NULL) != ES_NONE) {
1560  rterror("rt_band_new_offline: Could not set NODATA value");
1561  rt_band_destroy(band);
1562  return NULL;
1563  }
1564 
1565  band->data.offline.bandNum = bandNum;
1566 
1567  /* memory for data.offline.path is managed internally */
1568  pathlen = strlen(path);
1569  band->data.offline.path = rtalloc(sizeof(char) * (pathlen + 1));
1570  if (band->data.offline.path == NULL) {
1571  rterror("rt_band_new_offline: Out of memory allocating offline path");
1572  rt_band_destroy(band);
1573  return NULL;
1574  }
1575  memcpy(band->data.offline.path, path, pathlen);
1576  band->data.offline.path[pathlen] = '\0';
1577 
1578  band->data.offline.mem = NULL;
1579 
1580  return band;
1581 }
rt_errorstate rt_band_set_nodata(rt_band band, double val, int *converted)
Set nodata value.
Definition: rt_api.c:2061
const char * rt_pixtype_name(rt_pixtype pixtype)
Definition: rt_api.c:1168
rt_raster raster
Definition: rt_api.h:2249
rt_pixtype pixtype
Definition: rt_api.h:2239
tuple band
Definition: ovdump.py:57
uint16_t height
Definition: rt_api.h:2242
#define RASTER_DEBUGF(level, msg,...)
Definition: rt_api.h:285
int8_t ownsdata
Definition: rt_api.h:2247
double nodataval
Definition: rt_api.h:2246
uint16_t width
Definition: rt_api.h:2241
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition: rt_api.c:1650
union rt_band_t::@14 data
void * rtalloc(size_t size)
Raster core memory management functions.
Definition: rt_api.c:867
void rterror(const char *fmt,...)
Raster core error and info handlers.
Definition: rt_api.c:895
int32_t offline
Definition: rt_api.h:2240
int32_t isnodata
Definition: rt_api.h:2244
#define FALSE
Definition: dbfopen.c:169
int32_t hasnodata
Definition: rt_api.h:2243

Here is the call graph for this function:

Here is the caller graph for this function: