PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ rt_raster_serialized_size()

static uint32_t rt_raster_serialized_size ( rt_raster  raster)
static

Definition at line 462 of file rt_serialize.c.

462  {
463  uint32_t size = sizeof (struct rt_raster_serialized_t);
464  uint16_t i = 0;
465 
466  assert(NULL != raster);
467 
468  RASTER_DEBUGF(3, "Serialized size with just header:%d - now adding size of %d bands",
469  size, raster->numBands);
470 
471  for (i = 0; i < raster->numBands; ++i) {
472  rt_band band = raster->bands[i];
473  rt_pixtype pixtype = band->pixtype;
474  int pixbytes = rt_pixtype_size(pixtype);
475 
476  if (pixbytes < 1) {
477  rterror("rt_raster_serialized_size: Corrupted band: unknown pixtype");
478  return 0;
479  }
480 
481  /* Add space for band type, hasnodata flag and data padding */
482  size += pixbytes;
483 
484  /* Add space for nodata value */
485  size += pixbytes;
486 
487  if (band->offline) {
488  /* Add space for band number */
489  size += 1;
490 
491  /* Add space for null-terminated path */
492  size += strlen(band->data.offline.path) + 1;
493  }
494  else {
495  /* Add space for raster band data */
496  size += pixbytes * raster->width * raster->height;
497  }
498 
499  RASTER_DEBUGF(3, "Size before alignment is %d", size);
500 
501  /* Align size to 8-bytes boundary (trailing padding) */
502  /* XXX jorgearevalo: bug here. If the size is actually 8-bytes aligned,
503  this line will add 8 bytes trailing padding, and it's not necessary */
504  /*size += 8 - (size % 8);*/
505  if (size % 8)
506  size += 8 - (size % 8);
507 
508  RASTER_DEBUGF(3, "Size after alignment is %d", size);
509  }
510 
511  return size;
512 }
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
#define RASTER_DEBUGF(level, msg,...)
Definition: librtcore.h:299
rt_pixtype
Definition: librtcore.h:185
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
Definition: rt_pixel.c:39
band
Definition: ovdump.py:57
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
Struct definitions.
Definition: librtcore.h:2250
unsigned int uint32_t
Definition: uthash.h:78

References ovdump::band, rtrowdump::raster, RASTER_DEBUGF, rt_pixtype_size(), rterror(), and rt_raster_serialized_t::size.

Referenced by rt_raster_serialize().

Here is the call graph for this function:
Here is the caller graph for this function: