PostGIS  2.1.10dev-r@@SVN_REVISION@@
static uint32_t rt_raster_serialized_size ( rt_raster  raster)
static

Definition at line 8099 of file rt_api.c.

References ovdump::band, rt_raster_t::bands, rt_band_t::data, rt_raster_t::height, rt_raster_t::numBands, rt_band_t::offline, rt_band_t::pixtype, RASTER_DEBUGF, rt_pixtype_size(), rterror(), rt_raster_serialized_t::size, and rt_raster_t::width.

Referenced by rt_raster_serialize().

8099  {
8100  uint32_t size = sizeof (struct rt_raster_serialized_t);
8101  uint16_t i = 0;
8102 
8103  assert(NULL != raster);
8104 
8105  RASTER_DEBUGF(3, "Serialized size with just header:%d - now adding size of %d bands",
8106  size, raster->numBands);
8107 
8108  for (i = 0; i < raster->numBands; ++i) {
8109  rt_band band = raster->bands[i];
8110  rt_pixtype pixtype = band->pixtype;
8111  int pixbytes = rt_pixtype_size(pixtype);
8112 
8113  if (pixbytes < 1) {
8114  rterror("rt_raster_serialized_size: Corrupted band: unknown pixtype");
8115  return 0;
8116  }
8117 
8118  /* Add space for band type, hasnodata flag and data padding */
8119  size += pixbytes;
8120 
8121  /* Add space for nodata value */
8122  size += pixbytes;
8123 
8124  if (band->offline) {
8125  /* Add space for band number */
8126  size += 1;
8127 
8128  /* Add space for null-terminated path */
8129  size += strlen(band->data.offline.path) + 1;
8130  }
8131  else {
8132  /* Add space for raster band data */
8133  size += pixbytes * raster->width * raster->height;
8134  }
8135 
8136  RASTER_DEBUGF(3, "Size before alignment is %d", size);
8137 
8138  /* Align size to 8-bytes boundary (trailing padding) */
8139  /* XXX jorgearevalo: bug here. If the size is actually 8-bytes aligned,
8140  this line will add 8 bytes trailing padding, and it's not necessary */
8141  /*size += 8 - (size % 8);*/
8142  if (size % 8)
8143  size += 8 - (size % 8);
8144 
8145  RASTER_DEBUGF(3, "Size after alignment is %d", size);
8146  }
8147 
8148  return size;
8149 }
uint16_t numBands
Definition: rt_api.h:2215
rt_pixtype pixtype
Definition: rt_api.h:2239
tuple band
Definition: ovdump.py:57
uint16_t height
Definition: rt_api.h:2227
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
Definition: rt_api.c:1097
rt_pixtype
Definition: rt_api.h:172
#define RASTER_DEBUGF(level, msg,...)
Definition: rt_api.h:285
uint16_t width
Definition: rt_api.h:2226
union rt_band_t::@14 data
void rterror(const char *fmt,...)
Raster core error and info handlers.
Definition: rt_api.c:895
int32_t offline
Definition: rt_api.h:2240
Struct definitions.
Definition: rt_api.h:2175
rt_band * bands
Definition: rt_api.h:2228

Here is the call graph for this function:

Here is the caller graph for this function: