PostGIS 3.6.2dev-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 682 of file rt_wkb.c.

682 {
683 uint8_t *wkb = NULL;
684 char* hexwkb = NULL;
685 uint32_t wkbsize = 0;
686
687 assert(NULL != raster);
688 assert(NULL != hexwkbsize);
689
690 RASTER_DEBUG(2, "rt_raster_to_hexwkb: calling rt_raster_to_wkb");
691
692 wkb = rt_raster_to_wkb(raster, outasin, &wkbsize);
693
694 RASTER_DEBUG(3, "rt_raster_to_hexwkb: rt_raster_to_wkb returned");
695
696 *hexwkbsize = wkbsize * 2; /* hex is 2 times bytes */
697 hexwkb = (char*) rtalloc((*hexwkbsize) + 1);
698 if (!hexwkb) {
699 rterror("rt_raster_to_hexwkb: Out of memory hexifying raster WKB");
700 rtdealloc(wkb);
701 return NULL;
702 }
703
704 char *optr = hexwkb;
705 uint8_t *iptr = wkb;
706 const char hexchar[]="0123456789ABCDEF";
707 while (wkbsize--) {
708 uint8_t v = *iptr++;
709 *optr++ = hexchar[v>>4];
710 *optr++ = hexchar[v & 0x0F];
711 }
712 *optr = '\0'; /* Null-terminate */
713
714 rtdealloc(wkb); /* we don't need this anymore */
715
716 RASTER_DEBUGF(3, "rt_raster_to_hexwkb: output wkb: %s", hexwkb);
717 return hexwkb;
718}
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:302
#define RASTER_DEBUGF(level, msg,...)
Definition librtcore.h:306
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:497

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: