PostGIS  2.1.10dev-r@@SVN_REVISION@@
static uint32_t rt_raster_wkb_size ( rt_raster  raster,
int  outasin 
)
static

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

Referenced by rt_raster_to_wkb().

7834  {
7835  uint32_t size = RT_WKB_HDR_SZ;
7836  uint16_t i = 0;
7837 
7838  assert(NULL != raster);
7839 
7840  RASTER_DEBUGF(3, "rt_raster_wkb_size: computing size for %d bands",
7841  raster->numBands);
7842 
7843  for (i = 0; i < raster->numBands; ++i) {
7844  rt_band band = raster->bands[i];
7845  rt_pixtype pixtype = band->pixtype;
7846  int pixbytes = rt_pixtype_size(pixtype);
7847 
7848  RASTER_DEBUGF(3, "rt_raster_wkb_size: adding size of band %d", i);
7849 
7850  if (pixbytes < 1) {
7851  rterror("rt_raster_wkb_size: Corrupted band: unknown pixtype");
7852  return 0;
7853  }
7854 
7855  /* Add space for band type */
7856  size += 1;
7857 
7858  /* Add space for nodata value */
7859  size += pixbytes;
7860 
7861  if (!outasin && band->offline) {
7862  /* Add space for band number */
7863  size += 1;
7864 
7865  /* Add space for null-terminated path */
7866  size += strlen(band->data.offline.path) + 1;
7867  }
7868  else {
7869  /* Add space for actual data */
7870  size += pixbytes * raster->width * raster->height;
7871  }
7872  }
7873 
7874  return size;
7875 }
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
#define RT_WKB_HDR_SZ
Definition: rt_api.c:7666
int32_t offline
Definition: rt_api.h:2240
rt_band * bands
Definition: rt_api.h:2228

Here is the call graph for this function:

Here is the caller graph for this function: