PostGIS  2.5.7dev-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 679 of file rt_wkb.c.

679  {
680  uint8_t *wkb = NULL;
681  char* hexwkb = NULL;
682  uint32_t wkbsize = 0;
683 
684  assert(NULL != raster);
685  assert(NULL != hexwkbsize);
686 
687  RASTER_DEBUG(2, "rt_raster_to_hexwkb: calling rt_raster_to_wkb");
688 
689  wkb = rt_raster_to_wkb(raster, outasin, &wkbsize);
690 
691  RASTER_DEBUG(3, "rt_raster_to_hexwkb: rt_raster_to_wkb returned");
692 
693  *hexwkbsize = wkbsize * 2; /* hex is 2 times bytes */
694  hexwkb = (char*) rtalloc((*hexwkbsize) + 1);
695  if (!hexwkb) {
696  rterror("rt_raster_to_hexwkb: Out of memory hexifying raster WKB");
697  rtdealloc(wkb);
698  return NULL;
699  }
700 
701  char *optr = hexwkb;
702  uint8_t *iptr = wkb;
703  const char hexchar[]="0123456789ABCDEF";
704  while (wkbsize--) {
705  uint8_t v = *iptr++;
706  *optr++ = hexchar[v>>4];
707  *optr++ = hexchar[v & 0x0F];
708  }
709  *optr = '\0'; /* Null-terminate */
710 
711  rtdealloc(wkb); /* we don't need this anymore */
712 
713  RASTER_DEBUGF(3, "rt_raster_to_hexwkb: output wkb: %s", hexwkb);
714  return hexwkb;
715 }
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
#define RASTER_DEBUG(level, msg)
Definition: librtcore.h:295
#define RASTER_DEBUGF(level, msg,...)
Definition: librtcore.h:299
void rtdealloc(void *mem)
Definition: rt_context.c:186
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
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
unsigned int uint32_t
Definition: uthash.h:78
unsigned char uint8_t
Definition: uthash.h:79

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

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

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