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.
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");
580 *ptr =
band->pixtype;
582 #ifdef POSTGIS_RASTER_DISABLE_OFFLINE
583 rterror(
"rt_raster_serialize: offdb raster support disabled at compile-time");
588 if (
band->hasnodata) {
592 if (
band->isnodata) {
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));
627 int8_t v =
band->nodataval;
633 int16_t v =
band->nodataval;
639 uint16_t v =
band->nodataval;
645 int32_t v =
band->nodataval;
657 float v =
band->nodataval;
663 memcpy(ptr, &
band->nodataval, 8);
668 rterror(
"rt_raster_serialize: Fatal error caused by unknown pixel type. Aborting.");
674 assert(!((ptr - ret) % pixbytes));
676 #if POSTGIS_DEBUG_LEVEL > 2
677 d_print_binary_hex(
"nodata", dbg_ptr,
size);
682 *ptr =
band->data.offline.bandNum;
686 strcpy((
char*) ptr,
band->data.offline.path);
687 ptr += strlen(
band->data.offline.path) + 1;
692 memcpy(ptr,
band->data.mem, datasize);
696 #if POSTGIS_DEBUG_LEVEL > 2
697 d_print_binary_hex(
"BAND", dbg_ptr,
size);
701 while ((ptr-ret) % 8) {
707 assert(!((ptr - ret) % pixbytes));
710 #if POSTGIS_DEBUG_LEVEL > 2
711 d_print_binary_hex(
"SERIALIZED RASTER", dbg_ptr,
size);
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)
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): ...
static uint32_t rt_raster_serialized_size(rt_raster raster)
#define BANDTYPE_FLAG_HASNODATA
#define BANDTYPE_FLAG_OFFDB
#define BANDTYPE_FLAG_ISNODATA
References ovdump::band, BANDTYPE_FLAG_HASNODATA, BANDTYPE_FLAG_ISNODATA, BANDTYPE_FLAG_OFFDB, PT_16BSI, PT_16BUI, PT_1BB, PT_2BUI, PT_32BF, PT_32BSI, PT_32BUI, PT_4BUI, PT_64BF, PT_8BSI, PT_8BUI, rtrowdump::raster, RASTER_DEBUG, RASTER_DEBUGF, rt_pixtype_size(), rt_raster_serialized_size(), rtalloc(), rtdealloc(), rterror(), and rt_raster_serialized_t::size.
Referenced by RASTER_addBand(), RASTER_addBandOutDB(), RASTER_addBandRasterArray(), RASTER_asRaster(), RASTER_band(), RASTER_clip(), RASTER_colorMap(), RASTER_copyBand(), RASTER_fromGDALRaster(), RASTER_fromHexWKB(), RASTER_fromWKB(), 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_setBandPath(), 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().