PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ 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 669 of file rt_wkb.c.

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

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

669  {
670  uint8_t *wkb = NULL;
671  char* hexwkb = NULL;
672  uint32_t wkbsize = 0;
673 
674  assert(NULL != raster);
675  assert(NULL != hexwkbsize);
676 
677  RASTER_DEBUG(2, "rt_raster_to_hexwkb: calling rt_raster_to_wkb");
678 
679  wkb = rt_raster_to_wkb(raster, outasin, &wkbsize);
680 
681  RASTER_DEBUG(3, "rt_raster_to_hexwkb: rt_raster_to_wkb returned");
682 
683  *hexwkbsize = wkbsize * 2; /* hex is 2 times bytes */
684  hexwkb = (char*) rtalloc((*hexwkbsize) + 1);
685  if (!hexwkb) {
686  rterror("rt_raster_to_hexwkb: Out of memory hexifying raster WKB");
687  rtdealloc(wkb);
688  return NULL;
689  }
690 
691  char *optr = hexwkb;
692  uint8_t *iptr = wkb;
693  const char hexchar[]="0123456789ABCDEF";
694  while (wkbsize--) {
695  uint8_t v = *iptr++;
696  *optr++ = hexchar[v>>4];
697  *optr++ = hexchar[v & 0x0F];
698  }
699  *optr = '\0'; /* Null-terminate */
700 
701  rtdealloc(wkb); /* we don't need this anymore */
702 
703  RASTER_DEBUGF(3, "rt_raster_to_hexwkb: output wkb: %s", hexwkb);
704  return hexwkb;
705 }
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
uint8_t * rt_raster_to_wkb(rt_raster raster, int outasin, uint32_t *wkbsize)
Return this raster in WKB form.
Definition: rt_wkb.c:494
#define RASTER_DEBUGF(level, msg,...)
Definition: librtcore.h:311
void rtdealloc(void *mem)
Definition: rt_context.c:186
#define RASTER_DEBUG(level, msg)
Definition: librtcore.h:307
Here is the call graph for this function:
Here is the caller graph for this function: