Return this raster in serialized form.
Memory (band data included) is copied from rt_raster.
Serialized form is documented in doc/RFC1-SerializedFormat.
Definition at line 521 of file rt_serialize.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, rt_band_t::isnodata, rt_band_t::mem, 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_pixtype_size(), rt_raster_serialized_size(), rtalloc(), rtdealloc(), rterror(), rt_raster_serialized_t::size, rt_raster_t::size, rt_raster_t::version, and rt_raster_t::width.
Referenced by RASTER_addBand(), RASTER_addBandOutDB(), RASTER_addBandRasterArray(), RASTER_asRaster(), RASTER_band(), RASTER_clip(), RASTER_colorMap(), RASTER_copyBand(), RASTER_fromGDALRaster(), RASTER_GDALWarp(), RASTER_in(), RASTER_makeEmpty(), RASTER_mapAlgebra2(), RASTER_mapAlgebraExpr(), RASTER_mapAlgebraFct(), RASTER_mapAlgebraFctNgb(), RASTER_nMapAlgebra(), RASTER_nMapAlgebraExpr(), RASTER_noop(), RASTER_reclass(), RASTER_setBandIsNoData(), RASTER_setBandNoDataValue(), RASTER_setGeotransform(), RASTER_setPixelValue(), RASTER_setPixelValuesArray(), RASTER_setPixelValuesGeomval(), RASTER_setRotation(), RASTER_setScale(), RASTER_setScaleXY(), RASTER_setSkew(), RASTER_setSkewXY(), RASTER_setSRID(), RASTER_setUpperLeftXY(), RASTER_tile(), RASTER_union_finalfn(), and test_raster_wkb().
527 assert(NULL != raster);
532 rterror(
"rt_raster_serialize: Out of memory allocating %d bytes for serializing a raster", size);
535 memset(ret,
'-', size);
542 RASTER_DEBUGF(3,
"serialized size:%lu", (
long unsigned) size);
557 RASTER_DEBUG(3,
"Start hex dump of raster being serialized using 0x2D to mark non-written bytes");
559 #if POSTGIS_DEBUG_LEVEL > 2 561 d_print_binary_hex(
"HEADER", dbg_ptr, size);
567 for (i = 0; i < raster->
numBands; ++i) {
569 assert(NULL != band);
574 rterror(
"rt_raster_serialize: Corrupted band: unknown pixtype");
582 #ifdef POSTGIS_RASTER_DISABLE_OFFLINE 583 rterror(
"rt_raster_serialize: offdb raster support disabled at compile-time");
596 #if POSTGIS_DEBUG_LEVEL > 2 597 d_print_binary_hex(
"PIXTYPE", dbg_ptr, size);
604 memset(ptr,
'\0', pixbytes - 1);
608 #if POSTGIS_DEBUG_LEVEL > 2 609 d_print_binary_hex(
"PADDING", dbg_ptr, size);
613 assert(!((ptr - ret) % pixbytes));
658 rterror(
"rt_raster_serialize: Fatal error caused by unknown pixel type. Aborting.");
664 assert(!((ptr - ret) % pixbytes));
666 #if POSTGIS_DEBUG_LEVEL > 2 667 d_print_binary_hex(
"nodata", dbg_ptr, size);
682 memcpy(ptr, band->
data.
mem, datasize);
686 #if POSTGIS_DEBUG_LEVEL > 2 687 d_print_binary_hex(
"BAND", dbg_ptr, size);
691 while ((uintptr_t) ptr % 8) {
699 assert(!((ptr - ret) % pixbytes));
702 #if POSTGIS_DEBUG_LEVEL > 2 703 d_print_binary_hex(
"SERIALIZED RASTER", dbg_ptr, size);
#define BANDTYPE_FLAG_HASNODATA
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
static uint32_t rt_raster_serialized_size(rt_raster raster)
#define BANDTYPE_FLAG_OFFDB
#define RASTER_DEBUGF(level, msg,...)
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