PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ 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 119 of file rt_band.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().

124  {
125  rt_band band = NULL;
126  int pathlen = 0;
127 
128  assert(NULL != path);
129 
130  band = rtalloc(sizeof(struct rt_band_t));
131  if (band == NULL) {
132  rterror("rt_band_new_offline: Out of memory allocating rt_band");
133  return NULL;
134  }
135 
136  RASTER_DEBUGF(3, "Created rt_band @ %p with pixtype %s",
137  band, rt_pixtype_name(pixtype)
138  );
139 
140  band->pixtype = pixtype;
141  band->offline = 1;
142  band->width = width;
143  band->height = height;
144  band->hasnodata = hasnodata ? 1 : 0;
145  band->nodataval = 0;
146  band->isnodata = FALSE; /* we don't know if the offline band is NODATA */
147  band->ownsdata = 0; /* offline, flag is useless as all offline data cache is owned internally */
148  band->raster = NULL;
149 
150  /* properly set nodataval as it may need to be constrained to the data type */
151  if (hasnodata && rt_band_set_nodata(band, nodataval, NULL) != ES_NONE) {
152  rterror("rt_band_new_offline: Could not set NODATA value");
153  rt_band_destroy(band);
154  return NULL;
155  }
156 
157  band->data.offline.bandNum = bandNum;
158 
159  /* memory for data.offline.path is managed internally */
160  pathlen = strlen(path);
161  band->data.offline.path = rtalloc(sizeof(char) * (pathlen + 1));
162  if (band->data.offline.path == NULL) {
163  rterror("rt_band_new_offline: Out of memory allocating offline path");
164  rt_band_destroy(band);
165  return NULL;
166  }
167  memcpy(band->data.offline.path, path, pathlen);
168  band->data.offline.path[pathlen] = '\0';
169 
170  band->data.offline.mem = NULL;
171 
172  return band;
173 }
rt_errorstate rt_band_set_nodata(rt_band band, double val, int *converted)
Set nodata value.
Definition: rt_band.c:600
rt_raster raster
Definition: librtcore.h:2275
rt_pixtype pixtype
Definition: librtcore.h:2265
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
uint16_t height
Definition: librtcore.h:2268
union rt_band_t::@6 data
int8_t ownsdata
Definition: librtcore.h:2273
double nodataval
Definition: librtcore.h:2272
#define RASTER_DEBUGF(level, msg,...)
Definition: librtcore.h:299
uint16_t width
Definition: librtcore.h:2267
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition: rt_band.c:242
int32_t offline
Definition: librtcore.h:2266
int32_t isnodata
Definition: librtcore.h:2270
#define FALSE
Definition: dbfopen.c:168
const char * rt_pixtype_name(rt_pixtype pixtype)
Definition: rt_pixel.c:110
int32_t hasnodata
Definition: librtcore.h:2269
Here is the call graph for this function:
Here is the caller graph for this function: