PostGIS  2.5.0dev-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 120 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_tile(), rt_band_duplicate(), rt_band_new_offline_from_path(), and test_band_metadata().

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