52 rterror(
"rt_band_from_wkb: Out of memory allocating rt_band during WKB parsing");
58 rterror(
"rt_band_from_wkb: Premature end of WKB on band reading (%s:%d)",
76 band->height = height;
78 RASTER_DEBUGF(3,
" Band pixtype:%s, offline:%d, hasnodata:%d",
86 if (((*ptr) + pixbytes) >= end) {
87 rterror(
"rt_band_from_wkb: Premature end of WKB on band novalue reading");
93 switch (
band->pixtype) {
139 rterror(
"rt_band_from_wkb: Unknown pixeltype %d",
band->pixtype);
145 RASTER_DEBUGF(3,
" Nodata value: %g, pixbytes: %d, ptr @ %p, end @ %p",
146 band->nodataval, pixbytes, *ptr, end);
149 if (((*ptr) + 1) >= end) {
150 rterror(
"rt_band_from_wkb: Premature end of WKB on offline "
151 "band data bandNum reading (%s:%d)",
159 band->data.offline.mem = NULL;
164 while ((*ptr)[sz] && &((*ptr)[sz]) < end) ++sz;
165 if (&((*ptr)[sz]) >= end) {
166 rterror(
"rt_band_from_wkb: Premature end of WKB on band offline path reading");
175 if (
band->data.offline.path == NULL) {
176 rterror(
"rt_band_from_wkb: Out of memory allocating for offline path of band");
181 memcpy(
band->data.offline.path, *ptr, sz);
182 band->data.offline.path[sz] =
'\0';
185 band->data.offline.path, sz);
198 sz = width * height * pixbytes;
199 if (((*ptr) + sz) > end) {
200 rterror(
"rt_band_from_wkb: Premature end of WKB on band data reading (%s:%d)",
207 if (!
band->data.mem) {
208 rterror(
"rt_band_from_wkb: Out of memory during band creation in WKB parser");
214 memcpy(
band->data.mem, *ptr, sz);
226 else if (pixbytes == 4)
228 else if (pixbytes == 8)
231 rterror(
"rt_band_from_wkb: Unexpected pix bytes %d", pixbytes);
236 flipme =
band->data.mem;
238 for (v = 0; v < sz; ++v) {
254 for (v = 0; v < sz; ++v) {
257 rterror(
"rt_band_from_wkb: Invalid value %d for pixel of type %s",
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
#define RASTER_DEBUGF(level, msg,...)
void rt_band_destroy(rt_band band)
Destroy a raster band.
const char * rt_pixtype_name(rt_pixtype pixtype)
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
uint8_t isMachineLittleEndian(void)
void flip_endian_32(uint8_t *d)
void flip_endian_16(uint8_t *d)
uint8_t read_uint8(const uint8_t **from)
double read_float64(const uint8_t **from, uint8_t littleEndian)
float read_float32(const uint8_t **from, uint8_t littleEndian)
void flip_endian_64(uint8_t *d)
int8_t read_int8(const uint8_t **from)
int16_t read_int16(const uint8_t **from, uint8_t littleEndian)
int32_t read_int32(const uint8_t **from, uint8_t littleEndian)
uint32_t read_uint32(const uint8_t **from, uint8_t littleEndian)
uint16_t read_uint16(const uint8_t **from, uint8_t littleEndian)
#define BANDTYPE_HAS_NODATA(x)
#define BANDTYPE_IS_OFFDB(x)
#define BANDTYPE_IS_NODATA(x)
#define BANDTYPE_PIXTYPE_MASK