Return this raster in WKB form.
496 #if POSTGIS_DEBUG_LEVEL > 0
506 assert(NULL != wkbsize);
508 RASTER_DEBUG(2,
"rt_raster_to_wkb: about to call rt_raster_wkb_size");
511 RASTER_DEBUGF(3,
"rt_raster_to_wkb: found size: %d", *wkbsize);
515 rterror(
"rt_raster_to_wkb: Out of memory allocating WKB for raster");
521 #if POSTGIS_DEBUG_LEVEL > 2
522 wkbend = ptr + (*wkbsize);
524 RASTER_DEBUGF(3,
"Writing raster header to wkb on position %d (expected 0)",
525 d_binptr_to_pos(ptr, wkbend, *wkbsize));
538 RASTER_DEBUGF(3,
"Writing bands header to wkb position %d (expected 61)",
539 d_binptr_to_pos(ptr, wkbend, *wkbsize));
542 for (i = 0; i <
raster->numBands; ++i) {
548 RASTER_DEBUGF(3,
"Writing band pixel type to wkb position %d",
549 d_binptr_to_pos(ptr, wkbend, *wkbsize));
552 rterror(
"rt_raster_to_wkb: Corrupted band: unknown pixtype");
558 *ptr =
band->pixtype;
568 memset(ptr,
'\0', pixbytes - 1);
572 assert(!(((uint64_t) ptr) % pixbytes));
576 d_binptr_to_pos(ptr, wkbend, *wkbsize));
590 int8_t v =
band->nodataval;
596 int16_t v =
band->nodataval;
602 uint16_t v =
band->nodataval;
608 int32_t v =
band->nodataval;
620 float v =
band->nodataval;
626 memcpy(ptr, &
band->nodataval, 8);
631 rterror(
"rt_raster_to_wkb: Fatal error caused by unknown pixel type. Aborting.");
640 assert(!((uint64_t) ptr % pixbytes));
643 if (!outasin &&
band->offline) {
645 *ptr =
band->data.offline.bandNum;
649 strcpy((
char*) ptr,
band->data.offline.path);
650 ptr += strlen(
band->data.offline.path) + 1;
655 RASTER_DEBUGF(4,
"rt_raster_to_wkb: Copying %d bytes", datasize);
665 while ((uint64_t) ptr % 8) {
671 assert(!((uint64_t) ptr % pixbytes));
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
#define RASTER_DEBUG(level, msg)
#define RASTER_DEBUGF(level, msg,...)
void rtdealloc(void *mem)
void * rt_band_get_data(rt_band band)
Get pointer to raster band data.
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
uint8_t isMachineLittleEndian(void)
void write_uint16(uint8_t **to, uint8_t littleEndian, uint16_t v)
#define BANDTYPE_FLAG_HASNODATA
#define BANDTYPE_FLAG_OFFDB
#define BANDTYPE_FLAG_ISNODATA
static uint32_t rt_raster_wkb_size(rt_raster raster, int outasin)