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

◆ rt_raster_serialized_size()

static uint32_t rt_raster_serialized_size ( rt_raster  raster)
static

Definition at line 463 of file rt_serialize.c.

463 {
464 uint32_t size = sizeof (struct rt_raster_serialized_t);
465 uint16_t i = 0;
466
467 assert(NULL != raster);
468
469 RASTER_DEBUGF(3, "Serialized size with just header:%d - now adding size of %d bands",
470 size, raster->numBands);
471
472 for (i = 0; i < raster->numBands; ++i) {
473 rt_band band = raster->bands[i];
474 rt_pixtype pixtype = band->pixtype;
475 int pixbytes = rt_pixtype_size(pixtype);
476
477 if (pixbytes < 1) {
478 rterror("rt_raster_serialized_size: Corrupted band: unknown pixtype");
479 return 0;
480 }
481
482 /* Add space for band type, hasnodata flag and data padding */
483 size += pixbytes;
484
485 /* Add space for nodata value */
486 size += pixbytes;
487
488 if (band->offline) {
489 /* Add space for band number */
490 size += 1;
491
492 /* Add space for null-terminated path */
493 size += strlen(band->data.offline.path) + 1;
494 }
495 else {
496 /* Add space for raster band data */
497 size += pixbytes * raster->width * raster->height;
498 }
499
500 RASTER_DEBUGF(3, "Size before alignment is %d", size);
501
502 /* Align size to 8-bytes boundary (trailing padding) */
503 /* XXX jorgearevalo: bug here. If the size is actually 8-bytes aligned,
504 this line will add 8 bytes trailing padding, and it's not necessary */
505 /*size += 8 - (size % 8);*/
506 if (size % 8)
507 size += 8 - (size % 8);
508
509 RASTER_DEBUGF(3, "Size after alignment is %d", size);
510 }
511
512 return size;
513}
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
Struct definitions.
Definition librtcore.h:2452

References RASTER_DEBUGF, rt_pixtype_size(), rterror(), and rt_raster_serialized_t::size.

Referenced by rt_raster_serialize().

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