PostGIS  3.0.6dev-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.

441  {
442  uint32_t size = RT_WKB_HDR_SZ;
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 }
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:58
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
#define RT_WKB_HDR_SZ
Definition: rt_wkb.c:273

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

Referenced by rt_raster_to_wkb().

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