Return this raster in WKB form.
499 #if POSTGIS_DEBUG_LEVEL > 0
500 const uint8_t *wkbend = NULL;
509 assert(NULL != wkbsize);
511 RASTER_DEBUG(2,
"rt_raster_to_wkb: about to call rt_raster_wkb_size");
514 RASTER_DEBUGF(3,
"rt_raster_to_wkb: found size: %d", *wkbsize);
516 wkb = (uint8_t*)
rtalloc(*wkbsize);
518 rterror(
"rt_raster_to_wkb: Out of memory allocating WKB for raster");
524 #if POSTGIS_DEBUG_LEVEL > 2
525 wkbend = ptr + (*wkbsize);
527 RASTER_DEBUGF(3,
"Writing raster header to wkb on position %zu (expected 0)",
528 d_binptr_to_pos(ptr, wkbend, *wkbsize));
541 RASTER_DEBUGF(3,
"Writing bands header to wkb position %zu (expected 61)",
542 d_binptr_to_pos(ptr, wkbend, *wkbsize));
545 for (i = 0; i <
raster->numBands; ++i) {
551 RASTER_DEBUGF(3,
"Writing band pixel type to wkb position %zu",
552 d_binptr_to_pos(ptr, wkbend, *wkbsize));
555 rterror(
"rt_raster_to_wkb: Corrupted band: unknown pixtype");
561 *ptr =
band->pixtype;
571 memset(ptr,
'\0', pixbytes - 1);
575 assert(!(((uint64_t) ptr) % pixbytes));
579 d_binptr_to_pos(ptr, wkbend, *wkbsize));
587 uint8_t v =
band->nodataval;
593 int8_t v =
band->nodataval;
599 int16_t v =
band->nodataval;
605 uint16_t v =
band->nodataval;
611 int32_t v =
band->nodataval;
617 uint32_t v =
band->nodataval;
623 float v =
band->nodataval;
629 memcpy(ptr, &
band->nodataval, 8);
634 rterror(
"rt_raster_to_wkb: Fatal error caused by unknown pixel type. Aborting.");
643 assert(!((uint64_t) ptr % pixbytes));
646 if (!outasin &&
band->offline) {
648 *ptr =
band->data.offline.bandNum;
652 strcpy((
char*) ptr,
band->data.offline.path);
653 ptr += strlen(
band->data.offline.path) + 1;
657 uint32_t datasize =
raster->width *
raster->height * pixbytes;
658 RASTER_DEBUGF(4,
"rt_raster_to_wkb: Copying %d bytes", datasize);
668 while ((uint64_t) ptr % 8) {
674 assert(!((uint64_t) ptr % pixbytes));
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_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)