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

◆ rt_raster_to_hexwkb()

char * rt_raster_to_hexwkb ( rt_raster  raster,
int  outasin,
uint32_t *  hexwkbsize 
)

Return this raster in HEXWKB form (null-terminated hex)

Parameters
raster: the raster
outasin: if TRUE, out-db bands are treated as in-db
hexwkbsize: will be set to the size of returned wkb form, not including the null termination
Returns
HEXWKB of raster or NULL on error

Definition at line 693 of file rt_wkb.c.

693 {
694 uint8_t *wkb = NULL;
695 char* hexwkb = NULL;
696 uint32_t wkbsize = 0;
697
698 assert(NULL != raster);
699 assert(NULL != hexwkbsize);
700
701 RASTER_DEBUG(2, "rt_raster_to_hexwkb: calling rt_raster_to_wkb");
702
703 wkb = rt_raster_to_wkb(raster, outasin, &wkbsize);
704
705 RASTER_DEBUG(3, "rt_raster_to_hexwkb: rt_raster_to_wkb returned");
706
707 *hexwkbsize = wkbsize * 2; /* hex is 2 times bytes */
708 hexwkb = (char*) rtalloc((*hexwkbsize) + 1);
709 if (!hexwkb) {
710 rterror("rt_raster_to_hexwkb: Out of memory hexifying raster WKB");
711 rtdealloc(wkb);
712 return NULL;
713 }
714
715 char *optr = hexwkb;
716 uint8_t *iptr = wkb;
717 const char hexchar[]="0123456789ABCDEF";
718 while (wkbsize--) {
719 uint8_t v = *iptr++;
720 *optr++ = hexchar[v>>4];
721 *optr++ = hexchar[v & 0x0F];
722 }
723 *optr = '\0'; /* Null-terminate */
724
725 rtdealloc(wkb); /* we don't need this anymore */
726
727 RASTER_DEBUGF(3, "rt_raster_to_hexwkb: output wkb: %s", hexwkb);
728 return hexwkb;
729}
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition rt_context.c:191
#define RASTER_DEBUG(level, msg)
Definition librtcore.h:304
#define RASTER_DEBUGF(level, msg,...)
Definition librtcore.h:308
void rtdealloc(void *mem)
Definition rt_context.c:206
uint8_t * rt_raster_to_wkb(rt_raster raster, int outasin, uint32_t *wkbsize)
Return this raster in WKB form.
Definition rt_wkb.c:502

References RASTER_DEBUG, RASTER_DEBUGF, rt_raster_to_wkb(), rtalloc(), rtdealloc(), and rterror().

Referenced by build_overview(), convert_raster(), RASTER_asHexWKB(), RASTER_out(), and test_raster_wkb().

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