PostGIS 3.7.0dev-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 449 of file rt_wkb.c.

449 {
450 uint32_t size = RT_WKB_HDR_SZ;
451 uint16_t i = 0;
452
453 assert(NULL != raster);
454
455 RASTER_DEBUGF(3, "rt_raster_wkb_size: computing size for %d bands",
456 raster->numBands);
457
458 for (i = 0; i < raster->numBands; ++i) {
459 rt_band band = raster->bands[i];
460 rt_pixtype pixtype = band->pixtype;
461 int pixbytes = rt_pixtype_size(pixtype);
462
463 RASTER_DEBUGF(3, "rt_raster_wkb_size: adding size of band %d", i);
464
465 if (pixbytes < 1) {
466 rterror("rt_raster_wkb_size: Corrupted band: unknown pixtype");
467 return 0;
468 }
469
470 /* Add space for band type */
471 size += 1;
472
473 /* Add space for nodata value */
474 size += pixbytes;
475
476 if (!outasin && band->offline) {
477 /* Add space for band number */
478 size += 1;
479
480 /* Add space for null-terminated path */
481 size += strlen(band->data.offline.path) + 1;
482 }
483 else {
484 /* Add space for actual data */
485 size += pixbytes * raster->width * raster->height;
486 }
487 }
488
489 return size;
490}
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
#define RASTER_DEBUGF(level, msg,...)
Definition librtcore.h:308
rt_pixtype
Definition librtcore.h:188
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
Definition rt_pixel.c:40
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition rtrowdump.py:125
#define RT_WKB_HDR_SZ
Definition rt_wkb.c:280

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: