Return this raster in WKB form.
- Parameters
-
raster | : the raster |
outasin | : if TRUE, out-db bands are treated as in-db |
wkbsize | : will be set to the size of returned wkb form |
- Returns
- WKB of raster or NULL on error
Definition at line 494 of file rt_wkb.c.
References ovdump::band, rt_raster_t::bands, BANDTYPE_FLAG_HASNODATA, BANDTYPE_FLAG_ISNODATA, BANDTYPE_FLAG_OFFDB, rt_band_t::data, rt_band_t::hasnodata, rt_raster_t::height, isMachineLittleEndian(), rt_band_t::isnodata, rt_band_t::nodataval, rt_raster_t::numBands, rt_band_t::offline, rt_band_t::pixtype, PT_16BSI, PT_16BUI, PT_1BB, PT_2BUI, PT_32BF, PT_32BSI, PT_32BUI, PT_4BUI, PT_64BF, PT_8BSI, PT_8BUI, RASTER_DEBUG, RASTER_DEBUGF, rt_band_get_data(), rt_pixtype_size(), rt_raster_wkb_size(), rtalloc(), rtdealloc(), rterror(), rt_raster_t::width, and write_uint16().
Referenced by RASTER_to_binary(), RASTER_to_bytea(), and rt_raster_to_hexwkb().
496 #if POSTGIS_DEBUG_LEVEL > 0 505 assert(NULL != raster);
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");
568 memset(ptr,
'\0', pixbytes - 1);
572 assert(!(((uint64_t) ptr) % pixbytes));
576 d_binptr_to_pos(ptr, wkbend, *wkbsize));
621 rterror(
"rt_raster_to_wkb: Fatal error caused by unknown pixel type. Aborting.");
630 assert(!((uint64_t) ptr % pixbytes));
633 if (!outasin && band->
offline) {
645 RASTER_DEBUGF(4,
"rt_raster_to_wkb: Copying %d bytes", datasize);
655 while ((uint64_t) ptr % 8) {
661 assert(!((uint64_t) ptr % pixbytes));
#define BANDTYPE_FLAG_HASNODATA
static uint32_t rt_raster_wkb_size(rt_raster raster, int outasin)
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
void write_uint16(uint8_t **to, uint8_t littleEndian, uint16_t v)
#define BANDTYPE_FLAG_OFFDB
void * rt_band_get_data(rt_band band)
Get pointer to raster band data.
#define RASTER_DEBUGF(level, msg,...)
uint8_t isMachineLittleEndian(void)
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
void rtdealloc(void *mem)
#define RASTER_DEBUG(level, msg)
#define BANDTYPE_FLAG_ISNODATA