54 rterror(
"rt_band_from_wkb: Out of memory allocating rt_band during WKB parsing");
60 rterror(
"rt_band_from_wkb: Premature end of WKB on band reading (%s:%d)",
78 band->height = height;
80 RASTER_DEBUGF(3,
" Band pixtype:%s, offline:%d, hasnodata:%d",
88 if (((*ptr) + pixbytes) >= end) {
89 rterror(
"rt_band_from_wkb: Premature end of WKB on band novalue reading");
95 switch (
band->pixtype) {
141 rterror(
"rt_band_from_wkb: Unknown pixeltype %d",
band->pixtype);
147 RASTER_DEBUGF(3,
" Nodata value: %g, pixbytes: %d, ptr @ %p, end @ %p",
148 band->nodataval, pixbytes, *ptr, end);
151 if (((*ptr) + 1) >= end) {
152 rterror(
"rt_band_from_wkb: Premature end of WKB on offline "
153 "band data bandNum reading (%s:%d)",
161 band->data.offline.mem = NULL;
166 while ((*ptr)[sz] && &((*ptr)[sz]) < end) ++sz;
167 if (&((*ptr)[sz]) >= end) {
168 rterror(
"rt_band_from_wkb: Premature end of WKB on band offline path reading");
177 if (
band->data.offline.path == NULL) {
178 rterror(
"rt_band_from_wkb: Out of memory allocating for offline path of band");
183 memcpy(
band->data.offline.path, *ptr, sz);
184 band->data.offline.path[sz] =
'\0';
187 band->data.offline.path, sz);
200 sz = (size_t)width * height * pixbytes;
201 if (((*ptr) + sz) > end) {
202 rterror(
"rt_band_from_wkb: Premature end of WKB on band data reading (%s:%d)",
209 if (!
band->data.mem) {
210 rterror(
"rt_band_from_wkb: Out of memory during band creation in WKB parser");
216 memcpy(
band->data.mem, *ptr, sz);
223 void (*flipper)(uint8_t*) = 0;
224 uint8_t *flipme = NULL;
228 else if (pixbytes == 4)
230 else if (pixbytes == 8)
233 rterror(
"rt_band_from_wkb: Unexpected pix bytes %d", pixbytes);
238 flipme =
band->data.mem;
239 sz = (size_t)width * height;
240 for (v = 0; v < sz; ++v) {
255 sz = (size_t)width*height;
256 for (v = 0; v < sz; ++v) {
257 val = ((uint8_t*)
band->data.mem)[v];
259 rterror(
"rt_band_from_wkb: Invalid value %d for pixel of type %s",
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.
#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