PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ rt_raster_wkb_size()

static uint32_t rt_raster_wkb_size ( rt_raster  raster,
int  outasin 
)
static

Definition at line 441 of file rt_wkb.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(), RT_WKB_HDR_SZ, rterror(), and rt_raster_t::width.

Referenced by rt_raster_to_wkb().

441  {
443  uint16_t i = 0;
444 
445  assert(NULL != raster);
446 
447  RASTER_DEBUGF(3, "rt_raster_wkb_size: computing size for %d bands",
448  raster->numBands);
449 
450  for (i = 0; i < raster->numBands; ++i) {
451  rt_band band = raster->bands[i];
452  rt_pixtype pixtype = band->pixtype;
453  int pixbytes = rt_pixtype_size(pixtype);
454 
455  RASTER_DEBUGF(3, "rt_raster_wkb_size: adding size of band %d", i);
456 
457  if (pixbytes < 1) {
458  rterror("rt_raster_wkb_size: Corrupted band: unknown pixtype");
459  return 0;
460  }
461 
462  /* Add space for band type */
463  size += 1;
464 
465  /* Add space for nodata value */
466  size += pixbytes;
467 
468  if (!outasin && band->offline) {
469  /* Add space for band number */
470  size += 1;
471 
472  /* Add space for null-terminated path */
473  size += strlen(band->data.offline.path) + 1;
474  }
475  else {
476  /* Add space for actual data */
477  size += pixbytes * raster->width * raster->height;
478  }
479  }
480 
481  return size;
482 }
#define RT_WKB_HDR_SZ
Definition: rt_wkb.c:273
uint16_t numBands
Definition: librtcore.h:2241
rt_pixtype pixtype
Definition: librtcore.h:2265
band
Definition: ovdump.py:57
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
rt_pixtype
Definition: librtcore.h:185
uint16_t height
Definition: librtcore.h:2253
unsigned int uint32_t
Definition: uthash.h:78
uint16_t width
Definition: librtcore.h:2252
union rt_band_t::@6 data
#define RASTER_DEBUGF(level, msg,...)
Definition: librtcore.h:299
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
Definition: rt_pixel.c:39
int32_t offline
Definition: librtcore.h:2266
rt_band * bands
Definition: librtcore.h:2254
Here is the call graph for this function:
Here is the caller graph for this function: