PostGIS  2.1.10dev-r@@SVN_REVISION@@
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 8062 of file rt_api.c.

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

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

8062  {
8063  uint8_t *wkb = NULL;
8064  char* hexwkb = NULL;
8065  uint32_t i = 0;
8066  uint32_t wkbsize = 0;
8067 
8068  assert(NULL != raster);
8069  assert(NULL != hexwkbsize);
8070 
8071  RASTER_DEBUG(2, "rt_raster_to_hexwkb: calling rt_raster_to_wkb");
8072 
8073  wkb = rt_raster_to_wkb(raster, outasin, &wkbsize);
8074 
8075  RASTER_DEBUG(3, "rt_raster_to_hexwkb: rt_raster_to_wkb returned");
8076 
8077  *hexwkbsize = wkbsize * 2; /* hex is 2 times bytes */
8078  hexwkb = (char*) rtalloc((*hexwkbsize) + 1);
8079  if (!hexwkb) {
8080  rterror("rt_raster_to_hexwkb: Out of memory hexifying raster WKB");
8081  rtdealloc(wkb);
8082  return NULL;
8083  }
8084  hexwkb[*hexwkbsize] = '\0'; /* Null-terminate */
8085 
8086  for (i = 0; i < wkbsize; ++i) {
8087  deparse_hex(wkb[i], &(hexwkb[2 * i]));
8088  }
8089 
8090  rtdealloc(wkb); /* we don't need this anymore */
8091 
8092  RASTER_DEBUGF(3, "rt_raster_to_hexwkb: output wkb: %s", hexwkb);
8093  return hexwkb;
8094 }
void rtdealloc(void *mem)
Definition: rt_api.c:882
void deparse_hex(uint8_t str, char *result)
Convert a char into a human readable hex digit.
Definition: lwgeom_api.c:739
#define RASTER_DEBUG(level, msg)
Definition: rt_api.h:281
#define RASTER_DEBUGF(level, msg,...)
Definition: rt_api.h:285
uint8_t * rt_raster_to_wkb(rt_raster raster, int outasin, uint32_t *wkbsize)
Return this raster in WKB form.
Definition: rt_api.c:7887
void * rtalloc(size_t size)
Raster core memory management functions.
Definition: rt_api.c:867
void rterror(const char *fmt,...)
Raster core error and info handlers.
Definition: rt_api.c:895

Here is the call graph for this function:

Here is the caller graph for this function: