PostGIS 3.6.2dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ rt_raster_wkb_size()

static uint32_t rt_raster_wkb_size ( rt_raster  raster,
int  outasin 
)
static

Definition at line 444 of file rt_wkb.c.

444 {
445 uint32_t size = RT_WKB_HDR_SZ;
446 uint16_t i = 0;
447
448 assert(NULL != raster);
449
450 RASTER_DEBUGF(3, "rt_raster_wkb_size: computing size for %d bands",
451 raster->numBands);
452
453 for (i = 0; i < raster->numBands; ++i) {
454 rt_band band = raster->bands[i];
455 rt_pixtype pixtype = band->pixtype;
456 int pixbytes = rt_pixtype_size(pixtype);
457
458 RASTER_DEBUGF(3, "rt_raster_wkb_size: adding size of band %d", i);
459
460 if (pixbytes < 1) {
461 rterror("rt_raster_wkb_size: Corrupted band: unknown pixtype");
462 return 0;
463 }
464
465 /* Add space for band type */
466 size += 1;
467
468 /* Add space for nodata value */
469 size += pixbytes;
470
471 if (!outasin && band->offline) {
472 /* Add space for band number */
473 size += 1;
474
475 /* Add space for null-terminated path */
476 size += strlen(band->data.offline.path) + 1;
477 }
478 else {
479 /* Add space for actual data */
480 size += pixbytes * raster->width * raster->height;
481 }
482 }
483
484 return size;
485}
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
#define RASTER_DEBUGF(level, msg,...)
Definition librtcore.h:306
rt_pixtype
Definition librtcore.h:187
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
Definition rt_pixel.c:39
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:275

References 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: